Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8704509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:07:25+00:00 2026-06-13T03:07:25+00:00

In my current problem, I have several hundred animated gifs that will preform a

  • 0

In my current problem, I have several hundred animated gifs that will preform a certain animation a few times and then do a different animation the last time. So that means the gif loops 3 times or so then on the 4th time instead of looping it will do a different animation. These loops are all just hardcoded into layers in the .gif file.

My goal is to determine the first loop and shrink the animation into ten frames. I figure that using python, I can find when the first frame equals a later frame (thereby finding the first full sequence and the number of frames). Now I have the number of frames that the animation takes, and this number is variable across the several hundred different images I’m working with. So for one image, the first loop will complete in 20 or so frames, another maybe in 25. Some will take 75 or so frames (since they are a very slow image)

My question is using these numbers (20, 25, 75, … or whatever the first loop is) how can I best turn this into only 10. In my head I did a little math, and these is a good example of what I need to figure out how to generate

20 -> 20/10 = 2 Resulting sequence: [0, 20) step 2
25 -> 25/10 = 2.5 Sequenece: [0, 25).... Step ?? should alternate between 2 and 3 somehow
75 -> 75/10 = 7.5 Sequenece: [0, 75).... Step ?? should alternate between 7 and 8 somehow

My solution could either be in bash script or python or whatever you can use from the bash shell.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:07:26+00:00Added an answer on June 13, 2026 at 3:07 am

    Note: shorter solution below

    Here’s a Python iterator class that can be used to generate these sequences:

    class quantizer:
        def __init__(self, total, limit):
            self.total = total
            self.limit = limit
            self.index = float(0)
            self.step = float(total) / float(limit)
        def __iter__(self):
            return self
        def next(self):
            if self.index >= self.total:
                raise StopIteration
            result = int(round(self.index))
            self.index += self.step
            return result
    

    better solution:
    It was pointed out to me that there’s a more concise solution using a generator:

    def quantize(total, limit):
        i, step = 0.0, float(total) / float(limit)
        while i < total:
            yield int(round(i))
            i += step
    

    You can use it like this:

    >>> for frame in quantize(25, 10):
    ...     print frame
    ... 
    
    0
    3
    5
    8
    10
    13
    15
    18
    20
    23
    >>> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a little problem implementing some serialization/deserialization logic. I have several classes that
I want to have a class Utils, that will have several methods used all
The following code summarizes the problem I have at the moment. My current execution
I have a problem with obtaining the current user location. Code at first works
ok i got this problem. i have this routes: (code bit change) File:/home/dotcloud/current/config/routes.js exports.routes
I'm trying to write a re-usable .NET Assembly that implements WCF. My current problem
I'm looking for an elegant pattern to solve this problem: I have several user
My problem is this: I have a C/C++ app that runs under Linux, and
I have several DLLs in my project that are defined to create their *.pdb
I have several BusinessObject classes that refer to each other and I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.