Autor | Zpráva | ||
---|---|---|---|
German Profil * |
Ahojte pouzivam tuhle funkci na zmnenseny obrazku
<?php function thumb_action($img_src, // obrazek $img_width, // max. velkost x $img_height, // max. velkost y $folder_scr, // Slozka pro originalni obrazky $des_src) // Slozka pro thumbs { // Größe und Typ ermitteln list($src_width, $src_height, $src_typ) = getimagesize($folder_scr."/".$img_src); // neue Größe bestimmen if($src_width >= $src_height) { $new_image_width = $img_width; $new_image_height = $src_height * $img_width / $src_width; } if($src_width < $src_height) { $new_image_height = $img_width; $new_image_width = $src_width * $img_height / $src_height; } if($src_typ == 1) // GIF { $image = imagecreatefromgif($folder_scr."/".$img_src); $new_image = imagecreate($new_image_width, $new_image_height); imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_image_width,$new_image_height, $src_width, $src_height); imagegif($new_image, $des_src."/".$img_src, 100); imagedestroy($image); imagedestroy($new_image); return true; } elseif($src_typ == 2) // JPG { $image = imagecreatefromjpeg($folder_scr."/".$img_src); $new_image = imagecreatetruecolor($new_image_width, $new_image_height); imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_image_width,$new_image_height, $src_width, $src_height); imagejpeg($new_image, $des_src."/".$img_src, 100); imagedestroy($image); imagedestroy($new_image); return true; } elseif($src_typ == 3) // PNG { $image = imagecreatefrompng($folder_scr."/".$img_src); $new_image = imagecreatetruecolor($new_image_width, $new_image_height); imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_image_width,$new_image_height, $src_width, $src_height); imagepng($new_image, $des_src."/".$img_src); imagedestroy($image); imagedestroy($new_image); return true; } else { return false; } } ?> ale kdys dam do img_width = 100, img_height: 50 Tak se mi nekdy udela obrazek 100x75 nekdy zase 100x131 ... a muj problem je v tom ze nevym to udelat tak aby se obrazek zestrihoval porad na 100x50 a nevybiral si co se mu hodi... Moderátor Joker: Změnil jsem titulek „tgumb funktion“ na snad výstižnější a bez chyb.
|
||
Joker Profil |
#2 · Zasláno: 15. 12. 2009, 09:18:19
Příčina:
if($src_width < $src_height) { $new_image_height = $img_width; $new_image_width = $src_width * $img_height / $src_height; } místo width má být height, řekl bych. |
||
German Profil * |
#3 · Zasláno: 15. 12. 2009, 09:45:28
Joker:
ne porad si to dela co chce i kdys sem to premnenil :D |
||
larryx Profil * |
#4 · Zasláno: 15. 12. 2009, 13:28:13
German:
no ja myslim ze to bude v tom ze ten skript pocita tie rozmery v pomere 1:3 skuste dat miesto tohto if($src_width >= $src_height) { $new_image_width = $img_width; $new_image_height = $src_height * $img_width / $src_width; } if($src_width < $src_height) { $new_image_height = $img_width; $new_image_width = $src_width * $img_height / $src_height; } $new_image_width=$img_width; $new_image_height=$img_height; |
||
German Profil * |
#5 · Zasláno: 15. 12. 2009, 14:13:09
larryx:
dekuju ... a jak muzu nastavit to ze fotka nemuze byt mensi nez 550x680 .... ?.... |
||
larryx Profil * |
#6 · Zasláno: 15. 12. 2009, 14:23:45
if(($src_width <=550) or ($src_height <=680)){ print "mala fotka"; // tu si nastavis co sa ma diat ked je mala... } else { ... // tu si nastavis co sa bude diat ked je vsetko ok.... cize kod na zmensenia a prerobenie fotky } |
||
German Profil * |
#7 · Zasláno: 15. 12. 2009, 14:58:56
larryx:
dikec .... |
||
Časová prodleva: 15 let
|
0