PDA

View Full Version : converting multiple jpg's into one tiff programmatically




patrover
Oct 13, 2009, 03:26 PM
converting multiple jpg's into one tiff programmatically.
is there a way to do it?



PhoneyDeveloper
Oct 13, 2009, 04:05 PM
Pretty sure there's no support for tiff AT ALL on iPhone OS. So the only options would be third party code like libtiff or something server-side.

Is your goal a kind of mosaic of the jpegs or some kind of layered image?

patrover
Oct 13, 2009, 04:22 PM
http://developer.apple.com/iphone/library/documentation/uikit/reference/UIImage_Class/Reference/Reference.html says tiff is supported.

i have multiple pages in jpg files and i want to make all the pages in one tiff file, no mosaic, simply one after another.

PhoneyDeveloper
Oct 13, 2009, 09:31 PM
That's what I meant by mosaic, a checkerboard, you want to make a single tiff image by laying out a bunch of jpegs next to one another.

At any rate, see this

https://devforums.apple.com/message/131913

The link you mention will allow you to display a tiff but not create one. You could create a jpeg or png or maybe a pdf, with memory being the major limitation.

dejo
Oct 13, 2009, 09:48 PM
Why does it need to be tiff? Is there a specific reason for that as the end result? Or would you be okay with just some kind of image containing the jpgs side-by-side?

patrover
Oct 14, 2009, 07:24 AM
it could be any format that can contain multiple pages

patrover
Oct 14, 2009, 07:25 AM
That's what I meant by mosaic, a checkerboard, you want to make a single tiff image by laying out a bunch of jpegs next to one another.

At any rate, see this

https://devforums.apple.com/message/131913

The link you mention will allow you to display a tiff but not create one. You could create a jpeg or png or maybe a pdf, with memory being the major limitation.

i think the link is broken

dejo
Oct 14, 2009, 11:06 AM
i think the link is broken
Works fine for me.

PhoneyDeveloper
Oct 14, 2009, 12:22 PM
You could build jpegs or pngs or pdfs with the apis present in iPhone OS and could build tiffs if you incorporate libtiff.

jpegs and pngs would use the same procedure. These formats don't have a concept of a page per se but you could build a long image composed of multiple images.

To do this you would create a bitmap context large enough to hold the final image. Then you draw each of the smaller images into the bitmap context. Then get a CGImage from the bitmap context and a UIImage from the CGImage. Then use UIImagePNGRepresentation or UIImageJPEGRepresentation to get the data from the image and write it to a file or send it over the wire someplace.

The main issue with this process would be that it could use a lot of memory. The code would be straightforward.

There are classes for reading and writing PDF files. I haven't used them but I'm sure they work fine. If you're trying to create some kind of document this is probably the way to go. I assume that you could add text for headers and footers on each page. Memory would also be a problem with this method I would guess. Also, when you put bitmap images into a pdf once the user enlarges the document past a certain magnification the image gets the jaggies. You'd have to work with that issue to get a document that you like.

If you want to generate tiffs then you need to incorporate libtiff in your app and use its apis, which I'm not familiar with anymore. I bet it would work.