[GD] imagecreatefromjpeg & getimagesize
voilà : j'ai
Code:
1 2 3 4 5 6 7 8 9 10 11
| <?php
function getVignette($id) {
$id = intval($id);
$file = "photo.php?id=$id";
$image = imagecreatefromjpeg($file);
$details = getimagesize($file);
$s = ($details[0]>$details[1])?'width="100"':'height="100"';
$s = '<img src="photo.php?id='.$id.'" '.$s.'>';
return $s;
}
?> |
et voici : photo.php
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| <?php
if (isset($_GET['id'])) {
$id = intval($_GET['id']);
include("connexion.php");
$req = "SELECT photo_blob, photo_type FROM produits WHERE id = ".$id;
$ret = mysql_query($req) or die (mysql_error());
$col = mysql_fetch_row($ret);
if (!$col[0]) {
echo "Id d'image inconnu";
} else {
header("Content-type: ".$col[1]);
echo $col[0];
}
} else {
echo "Mauvais Id d'image";
}
?> |
et j'a le message :
Citation:
Warning: imagecreatefromjpeg(photo.php?id=13): failed to open stream: No such file or directory in includes/functions.inc.php on line 4
Warning: getimagesize(photo.php?id=13): failed to open stream: No such file or directory in includes/functions.inc.php on line 5
Ce que je veux faire : récupérer la taille de l'image en BD et la faire tenir dans un carré de 100*100 grâce aux redimenssionements de la balise html <img>