PHP GD图像损坏在imagecopy()
我在使用PHP 5.3.3时遇到了一些奇怪的问题,我正在尝试为图像添加水印。
$body = @imagecreatefromstring($image_data['body']);
imagejpeg($body, null, 85);
返回:http://i.stack.imgur.com/KJjDi.jpg
$body = @imagecreatefromstring($image_data['body']);
$logo = @imagecreatefrompng(APP_ROOT . self::WATERMARK_PATH);
$body_width = (int) @imagesx($body);
$body_height = (int) @imagesy($body);
$logo_width = (int) @imagesx($logo);
$logo_height = (int) @imagesy($logo);
$image = imagecreatetruecolor($body_width + 4, $body_height + $logo_height);
imagecopy(
$image, $logo,
intval($body_width / 2) - ceil($logo_width / 2), $body_height,
0, 0, $logo_width, $logo_height
);
imagejpeg($image, null, 85);
返回:http://i.stack.imgur.com/nwtqZ.jpg
buuuuuuuuut ......如果我将身体(猫)添加到图像中......
$body = @imagecreatefromstring($image_data['body']);
$logo = @imagecreatefrompng(APP_ROOT . self::WATERMARK_PATH);
$body_width = (int) @imagesx($body);
$body_height = (int) @imagesy($body);
$logo_width = (int) @imagesx($logo);
$logo_height = (int) @imagesy($logo);
$image = imagecreatetruecolor($body_width + 4, $body_height + $logo_height);
imagecopy(
$image, $body,
1, 1,
0, 0, $body_width, $body_height
);
imagecopy(
$image, $logo,
intval($body_width / 2) - ceil($logo_width / 2), $body_height,
0, 0, $logo_width, $logo_height
);
imagejpeg($image, null, 85);
结果:http://i.stack.imgur.com/Xeb73.jpg
正如你在最后一个中看到的那样,图像的底部是腐败的还是......发生了什么?
没有找到相关结果
已邀请:
1 个回复
降女陷费券
我要说它与实际图像有关: - ?