Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

How to merge multiple images into one

Hi,

I'm looking for a way to merge multiple images (jpeg/png) into one.

To get an idea, examples of iPhoen apps that can use this are:

  • watermarking a photo
  • generating an avatar with different portrait components: hair, nose, eyes etc…

Is there a way to do this? Using an external lib like ImageMagick for example?

Regards

— asked April 21st 2010 by Quoc Huy Nguyen Dinh
  • combine
  • images
  • iphone
0 Comments

6 Answers

  • Accepted Answer

    I haven't tested this yet, but I think it should be possible to put the images in a window or view, and then do a toImage() on that. I'd say that would be faster than doing this online.

    — answered April 21st 2010 by Martijn Pannevis
    permalink
    0 Comments
  • Perhaps you could layer the images (assuming they're PNG's) in your app until the user is ready to have them merged, then call an external PHP to do the work?

    I don't know of a JS library could do this, but even if there were it might be expensive to do that from the client since memory and CPU is rather limited on the pre-3GS iPhones. You'd have a bit of a delay while you wait for the upload, merge, and download to be complete, but still may be faster. Plus if you find bugs with the merging you could fix them on the server right away without having to release a patch.

    These links might help:

    http://sniptools.com/vault/using-imagemagick-with-php
    http://pecl.php.net/package/imagick

    — answered April 21st 2010 by Dan Giulvezan
    permalink
    0 Comments
  • Ah, right, toImage. Forgot about that one. Might be worth a shot.

    — answered April 21st 2010 by Dan Giulvezan
    permalink
    0 Comments
  • Thanks guys for your answers.
    Both are making sense.
    @Dan, your solution was the one I had in mind if I couldn't make it in app. The external PHP already exists but using it will make it necessary to have an internet connection in order to use the app.

    So currently the best answer is from Martijn, although I can't test it right now. Thanks for pointing to this function.

    Cheers

    — answered April 23rd 2010 by Quoc Huy Nguyen Dinh
    permalink
    0 Comments
  • Hello

    Anyone has a sample code ?

    Thanks

    — answered July 22nd 2013 by Rene Gade
    permalink
    0 Comments
  • Hello, anyone has an example of this, I do the same but not how.

    Thanks

    — answered June 4th 2014 by Edgar Hernández
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.