Fejl ved generering af thumps med imagejpeg()
Hejsa..Jeg har pludseligt fået nogle problemer med mit script til at lave thumps med php.. det her virket før, men nu er den død..
fejlen sker i imagejpeg(), men kan ikke se hvorfår den opstår..
min kode ser således ud:
$thumb_size; // Størrelse på thump i px
$imgcomp; // Komprimeringsgrad
$image_sourcefile; // Kilde for stort billede
$thump_destination; // Destinationsfil [Thump]
echo '833: > thumb_size = '.$thumb_size.' < <br>';
echo '833: > imgcomp = '.$imgcomp.' < <br>';
echo '833: > image_sourcefile = '.$image_sourcefile.' < <br>';
echo '833: > thump_destination = '.$thump_destination.' < <br>';
if(file_exists($image_sourcefile)){
$g_is=getimagesize($image_sourcefile);
$img_width = $g_is[0];
$img_height = $g_is[1];
if($img_width >= $img_height){
$copy_mark_x = ($img_width - $img_height) / 2;
$copy_mark_y = 0;
$img_width = $g_is[1];
$img_height = $g_is[1];
}else{
$copy_mark_x = 0;
$copy_mark_y = ($img_height - $img_width) / 2;
$img_width = $g_is[0];
$img_height = $g_is[0];
}
if ($img_src = imagecreatefromjpeg($image_sourcefile)){
echo 'imagecreatefromjpeg Lykkedes <br>';
}else{
echo'imagecreatefromjpeg Lykkedes IKKE <br>';
}
if ($img_dst = imagecreatetruecolor($thumb_size,$thumb_size)){
echo 'imagecreatetruecolor Lykkedes <br>';
}else{
echo'imagecreatetruecolor Lykkedes IKKE <br>';
}
if (imagecopyresampled($img_dst, $img_src, 0, 0, $copy_mark_x, $copy_mark_y, $thumb_size, $thumb_size, $img_width, $img_height)){
echo 'imagecopyresampled Lykkedes <br>';
}else {
echo'imagecopyresampled Lykkedes IKKE <br>';
}
echo '857: > img_dst = '.$img_dst.' < <br>';
echo '857: > img_src = '.$img_src.' < <br>';
echo '857: > thump_destination = '.$thump_destination.' < <br>';
if (imagejpeg($img_dst, $thump_destination, $imgcomp)){
echo 'imagejpeg lykkedes <br>';
}else{
echo ' FEJL: imagejpeg('.$img_dst.', '.$thump_destination.', '.$imgcomp.') lykkedes IKKE<br>';
}
imagedestroy($img_dst);
Og mit output i browseren:
151220051026_kasper_birk_arkitektur.jpgmove_uploaded_file
833: > thumb_size = 100 <
833: > imgcomp = 75 <
833: > image_sourcefile = wallpapers/151220051026_kasper_birk_arkitektur.jpg <
833: > thump_destination = wallpapers/s_151220051026_kasper_birk_arkitektur.jpg <
imagecreatefromjpeg Lykkedes
imagecreatetruecolor Lykkedes
imagecopyresampled Lykkedes
857: > img_dst = Resource id #20 <
857: > img_src = Resource id #19 <
857: > thump_destination = wallpapers/s_151220051026_kasper_birk_arkitektur.jpg <
FEJL: imagejpeg(Resource id #20, wallpapers/s_151220051026_kasper_birk_arkitektur.jpg, 75) lykkedes IKKE
