pixelmatix / AnimatedGIFs

MIT License
62 stars 34 forks source link

Many 32x32 index color animated gifs I created don't play (but some do). Here's one that doesn't (seems to crash teensy) #2

Closed swb1701 closed 9 years ago

swb1701 commented 9 years ago

totoro3

pixelmatix commented 9 years ago

I'll trace down what's causing this GIF to break the sketch. What tool did you use to create it?

swb1701 commented 9 years ago

I used gimp to scale it down and save it. Sent from my Verizon Wireless BlackBerry

-----Original Message----- From: Pixelmatix notifications@github.com Date: Sun, 28 Sep 2014 13:34:48 To: pixelmatix/AnimatedGIFsAnimatedGIFs@noreply.github.com Reply-To: pixelmatix/AnimatedGIFs reply@reply.github.com Cc: swb1701swb1701@gmail.com Subject: Re: [AnimatedGIFs] Many 32x32 index color animated gifs I created don't play (but some do). Here's one that doesn't (seems to crash teensy) (#2)

I'll trace down what's causing this GIF to break the sketch. What tool did you use to create it?


Reply to this email directly or view it on GitHub: https://github.com/pixelmatix/AnimatedGIFs/issues/2#issuecomment-57099038

pixelmatix commented 9 years ago

This GIF can't play as the image data for the first frame is 1133 bytes long, and the GIF parser tries to write that into a 1024 byte buffer. I didn't write this code and I'm not sure the best way to fix, but I'm looking into it.

pixelmatix commented 9 years ago

If you just want to get your GIF playing without waiting for the real fix to be committed, change line 103 in GIFParseFunctions.cpp to:

byte lzwImageData[1280];

That gives the buffer enough room to decode the frames in this animation at least.

swb1701 commented 9 years ago

Thanks, I'll give that a try tonight. Sent from my Verizon Wireless BlackBerry

-----Original Message----- From: Pixelmatix notifications@github.com Date: Sun, 28 Sep 2014 14:52:47 To: pixelmatix/AnimatedGIFsAnimatedGIFs@noreply.github.com Reply-To: pixelmatix/AnimatedGIFs reply@reply.github.com Cc: swb1701swb1701@gmail.com Subject: Re: [AnimatedGIFs] Many 32x32 index color animated gifs I created don't play (but some do). Here's one that doesn't (seems to crash teensy) (#2)

If you just want to get your GIF playing without waiting for the real fix to be committed, change line 103 in GIFParseFunctions.cpp to:

byte lzwImageData[1280];

That gives the buffer enough room to decode the frames in this animation at least.


Reply to this email directly or view it on GitHub: https://github.com/pixelmatix/AnimatedGIFs/issues/2#issuecomment-57101649

swb1701 commented 9 years ago

You may have also seen I had trouble building Aurora (somehow the CRGB's don't cast to rgb24's for the smart matrix library). If you have any ideas there that would be helpful too. For this, I was just running the AnimatedGif demo independently -- which does build. Thanks. Sent from my Verizon Wireless BlackBerry

-----Original Message----- From: swb1701@gmail.com Date: Sun, 28 Sep 2014 22:14:33 To: pixelmatix/AnimatedGIFsreply@reply.github.com; pixelmatix/AnimatedGIFsAnimatedGIFs@noreply.github.com Reply-To: swb1701@gmail.com Subject: Re: [AnimatedGIFs] Many 32x32 index color animated gifs I created don't play (but some do). Here's one that doesn't (seems to crash teensy) (#2)

Thanks, I'll give that a try tonight. Sent from my Verizon Wireless BlackBerry

-----Original Message----- From: Pixelmatix notifications@github.com Date: Sun, 28 Sep 2014 14:52:47 To: pixelmatix/AnimatedGIFsAnimatedGIFs@noreply.github.com Reply-To: pixelmatix/AnimatedGIFs reply@reply.github.com Cc: swb1701swb1701@gmail.com Subject: Re: [AnimatedGIFs] Many 32x32 index color animated gifs I created don't play (but some do). Here's one that doesn't (seems to crash teensy) (#2)

If you just want to get your GIF playing without waiting for the real fix to be committed, change line 103 in GIFParseFunctions.cpp to:

byte lzwImageData[1280];

That gives the buffer enough room to decode the frames in this animation at least.


Reply to this email directly or view it on GitHub: https://github.com/pixelmatix/AnimatedGIFs/issues/2#issuecomment-57101649

pixelmatix commented 9 years ago

@CraigLindley The AnimatedGIFs sketch can't play this file as is, the lzw compressed image data for the first frame at least won't fit into 1024 bytes. It seems that for some complex images, the LZW compressed data is larger than the raw bitmap source. I'm increasing the the lzwImageData buffer size in AnimatedGIFs, and will add bounds checking as well. Do you have a recommendation on what size to set it to? Is there a theoretical limit I could compute with a better understanding of LZW compression?

ghost commented 9 years ago

This is interesting. I have never encountered this issue before and I have been using this decoder code for over 15 years in various forms. The gimp encoder isn't doing a very good job of compressing the image data if the compressed data is bigger than the bitmap data. It seems the encoder must be choosing a large code size to start with. Is the initial code size specifiable in gimp? If so, set it smaller than 8 bits.

That being said I don't see an issue with increasing the size of the lzw data buffer. But no I have no idea how to calculate an absolute maximum size. The important thing is that the decoded data doesn't exceed 32x32.

On Sun, Sep 28, 2014 at 5:20 PM, Pixelmatix notifications@github.com wrote:

@CraigLindley https://github.com/CraigLindley The AnimatedGIFs sketch can't play this file as is, the lzw compressed image data for the first frame at least won't fit into 1024 bytes. It seems that for some complex images, the LZW compressed data is larger than the raw bitmap source. I'm increasing the the lzwImageData buffer size in AnimatedGIFs, and will add bounds checking as well. Do you have a recommendation on what size to set it to? Is there a theoretical limit I could compute with a better understanding of LZW compression?

— Reply to this email directly or view it on GitHub https://github.com/pixelmatix/AnimatedGIFs/issues/2#issuecomment-57104327 .

Craig Lindley / Heather Hubbard

New Recordings: craigandheather.net/cnmpage.html Latest CD: craigandheather.net/hellinahandbasket.html

Personal Website: craigandheather.net

Phone: (719) 495-1873 Cell: (719) 502-7925

If you’re one in a million, there are now seven thousand people exactly like you.

pixelmatix commented 9 years ago

Fixed for now by increasing the buffer size probably too much. I created a new Issue #3 to set the buffer to the proper size

KevoHack commented 9 years ago

I found a quick work around: Just reduce the number of colors in the GIF. It reduced my photos-to-GIF from 5K to 2K. By default GIMP uses a 256 color pallet. Here's the tweak:

  1. Open image (of course);
  2. Click Image->Mode->RGB (it will show an "Indexed..." choice but clicking doesn't do anything, at least with GIMP 2.6.8 on Winderz 7 Pro);
  3. Click Image->Mode->Indexed...;
  4. Under "Colormap" change "Maximum number of colors" from 256 to something that won't wreck your 32x32 self-expression-masterpiece; in my case, I chose 16;
  5. For nicer results, under "Dithering" select "Floyd-Steinberg (reduced color bleeding)"
  6. Save as GIF, as animation, etc... Hope this helps somebody!

~Kevo

pixelmatix commented 9 years ago

@KevoHack Did you try changing the size of the buffer and found it didn't work for your GIF?

swb1701 commented 9 years ago

Expanding the lzw buffer solves the problem. I just doubled it but that's overkill. Sent from my Verizon Wireless BlackBerry

-----Original Message----- From: Pixelmatix notifications@github.com Date: Fri, 03 Oct 2014 15:43:24 To: pixelmatix/AnimatedGIFsAnimatedGIFs@noreply.github.com Reply-To: pixelmatix/AnimatedGIFs reply@reply.github.com Cc: swb1701swb1701@gmail.com Subject: Re: [AnimatedGIFs] Many 32x32 index color animated gifs I created don't play (but some do). Here's one that doesn't (seems to crash teensy) (#2)

@KevoHack Did you try changing the size of the buffer and found it didn't work for your GIF?


Reply to this email directly or view it on GitHub: https://github.com/pixelmatix/AnimatedGIFs/issues/2#issuecomment-57872548

KevoHack commented 9 years ago

Pixelmatix,

No, I did not try to change the buffer size, but I completely expect that would have worked and is obviously a much better solution than somehow forcing the image to a smaller size. However for persons not wanting to recompile code, tweaking the image is a quick solution.

My preference of an ultimate solution is the code allocates the necessary buffer!

~Kevo