1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

converting multiple jpg's into one tiff programmatically

Discussion in 'iPhone/iPad Programming' started by patrover, Oct 13, 2009.

  1. macrumors newbie

    converting multiple jpg's into one tiff programmatically.
    is there a way to do it?
  2. macrumors 68030


    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?
  3. macrumors newbie

  4. macrumors 68030


    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


    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.
  5. Moderator


    Staff Member

    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?
  6. macrumors newbie

    it could be any format that can contain multiple pages
  7. macrumors newbie

    i think the link is broken
  8. Moderator


    Staff Member

    Works fine for me.
  9. macrumors 68030


    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.

Share This Page