Checking image type and compression without Image Magick
I'm in a bit of a bind.
I need to write a script that goes through a folder of images (on a server maintained by a dif开发者_运维百科ferent department) and check that they're all uncompressed TIFs. Our local boxes have Image Magick installed, but this server does not. The person in charge of this server is no help (when I requested shell access last week, he replied, "It's a Windows server so...no" as if SSH is platform-dependent) so I need a work-around.
Is there a way to check compression and file type (short of just chopping off the extension) without Image Magick?
Well, yes, but you'd need to access something else than ImageMagick or GD. First, make sure that you don't have GD on the server as well, since that too would solve your problems.
Using GD you'd do: http://php.net/manual/en/function.getimagesize.php
If the server hasn't got GD either you'd probably need to either use some other web service (and send the image to it) or execute a shell command, using some other image tool installed on the server.
You can read the first X bytes (usually 8) to get the magic number of the file and optionally you can read the header files, looking for TIFs information. Take a look at TIF's file format specifications.
p.s. I will provide you with example if necessary. :)
精彩评论