Am scriptul de mai jos care adauga o sigla in imagine, si sub el ce am incercat sa il editez pentru a adauga si posibilitatea de a adauga si un text dar imi da eroare.
Cod: Selectaţi tot
<?php
$main_img = "http://sphotos-h.ak.fbcdn.net/hphotos-ak-ash4/429020_466465880056408_618248483_n.jpg"; // imagine fundal
$watermark_img = "https://lh5.googleusercontent.com/-tPLXra2s3bA/UL77G3f_F8I/AAAAAAAAAKE/BcnaS6yZKvc/s487/RenderedImage.png"; // sigla format png
$padding = 1; // neimportant
$opacity = 100; //opacitatea
$watermark = imagecreatefrompng($watermark_img); // creeaza logo-ul
$image = imagecreatefromjpeg($main_img); // creaza imaginea
if(!$image || !$watermark) die("Neah ceva nu merge ...");
$watermark_size = getimagesize($watermark_img);
$watermark_width = $watermark_size[0];
$watermark_height = $watermark_size[1];
//setari de pozitionare a siglei
$image_size = getimagesize($main_img);
$dest_x = $image_size[0] - $watermark_width - $padding;
$dest_y = "40";
// procesarea imaginii final
imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $opacity);
// returneaza imaginea procesata
header("content-type: image/jpeg");
imagejpeg($image);
// goleste memoria.
imagedestroy($image);
imagedestroy($watermark);
?>
Cod: Selectaţi tot
<?php
$main_img = "http://sphotos-h.ak.fbcdn.net/hphotos-ak-ash4/429020_466465880056408_618248483_n.jpg"; // imagine fundal
$watermark_img = "https://lh5.googleusercontent.com/-tPLXra2s3bA/UL77G3f_F8I/AAAAAAAAAKE/BcnaS6yZKvc/s487/RenderedImage.png"; // sigla format png
$text = "acesta este un DEMO"; // text
$padding = 1; // neimportant
$opacity = 100; //opacitatea
$watermark = imagecreatefrompng($watermark_img); // creeaza logo-ul
$image = imagecreatefromjpeg($main_img); // creaza imaginea
$textwh = @imagecreate(110, 20) ; //propietati text
$text_color = imagecolorallocate($textwh, 233, 14, 91); // culoare text
if(!$image || !$watermark) die("Neah ceva nu merge ...");
$watermark_size = getimagesize($watermark_img);
$watermark_width = $watermark_size[0];
$watermark_height = $watermark_size[1];
//setari de pozitionare a siglei
$image_size = getimagesize($main_img);
$dest_x = $image_size[0] - $watermark_width - $padding;
$dest_y = "40";
// procesarea imaginii final
imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $opacity,$textwh, 1, 5, 5, $text, $text_color);
// returneaza imaginea procesata
header("content-type: image/jpeg");
imagejpeg($image);
// goleste memoria.
imagedestroy($image);
imagedestroy($watermark);
imagedestroy($textwh);
?>
Cod: Selectaţi tot
Warning: Wrong parameter count for imagecopymerge() in /home/desehixc/public_html/app/test/poza.php on line 27
Warning: Cannot modify header information - headers already sent by (output started at ..../poza.php:27) in ..../poza.php on line 31