Grey_Wolf Posted January 26, 2005 Report Share Posted January 26, 2005 probleema ir shada- tiek mainiits bildes izmeers (un pat ja netiek mainiits) $image="bildes/a1.jpg"; if (!$max_width) $max_width = 400; if (!$max_height) $max_height = 500; $size = GetImageSize($image); $width = $size[0]; $height = $size[1]; $x_ratio = $max_width / $width; $y_ratio = $max_height / $height; if ( ($width <= $max_width) && ($height <= $max_height) ) { $tn_width = $width; $tn_height = $height; } else if (($x_ratio * $height) < $max_height) { $tn_height = ceil($x_ratio * $height); $tn_width = $max_width; } else { $tn_width = ceil($y_ratio * $width); $tn_height = $max_height; } $src = ImageCreateFromJpeg($image); $dst = ImageCreate($tn_width,$tn_height); ImageCopyResized($dst, $src, 0, 0, 0, 0, $tn_width,$tn_height,$width,$height); header("Content-type: image/jpeg"); ImageJpeg($dst); ImageDestroy($src); ImageDestroy($dst); bildei tiek totaali sajauktas kraasas .... un pat ja netiek izmainiits bildes izmeers vienalga kraasu kods tiek izjaukts - vienalga vai tas ir PNG vai JPG- kur vareetu buut probleema? P.S. izmeers mainaas korekti vieniigi probleema ir ar kraasaam:( Link to comment Share on other sites More sharing options...
Roze Posted January 26, 2005 Report Share Posted January 26, 2005 $dst = ImageCreate($tn_width,$tn_height); nomaini labāk par imagecreatetruecolor() (ši gan nestrādās .gif bilžu gadijumā) Un ImageCopyResized() par imagecopyresampled() šādi bilde tiks noresaizota korektāk, gadijumā ja kāds no lielumiem būtu nekorekti aprēķināts. Link to comment Share on other sites More sharing options...
Grey_Wolf Posted January 26, 2005 Author Report Share Posted January 26, 2005 Liels Paldies :) - mjaa vienkarshak sakot RTF ;) - sajaa gadiijumaa - principaa netiks njemti preti gif - kas taa par bildi 256 kraasaas ;) un ja arii iznaaks tad nav probleemu ielikt IFu kas atskiro Link to comment Share on other sites More sharing options...
Recommended Posts