When I add a png image, using the image module's image content-type node, it seems to upload fine since the files show up on the server. However, I get a blank page on upload and when I try to access the new image node. On upload, I get this error:

[Fri Jul 13 20:16:04 2007] [error] PHP Fatal error: Uncaught exception 'PelJpegInvalidMarkerException' with message 'Invalid marker found at offset 0: 0x89' in /home/flfn/www/drupal/sites/all/modules/exif/pel/PelJpeg.php:220\nStack trace:\n#0 /home/flfn/www/drupal/sites/all/modules/exif/pel/PelJpeg.php(315): PelJpeg->load(Object(PelDataWindow))\n#1 /home/flfn/www/drupal/sites/all/modules/exif/pel/PelJpeg.php(163): PelJpeg->loadFile('files//images/D...')\n#2 /home/flfn/www/drupal/sites/all/modules/exif/exif.module(44): PelJpeg->__construct('files//images/D...')\n#3 /home/flfn/www/drupal/modules/node/node.module(462): exif_nodeapi(Object(stdClass), 'view', NULL, NULL)\n#4 /home/flfn/www/drupal/sites/all/modules/og/og.module(1766): node_invoke_nodeapi(Object(stdClass), 'view', NULL, NULL)\n#5 /home/flfn/www/drupal/sites/all/modules/og/og.module(1690): og_node_view(Object(stdClass))\n#6 /home/flfn/www/drupal/sites/all/modules/og/og.module(1351): og_mail('Image', Object(stdClass))\n#7 /home/flfn/www/drupal/modules/node/node.module(462): og_nodeapi(Object(stdClass), 'insert' in /home/flfn/www/drupal/sites/all/modules/exif/pel/PelJpeg.php on line 220

It appears that this module breaks the image module when uploading a png file, which does not support exif data. The code should probably verify that the image is a jpeg before it tries to perform any exif-related queries.

CommentFileSizeAuthor
#4 exif_png.patch788 bytesdavid lesieur

Comments

scott falconer’s picture

Here's what I did to fix this...

changed lines 43 through 48 to:

if (!is_file($file)) break;
      $ext = array_pop(explode('.',$file));
      $ext = substr($ext,0,1);
      $ext = strtoupper($ext);
      if ($ext != 'J') break;
      $jpeg = new PelJpeg($file);

I'm not real good at php, so maybe this isn't the best way to go about it, but it at least fixes the problem.

Basically, it takes the first letter from the file extension, makes it upper case, and then checks if it's an uppercase 'J' or else breaks. It'll work if the file extension is jpeg Jpeg jpg jPg etc....

raintonr’s picture

Thanks Scott. We were having the same problem, that fix works here too.

david lesieur’s picture

Status: Active » Needs review

I'll try to review this soon. Thanks for the fix!

david lesieur’s picture

Status: Needs review » Fixed
StatusFileSize
new788 bytes

Looking at the first letter of the extension is not the most solid way to check for the file format... Here's the patch that I have committed instead.

Thanks for the help!

brasto’s picture

Excellent! A big thank you from brasto!

Anonymous’s picture

Status: Fixed » Closed (fixed)