Python scripting with Paint Shop Pro 8.0

Martin Franklin mfranklin1 at gatwick.westerngeco.slb.com
Thu Jul 24 16:52:51 CEST 2003


On Thursday 24 July 2003 3:14 pm, Marc Wilson wrote:
> In comp.lang.python,  Martin Franklin
> <mfranklin1 at gatwick.westerngeco.slb.com> (Martin Franklin) wrote in
>
> <mailman.1058790515.18332.python-list at python.org>::
> |On Monday 21 July 2003 12:29, Marc Wilson wrote:
> |> In comp.lang.python,  Martin Franklin
> |> <mfranklin1 at gatwick.westerngeco.slb.com> (Martin Franklin) wrote in
> |>

<snip>

> |
> |# PIL IMPORTS
> |import Image, ImageEnhance
> |
> |im = Image.open("gnome-mixer.jpg")
> |
> |enhancer = ImageEnhance.Sharpness(im)
> |eim = enhancer.enhance(2.0)
> |eim.save("gnome-mixer-sharp.jpg", "JPEG")
> |
> |eim.thumbnail((10, 10))
> |eim.save("gnome-mixer-thumb.jpg", "JPEG")
> |
> |
> |And this is the first time I've used PIL.
>
> Wow. I've now knocked up a script that can be called in "batch" mode to
> convert and sharpen the image, and produce a thumbnail from it.
>
> All I need to do now is resize the image (to a fixed width) and we're
> laughing.  I'll press on.
>
> Oh, and- is there a way to overwrite text onto an image?  The site is a
> house-sales site, and we want to overwrite "SOLD" across the thumbnail once
> a property is sold.  It looks like I can do this with the ImageDraw module,
> but I can't see how to replicate what we do now with Image Robot, which is
> to write "SOLD" across the image diagonally (using the Add Watermark
> feature).  Any ideas?
>
>

Marc,

Looks like there could be (at least) two ways to do it...
The ImageDraw class allows you to draw onto an existing image like so:-


im = Image.open("gnome-mixer.jpg")
draw = ImageDraw.Draw(im)
draw.text((5, 5), "SOLD", fill="black") 


I have not investigated how (and if) you can rotate the text - I know you can 
change it's font etc...

The second way would be to paste a SOLD image onto the original image

im = Image.open("gnome-mixer.jpg")
im.paste(Image.open("sold.jpg"), (5, 5))


HTH
Martin






More information about the Python-list mailing list