ok grazie !! ..
io poi nel mentre avevo risolto con questa funzione che ora vi scrivo. solo che mi crea la thumb solo se l'imm. è jpeg.. se gli passo un bmp non va! ..forse devo usare "convert" prima ?
in questo caso, visto che in php sono a 0 mi potete dire come posso inserire correttamente la funzione ?
io avevo fatto così :
Codice PHP:
$thumb = createThumbnail2($img, "thumb_", $imgPath, "-thumb", 160, 140, 100);
Codice PHP:
function createThumbnail2($img, $prefix, $imgPath, $suffix, $newWidth, $newHeight, $quality) { // Open the original image. $original = imagecreatefromjpeg("$imgPath/$img") or die("Error Opening original"); list($width_orig, $height_orig, $type, $attr) = getimagesize("$imgPath/$img"); $ratio_orig = $width/$height; $ratio_orig = $width_orig/$height_orig; if ($newWidth/$newHeight > $ratio_orig) { $newWidth = $newHeight*$ratio_orig; } else { $newHeight = $newWidth/$ratio_orig; } // Resample the image. $tempImg = imagecreatetruecolor($newWidth, $newHeight) or die("Cant create temp image"); imagecopyresized($tempImg, $original, 0, 0, 0, 0, $newWidth, $newHeight, $width_orig, $height_orig) or die("Cant resize copy"); // Create the new file name. $newNameE = explode(".", $img); $newName = $newNameE[0] . $suffix . ‘.’ . $newNameE[1]; // Save the image. imagejpeg($tempImg, "$imgPath/".$prefix.$img, $quality) or die("Cant save image"); // Clean up. imagedestroy($original); imagedestroy($tempImg); return true; }