Forum Moderators: coopster

Message Too Old, No Replies

iMagick getting wrong size for gif

         

Tommybs

6:59 pm on Nov 5, 2009 (gmt 0)

10+ Year Member



Hi,

I'm using iMagick for php to resize images, create thumbnails etc. As part of the resize I check that an imagewidth isn't greater then 700. If it is I want to make the width a maximum of 700. Resizes work fine, except when I use a transparent gif. It totally ignores the size of the transparent background and thinks it isn't over 700px even if it is, as such it doesn't resize the image and it ruins the look of my site. Does anybody know a way around this? I've tried searching google and the documentation but no luck so far.

Thanks

rainborick

9:18 pm on Nov 5, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Can you post your code? As I read the specification, GIF stores the image size once for the entire image. That is, there is no separate transparency layer to cause the problem you describe. Have you tried more than one image with transparency or is it just having trouble with a single image file?

Tommybs

7:27 am on Nov 6, 2009 (gmt 0)

10+ Year Member



Hey, sorry don't have access to the code at this exact moment, but it does appear to be just 1 image ( just knocked up a different one now), but as I was having a 'moment' yesterday I totally forgot that the image I was testing with was animated so I think this may have something to do with the problem

rocknbil

6:38 pm on Nov 6, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<whew> Yeah that would do it, worked with ImageMagick for years in both Perl and PHP and have never seen this.

In an animated .gif, the header info that determines the size is a bit different. It probably grabbed the first actual .gif in the ani on the stack and set the size from that. There are methods to compile animations with ImageMagick, but reading an animation already compiled will do some weird stuff.