4

I'm making an app where the user can upload potentially really large geotiffs. I would like to put client side restrictions on the width and height of the image. I know that it's possible to get the width and height from jpg/png using the Image() object in javascript. But that does not work with geotiffs.

Is there anyway to retrieve the width and height from a geotiff before file upload?

2
  • If he browser can load the image then you can do it the same way for jpg/png. If not you'll have to open up the file and read it to determine the file dimensions. Commented Aug 19, 2013 at 1:08
  • The only way I can think of is sending the first 500 bytes or so to the server, and examining the header data of the TIFF file. It will contain a data tag with the image's dimensions. It's not going to be trivial though en.wikipedia.org/wiki/Tagged_Image_File_Format#Flexible_options Commented Aug 19, 2013 at 1:30

1 Answer 1

1

Take a look at the browser image support table on Wikipedia. As you see, the only mainstream browsers that support TIFF (and therefore can load it into an HTMLImageElement) are Internet Explorer and Safari. If that's your target market, then you should have no problem.

If you have to support Chrome and Firefox, the you have a couple of options:

  1. As Pekka suggested, read the file contents and determine the width and height from the appropriate fields in the TIFF format spec, or

  2. Use a Java or a Flash object to decode the file and extract the information before uploading. Not all browsers have Java or Flash installed, but most probably do.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.