Skip Menu |
 

This queue is for tickets about the GD CPAN distribution.

Report information
The Basics
Id: 48052
Status: open
Priority: 0/
Queue: GD

People
Owner: Nobody in particular
Requestors: FISH [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 2.44
Fixed in: (no value)



Subject: GD::Image->_image_type does not recognise jpeg image if it starts with a comment tag
Download (untitled) / with headers
text/plain 1.1k
The code checking the type of a image is the following: sub _image_type { my $data = shift; my $magic = substr($data,0,4); return 'Png' if $magic eq "\x89PNG"; return 'Jpeg' if $magic eq "\377\330\377\340"; return 'Jpeg' if $magic eq "\377\330\377\341"; return 'Jpeg' if $magic eq "\377\330\377\355"; return 'Jpeg' if $magic eq "\377\330\377\356"; return 'Gif' if $magic eq "GIF8"; return 'Gd2' if $magic eq "gd2\000"; return 'Xpm' if substr($data,0,9) eq "/* XPM */"; return; } But there a many other values for the 3. and 4. byte. After the magic, the JFIF-Headers starts. And GD is only happy if the image _header_ starts with: 340: JFIF tag 341: EXIF data 355: A generic pointer 356: A generic pointer / copyright entry see also: http://de.wikipedia.org/wiki/JPEG_File_Interchange_Format But there are other tags which are valid i guess. I used ffmpeg to capture a frame from a video sequence and that jpeg has a comment field as a first tag (0xfe) so that GD doesn't recognize it. (See the attached file) Why do you check the 3. and 4. byte at all? Isn't checking the magic enough? If you think its necessary, you should at least add the comment tag as a valid tag i think.
Subject: Tesla01.mov.jpg
Download Tesla01.mov.jpg
image/jpeg 32.5k
Tesla01.mov.jpg
Download (untitled) / with headers
text/plain 340b
I also experienced this problem. We have user-uploaded photos, and very frequently the image resizing does not work because of the above bug. BTW, this ticket is a duplicate of #26146, that contains a proposed patch in https://rt.cpan.org/Ticket/Display.html?id=26146#txn-388769. Lincoln, can you please have a look at it? Thanks, norbi


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.