Oprette thumb
Hey,Sidder og leger med et galleri, prøver at få den til at oprette thumbs automatisk. Det virkede fint på min local webserver, men hos surftown giver det problemer.
Gør følgende:
if (!is_file($cwd. "/thumbs/mini_".$billed)){
$handle = @imagecreatefromjpeg($billed);
$x=imagesx($handle);
$y=imagesy($handle);
if($x > $y){
$max = $x;
$min = $y;
}
if($x <= $y){
$max = $y;
$min = $x;
}
$size_in_pixel = '100';
$rate = $max/$size_in_pixel;
$final_x = $x/$rate;
$final_y = $y/$rate;
if($final_x > $x) {
$final_x = $x;
$final_y = $y;
}
$final_x = ceil($final_x);
$final_y = ceil($final_y);
$black_picture = imageCreatetruecolor($final_x,$final_y);
imagefill($black_picture,0,0,imagecolorallocate($black_picture, 255, 255, 255));
imagecopyresampled($black_picture, $handle, 0, 0, 0, 0,$final_x, $final_y, $x, $y);
if(!@imagejpeg($black_picture,$cwd.'/thumbs/mini_'.$billed, $size_in_pixel)){
imagestring($black_picture, 1, $final_x-4, $final_y-8, ".", imagecolorallocate($black_picture,0,0,0));
imagejpeg($black_picture,'', '80');
imagedestroy($handle);
imagedestroy($black_picture);
}
}
Her leget lidt rundt med de forskellige test. Den kommer ind i
if(!@imagejpeg($black_picture,$cwd.'/thumbs/mini_'.$billed, $size_in_pixel)){
Så går ud fra noget af følgende ikk virker, men aner ikk hvad der så skal ske!
imagestring($black_picture, 1, $final_x-4, $final_y-8, ".", imagecolorallocate($black_picture,0,0,0));
imagejpeg($black_picture,'', '80');
imagedestroy($handle);
imagedestroy($black_picture);
