I'm trying to make 4 images from 1 image:
I used ImageMagick and it works fine. But when I try to type it in Imagick it doesn't work anymore. I get 1 image thats 50x50 pixels, instead of 4 images.
This is my ImageMagick code for testing:
Code: Select all
exec("convert input.jpg -crop 50%x50% +repage output_%d.jpg");
Code: Select all
$img = new Imagick('input.jpg');
$img->cropImage(50% , 50% , 0, 0);
$img->setImagePage(50, 50, 0, 0);
$img->writeImage('output_%d.jpg');
$img->destroy();
I got 2 known issues with this code which I can't solve:
1. It doesn't allow me to use the %. No matter what I try, with ' and " putting around it and without. It just doesn't work. The workaround that I (can) use is calculating the size of the input image and manually take 50% of both the height and width. But I don't want a ''human hand'' to be involved in this.
2. The +repage that I use in ImageMagick doesn't seem to be working when I use setImagePage with Imagick. I also tried resetImagePage(); but that didn't work either.
After I got the 4 images I want to save them separate.
I already tried a bunch of options and looked around on this forum and some Imagick tutorial sites but I couldn't find a solution that fits my problem..
I'm using ImageMagick 6.8.1-8 and a compatible Imagick version. Besides that, I use the code in PHP version 5.4.7.