Hello,
I try to cycle a an array of pictures and have them them cut to a square, resized and storing them on a different location. The Problem is, that I can't get the saving right and the strange thing is no error is being displayed.
Here it is:
// getting number of pics (max. 3)
$num = count($content);
if ($num == 0) {
$max = 0;
} elseif ($num == 1) {
$max = 1;
} elseif ($num == 2) {
$max = 2;
} else {
$max = 3;
}
$i = 0;
// resizing and storing.. resizing seems to work since there is no error message and when displyed in the browser (without header) garbage appears.
while ($i < $max) {
$currentPic = $pathToPictures . $content[$i];
$src = imageCreateFromJPEG($currentPic);
$org_y = imagesy($src);
$org_x = imagesx($src);
$dst = imagecreate (60, 60);
if($org_y > $org_x) {
$diff = ($org_y - $org_x)/2;
imagecopyresized ($dst, $src, 0, 0, 0,$diff0, 60, 60, $org_x, $org_x);
} elseif ($org_y < $org_x) {
$diff = ($org_x - $org_y)/2;
imagecopyresized ($dst, $src, 0, 0, $diff, 0, 60, 60, $org_y, $org_y);
} else {
imagecopyresized ($dst, $src, 0, 0, 0, 0, 60, 60, $org_x, $org_y);
}
$i++;
// the path is defined as absolut server path like /home/htdocs/..... the directory is currently chmod to 777
$savePath = $pathToIconPix . $galleryType . "/" . $galleryId . "/" . $i . ".jpg";
imageJPEG($dst, $savePath, 75);
imageDestroy($dst);
}