first posting, first problem
I want to generate thumbnail JPEG files for larger picture files on the fly (i.e. on the first request). I tried the following code but it will always create a black image (of correct size):
-x---C-u-t---h-e-r-e---x-
$srcimage = ImageCreateFromPng($table[$scan]['file']);
$srcX = ImageSX($srcimage);
$srcY = ImageSY($srcimage);
$facX = $srcX / 600;
$facY = $srcY / 800;
$fac = ($facX > $facY) ? $facX : $facY;
$dstX = intval($srcX / $fac);
$dstY = intval($srcY / $fac);
// ImageCreateTrueColor won't work (image creation fails)
$dstimg = ImageCreate($dstX, $dstY);
ImageCopyResized($dstimg, $srcimg, 0, 0, 0, 0, $dstX, $dstY, $srcX, $srcY);
ImagePaletteCopy($dstimg,$srcimg);
ImageJpeg($dstimg, $table[$scan]['fthb']);
ImageDestroy($dstimg);
ImageDestroy($srcimg);
-x---C-u-t---h-e-r-e---x-
I think it has something to do with the color palettes but my knowledge in image processing is very low.
Any tip for me, in best case a working code?
Ciao, Meph