Skip Menu |

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

Report information
The Basics
Id: 15167
Status: resolved
Worked: 50 min
Priority: 0/
Queue: Image-Info

People
Owner: TELS [...] cpan.org
Requestors: peterhi [...] ntlworld.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in:
  • 1.16
  • 1.17
  • 1.18
  • 1.19
  • 1.20
Fixed in: (no value)



Subject: Incorrect width and height for JPG files
Image-Info version 1.16 Perl v5.8.6 Darwin Kernel Version 8.2.0 With some JPG files Image-Info is returning the width and height from dim() as either undefined or some large positive integer. For example with the following origonal size images from Flickr. The first (x,y) is the values reported from Image-Info, the second (x,y) is reported by Image-Size. 49959260.jpg (52451464,52454320) (1024,1024) 49959297.jpg (52454284,52455328) (1024,1024) 49959327.jpg (31876424,52455196) (1024,1024) 49959359.jpg (52451080,52451908) (1024,1024) 49959413.jpg (31949328,31990964) (1024,1024) 49959462.jpg (31991264,52455364) (1024,1024) 49959504.jpg (52455136,52449484) (1024,1024) 49959550.jpg (52453816,52453996) (1024,1024) 49959621.jpg (52454920,31990844) (1024,1024) 49959668.jpg (52453504,52450252) (1024,1024) 49959702.jpg (52452424,68114812) (1024,1024) I have checked the image files themselves and they do seem to be the dimensions reported by Image-Size. There appears to be (almost) no rhyme or reason to the values returned by Image-Info. As this only affects less than 1% of all the files I have tested (1,236 out of 153,151) this would seem to be no great deal.
The problem appears to be that when Image-Info returns strange values for width and height it is infact returning an array. I put in some debug: sub push_info { my @l = @_; shift @l; use Data::Dumper; print Dumper(\@l) if $l[1] =~ m/width/; my @k = caller; print Dumper(\@k) if $l[1] =~ m/width/; my($self, $n, $key) = splice(@_, 0, 3); push(@{$self->[$n]{$key}}, @_); } $VAR1 = [ 0, 'width', 2659 ]; $VAR1 = ['Image::Info::JPEG', '/Library/Perl/5.8.6/Image/Info/JPEG.pm', 252]; $VAR1 = [ 1, 'width', 160 ]; $VAR1 = ['Image::Info::JPEG', '/Library/Perl/5.8.6/Image/Info/JPEG.pm', 119]; $VAR1 = [ 0, 'width', 1024 ]; $VAR1 = ['Image::Info::JPEG', '/Library/Perl/5.8.6/Image/Info/JPEG.pm', 119]; The second call is the thumbnail width, the third the actual image width. Not sure where the first one comes from but it seems to be the source of the problem. This is the process_app1_exif() routine. Well thats as far as I can get, something about the exif data maybe?
Hi Peter, can you please send me an example file to test/work with? Best wishes, Tels
Subject: Re: [rt.cpan.org #15167] Incorrect width and height for JPG files
Date: Sun, 29 Jan 2006 10:24:56 +0000
To: bug-Image-Info [...] rt.cpan.org
From: peterhickman <peterhi [...] ntlworld.com>
Sure, I'll start to dig through my files for a small one that exhibits the problem. On 28 Jan 2006, at 10:40 , via RT wrote: Show quoted text
> Hi Peter, > > can you please send me an example file to test/work with? > > Best wishes, > > Tels
-- Genius has its limitations. Stupidity is not thus handicapped.
Subject: Re: [rt.cpan.org #15167] Incorrect width and height for JPG files
Date: Sun, 29 Jan 2006 12:07:37 +0100
To: bug-Image-Info [...] rt.cpan.org
From: Tels <nospam-abuse [...] bloodgate.com>
On Sunday 29 January 2006 11:25, peterhi@ntlworld.com via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=15167 > > > Sure, I'll start to dig through my files for a small one that > exhibits the problem.
Cool, please make sure that it can be distributed under the license of Perl, so I can include it directly into the testsuite :) best wishes, tels -- Signed on Sun Jan 29 12:07:03 2006 with key 0x93B84C15. Visit my photo gallery at http://bloodgate.com/photos/ PGP key on http://bloodgate.com/tels.asc or per email. "Für eine solche Bitratenreduktion muss ich den Transcoder so umkonfigurieren, dass er gröbere Quantisierungskoeffizienten für die MPEG-Matrizen verwendet, Captain" - "An die Arbeit, Mr. LaForge." -- Jens Baumeister in http://tinyurl.com/oomb
Download (untitled)
application/pgp-signature 481b

Message body not shown because it is not plain text.

Subject: Re: [rt.cpan.org #15167] Incorrect width and height for JPG files
Date: Mon, 6 Feb 2006 20:06:20 +0000
To: bug-Image-Info [...] rt.cpan.org
From: peterhickman <peterhi [...] ntlworld.com>
The following two images show the problems that I have been getting. The first shows the most common problem: 21934 45591974.jpg w=[3671,516] h=[2458,800] The second shown the more extreme version of the problem: 52914 46378318.jpg w= [[1296891946,30990,538976288,538976288,538976288,538976288,538976288,538 976288,538976288,538976288,5130571,1330520131,1330794575,1380013129,1330 511950,1229672270,541339952,807403520,76800,256,76800,342,1701981746,774 909984,3289136,876228658,976238624,825440817,825898036,0,167772163,38923 14112,1056964608],480] h= [[1296891946,30990,538976288,538976288,538976288,538976288,538976288,538 976288,538976288,538976288,5130571,1330520131,1330794575,1380013129,1330 511950,1229672270,541339952,807403520,76800,256,76800,342,1701981746,774 909984,3289136,876228658,976238624,825440817,825898036,0,167772163,38923 14112,1056964608],640] Both images were downloaded from Flickr, however I have no record as to who owns them (I will have to look into the Flickr API and see if I can find it out) they were downloaded because the Flickr permissions allowed them to be. That is to say that the images were flagged as public. Code used to detect these is as follows: #!/usr/bin/perl -w use strict; use warnings; use Image::Info qw(image_info dim); use Data::Dumper; $Data::Dumper::Indent = 0; $Data::Dumper::Terse = 1; my $path = "/Volumes/Archive/Users/peterhickman/Flickr/Stored"; if ( scalar(@ARGV) ) { foreach my $file (@ARGV) { thisfile($file); } } else { opendir( DIR, $path ) or die "Unable to open '$path': $!"; while ( my $file = readdir(DIR) ) { next if $file !~ m/\.jpg$/; thisfile( $file, $path ); } closedir(DIR); } sub thisfile { my ( $file, $path ) = @_; my $x = $file; $x = "$path/" . $x if $path; eval { my $info = image_info($x); my ( $w, $h ) = dim($info); if ( ref($w) or ref($h) ) { my $bytes = ( stat($x) )[7]; printf "%12d %s w=%s h=%s\n", $bytes, $file, Dumper($w), Dumper($h); }}; if($@) { printf "%12d %s %s\n", -1, $file, $@; } }
Download 45591974.jpg
image/jpeg 21.4k
45591974.jpg
Download 46378318.jpg
image/jpeg 51.6k
46378318.jpg
On 29 Jan 2006, at 11:12 , nospam-abuse@bloodgate.com via RT wrote: Show quoted text
> On Sunday 29 January 2006 11:25, peterhi@ntlworld.com via RT wrote:
>> <URL: http://rt.cpan.org/Ticket/Display.html?id=15167 > >> >> Sure, I'll start to dig through my files for a small one that >> exhibits the problem.
> > Cool, please make sure that it can be distributed under the license of > Perl, so I can include it directly into the testsuite :) > > best wishes, > > tels
-- Beware of people who agree with you
Subject: Re: [rt.cpan.org #15167] Incorrect width and height for JPG files
Date: Mon, 6 Feb 2006 20:06:20 +0000
To: bug-Image-Info [...] rt.cpan.org
From: peterhickman <peterhi [...] ntlworld.com>
The following two images show the problems that I have been getting. The first shows the most common problem: 21934 45591974.jpg w=[3671,516] h=[2458,800] The second shown the more extreme version of the problem: 52914 46378318.jpg w= [[1296891946,30990,538976288,538976288,538976288,538976288,538976288,538 976288,538976288,538976288,5130571,1330520131,1330794575,1380013129,1330 511950,1229672270,541339952,807403520,76800,256,76800,342,1701981746,774 909984,3289136,876228658,976238624,825440817,825898036,0,167772163,38923 14112,1056964608],480] h= [[1296891946,30990,538976288,538976288,538976288,538976288,538976288,538 976288,538976288,538976288,5130571,1330520131,1330794575,1380013129,1330 511950,1229672270,541339952,807403520,76800,256,76800,342,1701981746,774 909984,3289136,876228658,976238624,825440817,825898036,0,167772163,38923 14112,1056964608],640] Both images were downloaded from Flickr, however I have no record as to who owns them (I will have to look into the Flickr API and see if I can find it out) they were downloaded because the Flickr permissions allowed them to be. That is to say that the images were flagged as public. Code used to detect these is as follows: #!/usr/bin/perl -w use strict; use warnings; use Image::Info qw(image_info dim); use Data::Dumper; $Data::Dumper::Indent = 0; $Data::Dumper::Terse = 1; my $path = "/Volumes/Archive/Users/peterhickman/Flickr/Stored"; if ( scalar(@ARGV) ) { foreach my $file (@ARGV) { thisfile($file); } } else { opendir( DIR, $path ) or die "Unable to open '$path': $!"; while ( my $file = readdir(DIR) ) { next if $file !~ m/\.jpg$/; thisfile( $file, $path ); } closedir(DIR); } sub thisfile { my ( $file, $path ) = @_; my $x = $file; $x = "$path/" . $x if $path; eval { my $info = image_info($x); my ( $w, $h ) = dim($info); if ( ref($w) or ref($h) ) { my $bytes = ( stat($x) )[7]; printf "%12d %s w=%s h=%s\n", $bytes, $file, Dumper($w), Dumper($h); }}; if($@) { printf "%12d %s %s\n", -1, $file, $@; } }
Download 45591974.jpg
image/jpeg 21.4k
45591974.jpg
Download 46378318.jpg
image/jpeg 51.6k
46378318.jpg
On 29 Jan 2006, at 11:12 , nospam-abuse@bloodgate.com via RT wrote: Show quoted text
> On Sunday 29 January 2006 11:25, peterhi@ntlworld.com via RT wrote:
>> <URL: http://rt.cpan.org/Ticket/Display.html?id=15167 > >> >> Sure, I'll start to dig through my files for a small one that >> exhibits the problem.
> > Cool, please make sure that it can be distributed under the license of > Perl, so I can include it directly into the testsuite :) > > best wishes, > > tels
-- Beware of people who agree with you
RT-Send-CC: Gisle Aas <gisle [...] activestate.com>
Moin Peter, trying to resolve this, but I am stumped: =item width This is the number of pixels horizontally in the image. =item height This is the number of pixels vertically in the image. (TIFF use the name ImageLength for this field.) The POD doesn't say it should be [1024,240] for an image with a width 1024 and a thumbnail width of 240, but the code very clearly processes chunks and the pushes each info onto an array. For most images, it works because there is only one jnk with a width. For some it fails because there is more than one chunk with a width. (wether this can/should happen, I don't know) I am Ccing Gisle, maybe he can help with some info. Best wishes, Tels
On Sat Apr 29 12:31:01 2006, TELS wrote: Show quoted text
> Moin Peter, > > trying to resolve this, but I am stumped: >
Sorry for the long delay. It took a few try to get a reply from the original author, but he said: Me writes: Show quoted text
>> Moin Gisle, >> >> pinging you again since I didn't see a reply for some months: >> >> Image::Info has a problem with images with embedded thumbnails, in >> that it returns [1024,240] (aka width of image, widht of embedded >> thumbnail) for the width instead of just (1024). Is this behaviour >> intended, or a bug?
> >That does not appear to be intended behaviour. Bug! > >--Gisle
So I am gonna fix this. :) Tels
On Mon Apr 23 18:24:06 2007, TELS wrote: Show quoted text
> On Sat Apr 29 12:31:01 2006, TELS wrote:
> > Moin Peter,
> So I am gonna fix this. :)
Sorry, I did not yet have time to look into this issue. :( Tels
I fixed this bug by keeping the biggest value for width/height, instead of creating an array with all values. The fix is in the just uploaded v1.28 of Image-Info. If this doesn't really solve the issue, please re-open this bug report by replying to this email :) Thank you for your report, and sorry for the long delay, Tels