imagemagick - php imagemagic crop resize crop result is image 1x1 -


try crop image resize , crop again code:

$im = new imagick($file_name); $result=$im->cropimage($w,$h,$x,$y); $result=$im->resizeimage($nw, $nh, $resizefilter, 1,true); $result=$im->cropimage($nw,$nh,$x,$y); $iw=$im->getimagewidth(); $ih=$im->getimageheight(); 

but @ result have wrong image ($im) size $iw,$ih 1x1px.

after different combinations found solution, after resizeimage() insert thumbnailimage() same size:

$im = new imagick($file_name); $result=$im->cropimage($w,$h,$x,$y); $result=$im->resizeimage($nw, $nh, $resizefilter, 1,true); $result=$im->thumbnailimage($nw,$nh); $result=$im->cropimage($nw,$nh,$x,$y); $iw=$im->getimagewidth(); $ih=$im->getimageheight(); 

why work? may other solution ?

solution:

$im = new imagick($file_name); $result=$im->cropimage($w,$h,$x,$y); $result=$im->setimagepage($w,$h,0,0); $result=$im->resizeimage($nw, $nh, $resizefilter, 1,true); $result=$im->cropimage($nw,$nh,$x,$y); $result=$im->setimagepage($nw,$nh,0,0); $iw=$im->getimagewidth(); $ih=$im->getimageheight(); 

Comments