When ImageConversion is asked to scale or crop a corrupted image it causes unexpected errors. I debugged this with an older version of ImageConversion but looking at the latest code it seems that it may still be there. If this has been fixed already please excuse me.
Some jpg images have a small amount of corruption or extra bytes which most viewers ignore. When one of these slightly corrupted images is converted through GD, specifically through imagecreatefromjpeg(), it would normally throw a warning and return false. However in ez's ImageConversion code this error is suppressed. line 77 of gd_base.php: if ( !ezcBaseFeatures::hasFunction( $loadFunction ) || ( $handle = @$loadFunction( $file ) ) === '' ) { throw new ezcImageFileNotProcessableException( $file, "File could not be opened using $loadFunction." ); } (where $loadFunction is 'imagecreatefromjpeg' in this case) So no errors will be logged. $handle gets set to FALSE and since the code is only checking if it's equal to '', it does not enter the if statement. No exceptions are fired at this point, even though it has failed, and 'resource' is set to FALSE. The next time getReferenceData() is called looking for 'resource' it will fail with an exception message like: "No valid reference found for action. No resource found for the active reference" Which is not a very useful error message since the cause is a corrupted jpeg. I would suggest that the code be changed to something more like: $handle = @$loadFunction( $file ); if ( !ezcBaseFeatures::hasFunction( $loadFunction ) || !$handle || $handle === '' ) { throw new ezcImageFileNotProcessableException( $file, "File could not be opened using $loadFunction." ); } Or it could even be more specific with additional 'if's. I've also noticed that this seems to create left over tmp image files, so perhaps close() is not being called in this error condition, but I haven't looked into that yet. As a side note, this failure mode can also be obviated by using: ini_set("gd.jpeg_ignore_warning", true); Thanks. Let me know if you need a corrupted jpeg to test with. -graham -- Components mailing list Components@lists.ez.no http://lists.ez.no/mailman/listinfo/components