Image concatenation in PIL

S

skip

Looking through the PIL docs I didn't see any obvious (one-line) way of
concatenating two images. Given im1 and im2 which I wish to concatenate
left-to-right, is this the simplest I can do?

def imconcat(im1, im2):
# concatenate im1 and im2 left-to-right
h1, w1 = im1.size
h2, w2 = im2.size
im3 = PIL.Image.new("RGB", (max(h1, h2), w1+w2))
im3.paste(im1)
im3.paste(im2, (0, w1, h2, w2))
return im3

I was hoping for something almost as simple as the netpbm command

pnmcat -lr im1 im2

Thx,

Skip
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top