Hello i have big technical problem i need crop image to parts like this:
One parts is 500px x 500px except in the case where there is less space.
Example image size is 1920px x 1080px totaly i have 12 parts of image.
Me problem i have very big image it's 30 000px x 20 000px it's have about 2800parts.
I try to use php imagemagic library
imagemagic command line codes: http://www.ioncannon.net/linux/81/5-imagemagick-command-line-examples-part-1/
with this command i can crop image place: convert flower.jpg -crop 500×500+0+0 flower_crop.jpg
first and seconds arguments width height of part: 500;
the third and fourth arguments it's the from the location started clipping;
I tested crop one part per 20 seconds if i need get 2800 parts i need about: 2800 x 20 / 60 / 60 = 15-16~ hours
I need get fastest result. How i can do it..
full php code:
public function cutImgIntoPieces($imgPieceSizeWidth, $imgPieceSizeHeight, $outputDir) {
$pieceWidth = $imgPieceSizeWidth;
$pieceHeight = $imgPieceSizeHeight;
$divWidth = floor($this->getImgWidth() / $pieceWidth);
$modWidth = $this->getImgWidth() % $pieceWidth;
$divHeight = floor($this->getImgHeight() / $pieceHeight);
$modHeight = $this->getImgHeight() % $pieceHeight;
for ($i = 0; $i <= $divWidth; $i++) {
for ($j = 0; $j <= $divHeight; $j++) {
$pieceWidth = ($i == $divWidth ? $modWidth : $imgPieceSizeWidth);
$pieceHeight = ($j == $divHeight ? $modHeight : $imgPieceSizeHeight);
exec("cd ". $this->getDirName() . " & convert " . $this->getFullFileName() . " -crop " . $pieceWidth . "x" . $pieceHeight . "+" . $imgPieceSizeWidth * $i . "+" . $imgPieceSizeHeight * $j . " " . $i . "_" . $j . ".jpg");
}
}
}
$img->cutImgIntoPieces(500, 500, 'C:/xampp/htdocs/');