So I'm currently using the following script on my synology nas webstation to resize images one at a time. It is being called by a post function on another page every time the previous request has been handled.
$originalFile = 'img1.jpg';
$smallFile = 'img1_small.jpg';
$percentage = 0.2;
$mktime = date('Y-m-d H:i:s', filemtime($originalFile));
$img = imagecreatefromjpeg($originalFile);
list($width, $height) = getimagesize($originalFile);
if(function_exists("exif_read_data")){
$exif = @exif_read_data($originalFile);
if(!empty($exif['Orientation'])) {
switch($exif['Orientation']) {
case 8:
$img = imagerotate($img,90,0);
list($height, $width) = getimagesize($originalFile);
break;
case 3:
$img = imagerotate($img,180,0);
break;
case 6:
$img = imagerotate($img,-90,0);
list($height, $width) = getimagesize($originalFile);
break;
}
}
}
$newWidth = ceil($percentage * $width);
$newHeight = ceil($percentage * $height);
$resized = imagecreatetruecolor($newWidth, $newHeight);
imagecopyresampled($resized, $img, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
imagejpeg($resized, $smallFile, 100);
imagedestroy($resized);
The images are images coming from a camera so they are almost he greatest quality you can get. The issue here is that i'm not able to run imagick on my nas. I would not know how to install this for php.
Is there any smart way to speed up the process I am doing here? BTW. I am running some sql scripts as well so I'd like to keep doing this using php.