简体   繁体   中英

Detect image resolution?

I've made some research and couldn't find the answer. Is it possible to detect an image resolution using an upload file field?

Right now, I can detect the size of an image in pixels...But I would need it to find the "inches" size. And I also need to find out the resolution of the image.

Using Javascript would be the best...if possible, if not...PHP maybe?

Thanks!

You'll have to do this once it has been submitted. Check out the getimagesize function in PHP - http://php.net/manual/en/function.getimagesize.php

You will need a browser that supports the FileReader interface - read more at Is it possible to get info from a file on the client side without uploading the file? .

There are some javascript libraries reading such information like EXIF from the file:

  • JsJpegMeta
  • ImageInfo - although I'm not sure whether it gets its binary data by ajax from already uploaded files.

If you want to offer this functionality to user with browsers not supporting this, you will need to upload the file and do it serverside (with PHP).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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