php gd 脚本无法正确输出图片
此代码按预期保存图像,但不是将其显示为图片,而是显示图片内的一行文本。帮助?
<?php
imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $opacity);
// print image to screen
header("content-type: image/jpeg");
imagejpeg($image, "modified-images/".$codigo2."_modified_picture_status_".$status.".jpg");
imagedestroy($image);
imagedestroy($watermark);
?>
This Code saves the image like it's suppose to, but instead of displaying it as a picture, what is displayed is a line of text inside the picture. help?
<?php
imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $opacity);
// print image to screen
header("content-type: image/jpeg");
imagejpeg($image, "modified-images/".$codigo2."_modified_picture_status_".$status.".jpg");
imagedestroy($image);
imagedestroy($watermark);
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您使用 imagejpeg 的第二个参数,图像将不会输出到浏览器,而仅保存到文件中。
如果不需要将其另存为文件,请尝试省略第二个参数,并且它应该直接输出到浏览器。
如果您想同时执行这两项操作,请在当前代码块之后尝试
print(file_get_contents($imagepath))
。$imagepath
显然应该包含您将图像写入的路径。If you are using the second parameter of imagejpeg, the image will not be outputted to the browser but ONLY saved to the file.
Try omitting the second parameter if you don't need to save it as a file, and it should output directly to the browser.
If you want to do both, try a
print(file_get_contents($imagepath))
after your current block of code.$imagepath
should obviously contain the path that you wrote the image to.制作两条线:
make two lines: