0

How can I put some small transparent image over an old image with PIL?

the new transparent one should sit in the middle like this:

enter image description here

the arrow circle would be what i want to put on the image.

how can I do this with PIL? i googled a bit, most solution are about drawing and not putting image over image

doniyor
  • 36,596
  • 57
  • 175
  • 260
  • @fredtantini it is all about drawing and stuff there, isnot it? – doniyor Oct 21 '14 at 10:41
  • in the first answer, there is an example where the 2 images are drawn, but the result doesn't take this information into account `img3 = alpha_composite(img1, img2)`. In the other answers, there are no mention either of drawing. – fredtantini Oct 21 '14 at 10:48
  • @fredtantini ok, seems i can find build a solution from there.. merci :) – doniyor Oct 21 '14 at 10:50

1 Answers1

1

What you want is something like putting a watermark on the picture. You can use this image utility I've written before.

from ImageUtilis import ImageUtilis

iu = ImageUtilis()

image_address = "image1.jpg"
mark_address = "watermake.png"  # transparent or whatever

iu.watermark(image_address, mark_address, 'tile', 0.5)
iu.watermark(image_address, mark_address, 'scale', 1.0)
iu.watermark(image_address, mark_address, (100, 100), 0.5) # (100,100) is position x,y
hamidfzm
  • 4,595
  • 8
  • 48
  • 80
  • when do I save the file? do I have to save the file? – doniyor Oct 21 '14 at 11:33
  • look at the source code at line 130 I overwrite `image_address` but you can change this line `self.make_watermark(im, mark, *args, **kwargs).save(image_address)` to `self.make_watermark(im, mark, *args, **kwargs).save('where/you/want/to/save/)` – hamidfzm Oct 21 '14 at 11:41
  • Thanks. can you please take a look at my prev question? http://stackoverflow.com/questions/26484411/python-resize-image-without-losing-sharpness – doniyor Oct 21 '14 at 11:49