Skip Menu |

This queue is for tickets about the Image-Info CPAN distribution.

Report information
The Basics
Id: 78471
Status: resolved
Priority: 0/
Queue: Image-Info

People
Owner: Nobody in particular
Requestors: david.green [...] telus.net
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in:
  • 1.31
  • 1.32
Fixed in: (no value)



Subject: Image::Info doesn't handle negative height values for BMP
Image::Info can report the wrong height for BMP files. For example, given the attached file: perl -e 'use Image::Info "image_info"; use Data::Dumper; print Dumper image_info "upside-down.bmp";' $VAR1 = { 'width' => 144, 'height' => 4294967064, ... }; Noticing that the image was not 700 miles long, and that the height was suspiciously close to 2**32, I discovered that BMPs use a negative value for the height when the data is ordered from top-to-bottom (instead of the "normal" bottom-to-top). The signed 32-bit ints thus produce the shown height. (Image::Size gives the same answer, but Graphics::Magick gives the right height of 232.) A fix is to add something like this to Image::Info::BMP (line 13): $header[7] = 2**32 - $header[7] if $header[7] >= 2**31;
Subject: upside-down.bmp
Download upside-down.bmp
image/bmp 97.9k
upside-down.bmp
On 2012-07-19 16:45:12, PLATO wrote: Show quoted text
> Image::Info can report the wrong height for BMP files. For example, > given the attached file: > > perl -e 'use Image::Info "image_info"; use Data::Dumper; print Dumper > image_info "upside-down.bmp";' > > $VAR1 = { > 'width' => 144, > 'height' => 4294967064, > ... > }; > > Noticing that the image was not 700 miles long, and that the height > was suspiciously close to 2**32, I discovered > that BMPs use a negative value for the height when the data is ordered > from top-to-bottom (instead of the > "normal" bottom-to-top). The signed 32-bit ints thus produce the > shown height. > > (Image::Size gives the same answer, but Graphics::Magick gives the > right height of 232.) > > A fix is to add something like this to Image::Info::BMP (line 13): > > $header[7] = 2**32 - $header[7] if $header[7] >= 2**31;
Thanks for the report and the fix. I just uploaded 1.32_52 to CPAN. One question yet: do you have a test image available which can be included to the Image-Info distribution (which means: it's in the public domain, and it's small) or do you know what tool can create such an image? Regards, Slaven
Subject: Re: [rt.cpan.org #78471] Image::Info doesn't handle negative height values for BMP
Date: Thu, 1 Nov 2012 11:29:07 -0600
To: bug-Image-Info [...] rt.cpan.org
From: David Green <david.green [...] telus.net>
On 2012-October-25, at 3:51 pm, Slaven_Rezic via RT wrote: Show quoted text
> One question yet: do you have a test image available which can be included to the Image-Info distribution
Hi, I was able to create a small image to save as .bmp, but it always came out as a positive height. So I edited the raw file and changed the value from 3 to FFFF FFDF, which seems to work fine: it opens OK in my image editor, and the old version of Image::Info reports the large unsigned value. Thanks, David Green
Download upside-down.bmp
image/bmp 78b
upside-down.bmp
Thanks. I just upload 1.33 to PAUSE. Regards, Slaven