ray Posted April 17, 2008 Report Share Posted April 17, 2008 (edited) Man ir png bilde, kurā ir caurumi, mēģinu ar gd uzlikt to bildi pa virsu, bet tajos caurumos nerāda apakšējo attēlu, kur kodā varētu būt kļūda? $jpg = "1.jpg"; $png = "2.png"; $dest_x = 0; $dest_y = 0; $watermark = imagecreatefrompng($png); $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); $image = imagecreatetruecolor($watermark_width, $watermark_height); $image = imagecreatefromjpeg($jpg); $size = getimagesize($jpg); imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100); imagepng($image, "jaunais_fails.jpg"); imagedestroy($image); imagedestroy($watermark); echo "<img src=\"jaunais_fails.jpg\">"; Edited April 17, 2008 by ray Link to comment Share on other sites More sharing options...
Aleksejs Posted April 17, 2008 Report Share Posted April 17, 2008 Nav alfa kanāls nodefinēts skriptā: http://lv.php.net/manual/en/function.imagealphablending.php Link to comment Share on other sites More sharing options...
ray Posted April 17, 2008 Author Report Share Posted April 17, 2008 (edited) Paldies! Edited April 17, 2008 by ray Link to comment Share on other sites More sharing options...
Rich Bitch Posted April 17, 2008 Report Share Posted April 17, 2008 ko lai pamaina shajaa kodaa, lai bilde izveidotos tik liela cik ir watermark, nevis jpg? Link to comment Share on other sites More sharing options...
andrisp Posted April 17, 2008 Report Share Posted April 17, 2008 http://lv.php.net/manual/en/function.imagecopyresized.php Link to comment Share on other sites More sharing options...
Rich Bitch Posted April 18, 2008 Report Share Posted April 18, 2008 (edited) Paarveidoju kodu, bet tik un taa taa bilde ir tik liela cik $jpg, nevis $png, kur varētu būt kļūda? $jpg = "1.jpg"; // izmeers 160x102 $png = "2.png"; //izmeers 208x120 $dest_x = 0; $dest_y = 0; $watermark = imagecreatefrompng($png); $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); $image = imagecreatetruecolor($watermark_width, $watermark_height); $image = imagecreatefromjpeg($jpg); ImageAlphaBlending($image, true); imagecopyresized($image, $watermark, $dest_x, $dest_y, 0, 0, 208, 120, $watermark_width, $watermark_height); imagepng($image, "jaunais_fails.png"); imagedestroy($image); imagedestroy($watermark); echo "<img src=\"jaunais_fails.png\">"; Edited April 18, 2008 by Rich Bitch Link to comment Share on other sites More sharing options...
Kaklz Posted April 21, 2008 Report Share Posted April 21, 2008 Triks slēpjas faktā, ka tu itkā izveido watermark lieluma bildi, bet tūlīt pēc tam to pārdefinē par jpg izmēriem atbilstošo bildi, izveidojot jaunu bildes resursu pa taisno no jpg faila: $image = imagecreatetruecolor($watermark_width, $watermark_height); $image = imagecreatefromjpeg($jpg); Attiecīgi arī tu uzreiz pazaudē gala rezultāta bildes izmērus. Vienkāršākais variants būtu nosaukt savādāk $image mainīgo, kurā tu iebāz to jpg bildi un pēc tam to jpg bildi uzkopēt uz $image, aptuveni šādi (nepārbaudīju, tāpēc skaties vai nav kļūdas pats) $image = imagecreatetruecolor($watermark_width, $watermark_height); $image2 = imagecreatefromjpeg($jpg); imagecopyresampled($image, $image2, 0, 0, 0,0,$watermark_width, $watermark_height, 160, 102); un tālāk jau aiziet tas tavs paša kods: ImageAlphaBlending($image, true); //.... Link to comment Share on other sites More sharing options...
Recommended Posts