简体   繁体   English

在没有Image Magick的情况下检查图像类型和压缩

[英]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 different department) and check that they're all uncompressed TIFs. 我需要编写一个脚本来浏览图像文件夹(在不同部门维护的服务器上),并检查它们是否均为未压缩的TIF。 Our local boxes have Image Magick installed, but this server does not. 我们的本地机器已安装Image Magick ,但此服务器未安装。 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. 该服务器的负责人没有帮助(上周我请求外壳程序访问时,他回答说,“这是Windows服务器,所以...否”,好像SSH依赖于平台),因此我需要一个变通办法。

Is there a way to check compression and file type (short of just chopping off the extension) without Image Magick ? 有没有Image Magick的方法来检查压缩和文件类型(不只是切断扩展名)?

Well, yes, but you'd need to access something else than ImageMagick or GD. 是的,但是您需要访问ImageMagick或GD以外的其他内容。 First, make sure that you don't have GD on the server as well, since that too would solve your problems. 首先,请确保服务器上也没有GD,因为那样也可以解决您的问题。

Using GD you'd do: http://php.net/manual/en/function.getimagesize.php 使用GD,您可以: 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. 如果服务器没有GD,则可能需要使用其他Web服务(并将图像发送给它)或使用服务器上安装的其他图像工具执行Shell命令。

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. 您可以读取前X个字节(通常为8个字节)以获取文件的幻数,还可以选择读取头文件以查找TIF信息。 Take a look at TIF's file format specifications. 看一下TIF的文件格式规范。

ps I will provide you with example if necessary. 附言:如有必要,我将为您提供示例。 :) :)

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

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