简体   繁体   English

如何更改图像的类型(mime类型)?

[英]How to change a type (mime type) of the image?

When I upload an image to FB, it has image/png type (or image/gif). 当我将图像上传到FB时,它具有图像/ png类型(或图像/ gif)。 But when I download back my uploaded image it has image/jpeg type already. 但是当我下载我上传的图像时,它已经有了image / jpeg类型。 How to change types? 如何改变类型? Is it just enough to save the image with different extension? 是否足以用不同的扩展名保存图像? I'v tried and it works, but is it the right way? 我尝试过它有效,但这是正确的方法吗?

Is it just enough to save the image with different extension? 是否足以用不同的扩展名保存图像?

Only if the file type detection code is broken. 仅在文件类型检测代码被破坏时。 If it only checks the extension then sure, this will fool it. 如果它只检查扩展,那么肯定,这将欺骗它。 If it, you know, actually looks at the file contents then no, this won't help; 如果它,你知道,实际上文件内容然后没有,这将无济于事; you'd have to use something like ImageMagick's convert to transcode the image. 你必须使用像ImageMagick的convert来转码图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM