Compose two smaller images into one larger image
Hi,
I've been using python's PIL (import Image in py2.5) and the command line utility ImageMagick to add text to images and compose images. I can't figure out how to get the composed image not to crop. That is, suppose I compose A onto B to create C. A is short and wide, while B is tall and narrow. I'd like C to be tall and wide, but instead it has the same dimensions as B. Code:
A = [-------] I'm just wondering if there is some way to streamline this. Can ImageMagick do this for me? These operations take a non-trivial amount of time. Thx. |
Code:
convert a.svg b.gif -append c.jpg The only thing is, it is not fast. If you say that these operations take a non trivial amount of time, I assume you mean execution time. When I appended a 1024x70 and a 700x1050 image, I estimate the time at 1-2 seconds on a 1700+ MHz AMD Duron. The culprit seems to be identify: indentiying 1024x70 is instantaneous, identifying the 700x1050 to a noticable amount of time. I think that IM does what you did in 3 statements. jlinkels |
jlinkels, thanks for the reply.
-append is not the option i'm looking for. It literally appends (or stacks) images one after the other: Code:
A = [xx] I'd like to do the equivalent of python's Image.paste, or ImageMagick's convert/compose -draw option: Code:
A = [xx] |
Code:
A = [xx] What if you 1. create an image out of the wide one, but reduce it to 1 pix in height 2. append the narrow one to this one pix image, will cause to stretch the background. 3. Then paste the wide banner on top of the composite what you got It will not be cropped (the image is widened now), and only one pixel higher than it should be. If you are a purist, paste the wide banner with y=+1 offset, and crop the composite image to cut off the 1 pixel high helper image. Does that make sense? jlinkels |
thanks for sticking with this topic, though i have to confess that it's not a big deal. i end up with something kind of like what you suggest, only i simply create an appropriately sized image from the get go, rather than appending (your steps 1 and 2). perhaps appending is much faster?
my biggest problem is actually that photoshop compressed png's get mucked up somehow, and when i past a masked icon on top of the image it comes out noisy. it's as though white is used as the transparency color, even though that part is not supposed to be transparent. works fine on pngs created using open source image programs. photoshop is known for ignoring image formats in favor of proprietary formats, so perhaps that's the problem. perhaps it's the compression. unfortunately, i expect users will use photoshop a bunch. i'm not sure how to test for position failure, though, so it's a sticky situation. the final images have to be les than 800kb, so compression is likely. you can check out the app here: http://whynoti.org |
All times are GMT -5. The time now is 02:01 PM. |