本文介绍了在 PHP 中将 JPG/GIF 图像转换为 PNG?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!
问题描述
可能重复
将jpg图像转换为gif、png &使用PHP的bmp格式
我有一个 PHP 表单,它允许上传图片并检查 exif_imagetype(); 以确保图片有效.
I have a PHP form that allows image uploads and checks exif_imagetype(); to make sure an image is valid.
但是,我希望所有格式(PNG、JPG、JPEG 和 GIF)在提交后最终都是 PNG.
However, I want all formats, PNG, JPG, JPEG, and GIF, to end up being PNG once submitted.
我该怎么做?
推荐答案
你只需要imagepng() 那么.事实上,它几乎变成了一条线:
You just need imagepng() then. In fact it almost becomes a one-liner:
imagepng(imagecreatefromstring(file_get_contents($filename)), "output.png");
您将使用 $_FILES["id"]["tmp_name"] 作为文件名,并且显然使用不同的输出文件名.但是图像格式探测本身就会变得多余.
You would use $_FILES["id"]["tmp_name"] for the filename, and a different output filename obviously. But the image format probing itself would become redundant.
这篇关于在 PHP 中将 JPG/GIF 图像转换为 PNG?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!
The End



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)