Get image mimetype from resource in PHP/GD?
ftp, gd, image, php
Solution
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.
Problem
I'm trying to find the mime type of an image. PHP has the function `getimagesize` but that only takes a filename, whereas I have an image "resource" instead - i.e. an image created from `imagecreatefromstring`. I found the functions `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? 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).