Autor Zpráva
Tom344
Profil *
Cau lidi,

nepouzivate nekdo nejakou peknou tridu pro tvorbu nahledu ?

Jde mi hlavne o vyplnovani pozadi urcitou barvou, pokud je obrazek menzi jako zadany rozmer.

Presneji pokud ma zmensovany obrazek jiny pomer stran jako velikost nahledu, bude po zmenseni zdeformovany. Pak je vhodne ten obrazek zmensit na nejblizsi rozmer (w nebo h) a zbyly druhy "mensi" rozmer doplnit zadanym pozadim do dane velikosti.
igamenir
Profil
Zrovna včera jsem to udělat. Ale s třídami zatím nedělam, tak je to funkce:
function Thumbnail($filename, $folder, $thumb_folder, $size, $background) {

$dim = getimagesize($folder.$filename);
$width = $dim[0];
$height = $dim[1];
if ($width > $height):
$newleft = 0;
$newwidth = $size;
$newheight = ($size * $height) / $width;
$newtop = ($size - $newheight) / 2;
else:
$newtop = 0;
$newheight = $size;
$newwidth = ($size * $width) / $height;
$newleft = ($size - $newwidth) / 2;
endif;
$image = imagecreatefromjpeg($folder.$filename);
$thumb = imagecreatetruecolor($size, $size);
imagefilledrectangle($thumb, 0, 0, $size, $size, $background);
imagecopyresampled($thumb, $image, $newleft, $newtop, 0, 0, $newwidth, $newheight, $width, $height);
imagejpeg($thumb, $thumb_folder.'th'.$filename);
return $thumb_folder.'th'.$filename;
}
kaifman
Profil
ja pouzivam neco kratsiho :)

exec("convert -thumbnail 150x100 obrazek.jpg nahledObrazku.jpg");
Toto téma je uzamčeno. Odpověď nelze zaslat.

0