Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error : Invalid code/color length, must be power of 2 and 2 #16

Closed
srijackec opened this issue Oct 3, 2016 · 3 comments
Closed

Error : Invalid code/color length, must be power of 2 and 2 #16

srijackec opened this issue Oct 3, 2016 · 3 comments

Comments

@srijackec
Copy link

Throwing this error and returning empty gif file. Please help me to resolve this.

@tobozo
Copy link

tobozo commented Oct 3, 2016

Provide the faulty gif file maybe ?

@deanm
Copy link
Owner

deanm commented Oct 3, 2016

You know, it's always more helpful to create better bug reports, with sample code, etc, otherwise we have to guess what you are doing. But anyway, seems like you must be trying to create a gif, as that exception comes from check_palette_and_num_colors() in GifWriter.

The exception is self explanatory, the palette you supply must be a power of two between 2 and 256 (inclusive). That is simply how the GIF format works, search for "Size of Global Color Table" in: https://www.w3.org/Graphics/GIF/spec-gif89a.txt

So, make sure your palette conforms to those restrictions, the file format doesn't allow you to do anything else. Attached is a screenshot of Photoshop's GIF dialog. You can see the same restriction on palette sizes there.

Of course, you don't need to use every color in the palette, so if you have 61 colors you can create a palette of 64 and put whatever you want in the extra 3 entries.

@deanm deanm closed this as completed Oct 3, 2016
@srijackec
Copy link
Author

Thanks for the instance response. We are uding three js 3D container and
capturing the animation to gif not a palette. That color differ models
to models. In this scenario how can do I proceed.

FYI : When I load a model without texture thats black color its creating
the gif but when its a color its showing the error.

On 2016-10-03 10:57, Dean McNamee wrote:

You know, it's always more helpful to create better bug reports, with
sample code, etc, otherwise we have to guess what you are doing. But
anyway, seems like you must be trying to create a gif, as that
exception comes from check_palette_and_num_colors() in GifWriter.

The exception is self explanatory, the palette you supply must be a
power of two between 2 and 256 (inclusive). That is simply how the GIF
format works, search for "Size of Global Color Table" in:
https://www.w3.org/Graphics/GIF/spec-gif89a.txt [1]

So, make sure your palette conforms to those restrictions, the file
format doesn't allow you to do anything else. Attached is a screenshot
of Photoshop's GIF dialog. You can see the same restriction on palette
sizes there.

[2]

Of course, you don't need to use every color in the palette, so if you
have 61 colors you can create a palette of 64 and put whatever you
want in the extra 3 entries.

You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub [3], or mute the
thread [4].

Links:

[1] https://www.w3.org/Graphics/GIF/spec-gif89a.txt
[2]
https://cloud.githubusercontent.com/assets/56582/19041871/266befe6-898a-11e6-9500-ca04b828e089.png
[3] #16 (comment)
[4]
https://github.com/notifications/unsubscribe-auth/AMXVy7aiD-3VKdQbGOg8aAo5K4JovMxqks5qwRfwgaJpZM4KMRMV

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants