i need to divide photo to X * Y pieces. That are separated N px line each other.
Image (4 x 3) = 12 pieces:
Image before:

Image after:



Code: Select all
convert -draw -stroke red -strokewidth 10 -draw "line 50,0 50,200" -draw "line 100,0 100,200" -draw "line 0,50 200,50" output.jpgCode: Select all
convert flowers.jpg -crop 200x200 image-%d.jpg

Code: Select all
convert input.jpg -background NavajoWhite -gravity south -splice 0x20+0+0 output.jpg Code: Select all
convert -draw -stroke red -strokewidth 10 -draw "line 50,0 50,200" -draw "line 100,0 100,200" -draw "line 0,50 200,50" output.jpgCode: Select all
<?php
// Setup the error array
$array = array();
exec("/home/user/public_html/folder/grid -s 200,100 -c red -t 10 -o 1 input.jpg grid.png 2>&1", $array);
//Display any errors
echo "<br><pre>".print_r($array)."<br>";
echo "</pre>";
?> Code: Select all
<?php
$size = getimagesize("input.jpg");
$width = round($size[0]/5);
$height = round($size[1]/3);
exec("/home/user/public_html/folder/grid -s $width,$height -c red -t 10 -o 1 input.jpg grid.png 2>&1", $array);
//Display any errors
echo "<br><pre>".print_r($array)."<br>";
echo "</pre>";
?>
<img src="grid.png">
Thanks for the explanation Fred; I did try Cygwin on my old PC but could not get it to work - the main problem I suppose was that I was not that interested in it !Grid is a unix bash shell script and requires PHP or IM compiled and accessible on a Unix or Max OSX platform. To use on Windows, you need to have Cygwin installed on Windows or something like it as there are numerous Unix function calls, such as grep, sed, awk, tr, bc, etc.
I just wanted to say that that code worked great for me to split an image into 9 separate images (after changing 25% to 33.333%, of course), but only after leaving out the -repage option. convert complains that -repage requires an argument.fmw42 wrote:convert image.jpg -crop 25%x33.333% +repage image_%d.jpg
should make an array of 12 separate images number 0-11.
Users browsing this forum: Bing [Bot] and 5 guests