Post
by dge » 2024-04-25 21:50
Thanks Jan, that's very helpful.
So I had a programmer try to implement this in a hook but he can't seem to get it working. Do you see anything obviously wrong?
Here is the hook he wrote:
function products_after_update($data, $memberInfo, &$args){
$filename = $data['photo'];
$width = 200;
$height = 200;
// Content type
header('Content-Type: image/jpeg');
// Get new dimensions
list($width_orig, $height_orig) = getimagesize($filename);
$ratio_orig = $width_orig/$height_orig;
if ($width/$height > $ratio_orig) {
$width = $height*$ratio_orig;
} else {
$height = $width/$ratio_orig;
}
// Resample
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
// Output
imagejpeg($image_p, null, 100);
createThumbnail($data['photo'], array('width' => 49, 'height' => 49, 'identifier' => ''));
return TRUE;
}
---------------------------
He ALSO tried doing the thumbnail separately, in the after_update hook (also doesn't seem to work)
function products_after_update($data, $memberInfo, &$args){
createThumbnail($data['photo'], array('width' => 49, 'height' => 49, 'identifier' => ''));
return TRUE;
}