Crop Bug Found!
Posted: 2009-03-24T19:14:21-07:00
No, its not a discussion about a pest for wheat, but very odd behaviour with MagickCropImage.
I've got a JPG which is loaded into a MW handle and is 800x575. It needs to be 800x574, so I use this command to criop the line off...
MagickCropImage($mwimage,800,574,0,1);
And for some reason the output is 800x563.
I've done a bit of digging around and I believe its definitely a bug. If you open the file, call the crop function then it works fine. However, this particular file has a lot of operations done on it before it calls the crop function.
I've just spent 30 mins tracking every MW call made and you can easily recreate this bug by doing the following..
downloading this file:
http://www.ukwebsystems.com/inc/0002/im ... master.jpg
& running this code...
Interestingly if you remove the earlier call to MagickCropImage the image is then cropped correctly to 574.
Is there somewhere I should repost this to attract a developer's attention!
In the mean time as a work around, if you save the file before the last crop and then reopen it again and then crop it, its fine.
It just appears to be if you crop the same image twice it doesn't work.
I've got a JPG which is loaded into a MW handle and is 800x575. It needs to be 800x574, so I use this command to criop the line off...
MagickCropImage($mwimage,800,574,0,1);
And for some reason the output is 800x563.
I've done a bit of digging around and I believe its definitely a bug. If you open the file, call the crop function then it works fine. However, this particular file has a lot of operations done on it before it calls the crop function.
I've just spent 30 mins tracking every MW call made and you can easily recreate this bug by doing the following..
downloading this file:
http://www.ukwebsystems.com/inc/0002/im ... master.jpg
& running this code...
Code: Select all
<?php
$Master = 'master.jpg';
$Production = 'production.jpg'; // Will be created
$Proof = 'proof.jpg'; // Will be created
$hFile = NewMagickWand();
MagickReadImage($hFile,$Master);
MagickResizeImage($hFile,3355,2514,MW_QuadraticFilter,1.0);
MagickCropImage($hFile,3355,2410,0,52);
MagickSetCompressionQuality($hFile,95);
MagickWriteImage($hFile,$Production);
MagickResizeImage($hFile,800,575,MW_QuadraticFilter,1.0);
// Image height is 575
MagickCropImage($hFile,800,574,0,1);
// Image height is 563!
$ImgH = MagickGetImageHeight($hFile); // $ImgH is now 563
MagickWriteImage($hFile,$Proof);
?>
Is there somewhere I should repost this to attract a developer's attention!
In the mean time as a work around, if you save the file before the last crop and then reopen it again and then crop it, its fine.
It just appears to be if you crop the same image twice it doesn't work.