从PHP / GD资源获取图像mimetype? [英] Get image mimetype from resource in PHP/GD?
问题描述
我试图找到图像的MIME类型。 PHP有函数 我找到了函数 注意:由于设置了一个奇怪的服务器,我们无法读取/写入文件服务器通常只能通过一个FTP层(这是我从中读取图像数据的地方)。 我知道这是很老,但为了防止有人像我这样做过这个帖子...... 更好的选项是从PHP 5.4.0发布的: 这个新功能与getimagesize完全一样,但允许您从流中获取信息。 I'm trying to find the mime type of an image. PHP has the function I found the functions Note: Due to a weird server set up, we can't read/write files from the server normally, only through an FTP layer (which is where I read the image data from). I know this is pretty old, but just in case someone come across this post like I did... A better option it's been released from PHP 5.4.0:
getimagesizefromstring This new function is exactly the same of getimagesize but allows you to retreive the information from a stream. 这篇关于从PHP / GD资源获取图像mimetype?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! getimagesize
,但只需要一个文件名,而我有一个图像资源,而不是 - 即从 imagecreatefromstring $创建的图像c code
$ b imagesx
和 imagesy
它从资源返回宽度/高度,但我找不到任何函数告诉我来自资源的MIME类型。任何人都知道如何做到这一点?
< a href =http://www.php.net/manual/en/function.getimagesizefromstring.php =noreferrer> getimagesizefromstring
getimagesize
but that only takes a filename, whereas I have an image "resource" instead - i.e. an image created from imagecreatefromstring
.imagesx
and imagesy
which return the width/height from a resource but I can't find any function that tell me the mime type from a resource. Anyone know of a way to do this?