Bonjour à toutes et à tous,

J'essaye de créer un module d'upload d'image sur mon site.
Après avoir choisi le fichier quel qu'il soit, j'ai ce message d'erreur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions
Pourtant, j'ai vérifié et bien défini mes dimensions partout...
D'où cela peut-il venir ?
Voici le code de ma fonction au cas où (que j'ai trouvé je ne sais où à l'origine d'ailleurs...)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
	function create_thumbnail($source,$destination,$thumb_width) {
		$size = getimagesize($source);
		$width = $size[0];
		$height = $size[1];
		$x = 0;
		$y = 0;
		if($width> $height) {
			$x = ceil(($width - $height) / 2);
			$width = $height;
		} elseif($height> $width) {
			$y = ceil(($height - $width) / 2);
			$height = $width;
		}
		$new_image = imagecreatetruecolor($thumb_width,$thumb_width)
							or die('Cannot Initialize new GD image stream');
		$extension = get_image_extension($source);
			if($extension=='jpg' || $extension=='jpeg')
				$image = imagecreatefromjpeg($source);
			if($extension=='gif')
				$image = imagecreatefromgif($source);
			if($extension=='png')
				$image = imagecreatefrompng($source);
 
		imagecopyresampled($new_image,$image,0,0,$x,$y,$thumb_width,$thumb_width,$width,$height);
		if($extension=='jpg' || $extension=='jpeg')
			imagejpeg($new_image,$destination);
		if($extension=='gif')
			imagegif($new_image,$destination);
		if($extension=='png')
			imagepng($new_image,$destination);
	}
Merci!