More information can found here:
http://valokuva.org/?p=24
Need testers! Imagick windows build.
Need testers! Imagick windows build.
Mikko Koppanen
My blog: http://valokuva.org
My blog: http://valokuva.org
Re: Need testers! Imagick windows build.
Unsure if this is an Imagick bug or an ImageMagick problem or just unhelpful programming, but I thought I'd start with this thread and see if I get anywhere:
Recently I've used the test build of Imagick to thumbnail several tens of thousands of images. A very small percentage of them (around 10 total) produced a corrupt JPEG. This is a little annoying naturally, but the real problem comes later when I try to open the thumbnail again.
If I do this: $im->readimage("TN0711I24N3572.jpg")
I receive:
Which naturally halts the execution of the script. I would have thought that the appropriate behaviour for the readimage function would be to return FALSE - at least that way I could deal it the corrupt image.
Can anyone shed any light?
Thanks
Cully
Recently I've used the test build of Imagick to thumbnail several tens of thousands of images. A very small percentage of them (around 10 total) produced a corrupt JPEG. This is a little annoying naturally, but the real problem comes later when I try to open the thumbnail again.
If I do this: $im->readimage("TN0711I24N3572.jpg")
I receive:
Code: Select all
Fatal error: Uncaught exception 'ImagickException' with message 'Not a JPEG file: starts with 0x00 0x00 `G:\Scripts\TN0711I24N3572.jpg'' in G:\inetpub\wwwroot\admin\test2.php:8 Stack trace: #0 G:\inetpub\wwwroot\admin\test2.php(8): Imagick->readimage('G:/scripts/TN07...') #1 {main} thrown in G:\inetpub\wwwroot\admin\test2.php on line 8
Can anyone shed any light?
Thanks
Cully
Re: Need testers! Imagick windows build.
You need to try catch the exception thrown.
Try this:
Try this:
Code: Select all
$im = new Imagick();
try
{
$im->readImage( "broken.jpg" );
} catch ( ImagickException $e ) {
echo "Caught exception: " . $e->getMessage() . "<br />\n";
}
Mikko Koppanen
My blog: http://valokuva.org
My blog: http://valokuva.org
Re: Need testers! Imagick windows build.
Thanks Mikko - that'll certainly get around the problem I have now. Much appreciated.mkoppanen wrote:You need to try catch the exception thrown.
Try this:
Code: Select all
$im = new Imagick(); try { $im->readImage( "broken.jpg" ); } catch ( ImagickException $e ) { echo "Caught exception: " . $e->getMessage() . "<br />\n"; }
For the future though, wouldn't returning FALSE rather than throwing an exception make more sense for the readImage function? Given that it returns TRUE on success....
Cully
Re: Need testers! Imagick windows build.
Using the traditional php error handling would lead to something like this:
Compared to this:
Code: Select all
/* Can not pass image name to constructor since
if exceptions are not used it is not possible to catch
error in construction */
$im = new Imagick();
if ( $im->readImage( "foo.png" ) === FALSE )
{
/* Do something with the error */
}
if ( $im->thumbnailImage( 200, null ) === FALSE )
{
/* Do something with the error */
}
if ( $im->writeImage( "th_foo.png" ) === FALSE )
{
/* Do something with the error */
}
Code: Select all
try
{
$im = new Imagick( "foo.png" );
$im->thumbnailImage( 200, null );
$im->writeImage( "th_foo.png" )
}
catch ( ImagickException $e )
{
echo $e->getMessage();
die();
}
Mikko Koppanen
My blog: http://valokuva.org
My blog: http://valokuva.org