Parsing a TIFF file

I hope I picked the right place to post this. If not, please advise and I’ll post on the appropriate forum.

I am trying to retrieve tiff files from a .gov site and parse them using PHP. The site in question lets me view the tiff with the AlternaTiff plugin, which offers me tabs so I can jump to different sections within the tiff document. The site allows me to download the tiffs and do whatever I want with them, since they are public domain.

Is this section information built into the tiff file? I couldn’t tell much from the tiff documentation I tried to wade through. I would love to be able to parse those tiff files into their sections and store each section in a different file. Is this possible with PHP and perhaps ImageMagick?

Thanks so much for any guidance!

If ImageMagick supports Tiff then yes, you would need to get the full file via cURL and send it to PHP. (Unless tiff’s are multi page, are they?)

To be honest, it would require a lot of memory and probably isn’t best suited to PHP, over a more low level programming language - but if it’s required to be automated for a web app then it may just have to be!

Thanks very much for the reply. The Tiffs are multi-page. I want to deploy my solution on my website and PHP is the only way I know to do it.

I suppose I could implement some sort of cgi solution, but I’m not even sure where I’d start with that since it’s been so long since I’ve done anything along those lines.

Start from the TIFF specification.

For the PHP side, you don’t need any CGI. you can use system() function from your PHP scripts to run command line utilities.
In this case you only have to find command line utility that can dig that info from the TIFF file.

Hint: web-programming forum isn’t the best place to search :wink:

I mentioned cgi as an alternative to PHP, not in addition to it. Cgi would handle the memory requirements better. In any case, I’ll have to investigate some other technologies before proceeding. Thanks very much for the assistance.

Reading a few bytes from a file will never require much memory.
Anyway there is no difference in handling memory requirements. And PHP cannot be compared to CGI, because PHP is language and CGI is protocol.

Oh, yes, right you are! I really meant that I could try to do it in a lower level language so it would be faster (I have to do more stuff with the images), and then access that via cgi from cgibin. How careless of me :slight_smile:

You don’t need to reinvent the wheel with low level languages
Imagemagick you mentioned is a swiss knife for command line graphics manipulation.
I’d give it try before anything else