English 中文(简体)
公共卫生和植物
原标题:PHP created watermark looks strange

I have script that add water mark (PNG, transparent) to image(JPG). Works fine with a catch - in some way water mark changes colors and makes it NOT transparent. This is code i use for adding water mark:

$im = imagecreatefromjpeg( ../../pics/ .$ran. _large.jpg );
$stamp = imagecreatefrompng( a.png );

$marge_right = 10;
$marge_bottom = 10;
$sx = imagesx($stamp);
$sy = imagesy($stamp);

imagecopymerge($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp), 70);

// Save the image to file and free memory
imagejpeg($im,  ../../pics/ .$ran. _large.jpg );
imagedestroy($im);

http://i39.tinypic.com/20iuwk7.jpg”rel=“nofollow> 带水面的图像在PHP生成(重)

最佳回答

thank you for help guys - I found answer in this site

$im = imagecreatefromjpeg( ../../pics/ .$ran. _large.jpg );
$stamp = imagecreatefrompng( a.png );

imagealphablending($im, true);

$marge_right = 10;
$marge_bottom = 10;

$sx = imagesx($stamp);
$sy = imagesy($stamp);

$offset = 10;

imagecopy($im, $stamp, imagesx($im) - imagesx($stamp) - $offset, imagesy($im) - imagesy($stamp) - $offset, 0, 0, imagesx($stamp), imagesy($stamp));
// Save the image to file and free memory
imagejpeg($im,  ../../pics/ .$ran. _large.jpg );
imagedestroy($im);
问题回答

你的产出形象格式是 j。 Jpeg并不支持实际情况。 将产出格式改为png。

还建议你使用图像魔鬼。 Gd非常原始。

• 在从巴布亚新几内亚制作的甲型六氯环己烷地图之后,不要忘记这些功能:

imagealphablending($stamp,false);
imagesavealpha($stamp,true);

参看这是否有什么区别?





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签