function createThumb($src, $dest, $desired_height) { /* read the source image */ $source_image = imageCreateFromAny($src); $width = imagesx($source_image); $height = imagesy($source_image); /* find the "desired height" of this thumbnail, relative to the desired width */ $desired_width = floor($width * ($desired_height / $height)); /* create a new, "virtual" image */ $virtual_image = imagecreatetruecolor($desired_width, $desired_height); /* copy source image at a resized size */ imagecopyresized($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height); // imageantialias($virtual_image, true); //enose PHP ei toeta seda /* create the physical thumbnail image to its destination */ imagejpeg($virtual_image, $dest); }
$ligne_index = $req->fetch(); $new_index = $ligne_index['max_index'] + 1; $uploadfile = $id_mbc . ' - ' . $ligne_photo['BILLE'] . ' - ' . $ligne_photo['MARQUE'] . ' - ' . $ligne_photo['CONDITIONNEMENT'] . ' - ' . $upload_type . ' - ' . $new_index . '.jpg'; } ecrireLog('APP', 'INFO', 'UPLOAD_ETIQUETTE.PHP| FICHIER CIBLE = ' . $uploaddir . 'HIDEF/' . $uploadfile); if (!move_uploaded_file($_FILES['file']['tmp_name'], $uploaddir . 'HIDEF/' . $uploadfile)) { ecrireLog('APP', 'ERROR', 'UPLOAD_ETIQUETTE.PHP| Problème sur le déplacement du fichier uploadé de ' . $_FILES['file']['tmp_name'] . ' vers ' . $uploaddir . 'HIDEF/' . $uploadfile); exit; } // Calcul des nouvelles dimensions list($width, $height) = getimagesize($uploaddir . 'HIDEF/' . $uploadfile); $newwidth = $width * 60 / $height; $newheight = 60; // Chargement $thumb = imagecreatetruecolor($newwidth, $newheight); $source = imageCreateFromAny($uploaddir . 'HIDEF/' . $uploadfile); // Redimensionnement imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); echo 'cible : ' . $uploaddir . 'THUMBNAIL/' . $uploadfile; imagejpeg($thumb, $uploaddir . 'THUMBNAIL/' . $uploadfile); imagedestroy($thumb); imagedestroy($source); if ($id_photo_sac > 0) { exit; } if ($id_photo_sac <= 0) { $requete = "INSERT INTO photos_sac ( ID_MARQUE_BILLES_CONDITIONNEMENT, NOM_FICHIER, TYPE, DEFINITION, INDEX_PHOTO ) values ( {$id_mbc}, '{$uploadfile}', '{$upload_type}', 'LODEF', {$new_index} )"; ecrireLog('SQL', 'INFO', 'UPLOAD_ETIQUETTE.PHP| REQUETE = ' . $requete); $req = $bdd->prepare($requete); if (!$req->execute()) { ecrireLog('APP', 'ERROR', 'UPLOAD_ETIQUETTE.PHP| Erreur à l\'insertion de l\'enregistrement nouvelle image');