Ik heb een probleem. Hieronder zie je de functie die dat probleem veroorzaakt.
Het doel van de functie is dat de upgeloade foto word verkleint naar een soort thumpnail zegmaar, en dat ook de upgeloade foto zelf een stuk verkleind word. Het stomme is, dat het helemaal geweldig werkt met een foto die 'liggend' is, maar op het moment dat daar wat anders komt te staan - zodat de foto dus in staand formaat komt - ik alle mogelijke errors krijg... :S
Wie weet wat ik kan doen? :) Hartelijk dank alvast :)
<?php
Function ImageSize($image){
$source=imagecreatefromjpeg($image);
$size["y"]=imagesy($source);
$size["x"]=imagesx($source);
imagedestroy($source);
return $size;
}
Function MakeSmallAndRotated($image,$naam,$manier="liggend"){ // manier is voor liggend of staand
global $rootdir;
if($manier=="liggend"){
$w=120;
$h=80;
}
else{
$w=80;
$h=120;
}
$rotate=rand(0,3);
if($rotate==0)
$rotate=30;
elseif($rotate==1)
$rotate=0-30;
elseif($rotate==2)
$rotate=15;
else
$rotate=0-15;
// kleine afbeelding maken.
$img=imagecreatetruecolor($w,$h+20);
$source=imagecreatefromjpeg($image);
$white=imagecolorallocate($img,255,255,255);
$black=imagecolorallocate($img,0,0,0);
imagefill($img,0,0,$white);
imagecopyresized($img,$source,0,0,0,0,$w,$h,imagesx($source),imagesy($source));
imagestring($img,5,5,$h+3,$naam,$black);
$img=imagerotate($img,$rotate,$white);
imagejpeg($img,$rootdir . "uploads/small_".$naam.".jpg",100);
imagedestroy($img);
// ook nog even grote afbeelding verkleinen
$size=ImageSize($image);
if($size["x"]>=300){
if($manier=="liggend"){
$h=240;
$w=320;
}
else{
$h=400;
$w=300;
}
$BigImg=imagecreatetruecolor($w,$h);
imagecopyresized($BigImg,$source,0,0,0,0,$w,$h,imagesx($source),imagesy($source));
imagestring($BigImg,2,2,2,"Copyright 2005",$white);
imagejpeg($BigImg,$rootdir . "uploads/" . $naam . ".jpg",100);
imagedestroy($BigImg);
imagedestroy($source);
}
}
?>en de errors:
Warning: imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error: in c:\www\dansschool\admin\fotoalbum.func.php on line 37
Warning: imagecreatefromjpeg(): '../uploads/glkglgh.jpg' is not a valid JPEG file in c:\www\dansschool\admin\fotoalbum.func.php on line 37
Warning: imagesx(): supplied argument is not a valid Image resource in c:\www\dansschool\admin\fotoalbum.func.php on line 42
Warning: imagesy(): supplied argument is not a valid Image resource in c:\www\dansschool\admin\fotoalbum.func.php on line 42
Warning: imagecopyresized(): supplied argument is not a valid Image resource in c:\www\dansschool\admin\fotoalbum.func.php on line 42
Warning: imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error: in c:\www\dansschool\admin\fotoalbum.func.php on line 4
Warning: imagecreatefromjpeg(): '../uploads/glkglgh.jpg' is not a valid JPEG file in c:\www\dansschool\admin\fotoalbum.func.php on line 4
Warning: imagesy(): supplied argument is not a valid Image resource in c:\www\dansschool\admin\fotoalbum.func.php on line 5
Warning: imagesx(): supplied argument is not a valid Image resource in c:\www\dansschool\admin\fotoalbum.func.php on line 6
Warning: imagedestroy(): supplied argument is not a valid Image resource in c:\www\dansschool\admin\fotoalbum.func.php on line 7