使用PHP查找JPEG分辨率 [英] Find JPEG resolution with PHP

查看:189
本文介绍了使用PHP查找JPEG分辨率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

调用所有PHP专家!

我知道您可以使用getimagesize()来获取PHP中图像的实际像素高度和宽度。但是,如果您在Photoshop中打开图像并查看图像大小对话框,您会注意到有一个分辨率值决定了图像的打印尺寸。

I understand that you can use getimagesize() to get the actual pixel height and width of an image in PHP. However, if you open an image in photoshop and look at the image size dialog, you notice that there is a resolution value that determines the print size of the image.

给定一个任意的jpg图像文件,我需要用PHP来确定这个分辨率。看来这个信息存储在某个地方的jpg文件中,所以我该怎么做呢?

Given an arbitrary jpg image file, I need to use PHP to determine this resolution number. It appears that this information is stored in the jpg file somewhere, so how do I get to it?

另一个要求 - 我只有gdlib可供我使用。我需要在不使用其他php库的情况下执行此操作(imagemagick等)。

One other requirement - I only have gdlib available to me. I need to do this without the use of other php libraries (imagemagick, etc.)

感谢您的帮助!

推荐答案

您可以直接读取JPEG文件,字节14-18指定:

You could just read the JPEG file directly, bytes 14-18 specify:


  • 字节14:01,X和Y密度单位指定符(00:无,像素比率,01:DPI,02:DPC)

  • 字节15-16:水平像素密度,

  • 字节16-18:垂直像素密度

另见: http://www.obrador.com/essentialjpeg/headerinfo.htm

这篇关于使用PHP查找JPEG分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆