Python scripting with Paint Shop Pro 8.0

Martin Franklin mfranklin1 at gatwick.westerngeco.slb.com
Mon Jul 21 08:23:06 EDT 2003


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
>
> <mailman.1058775152.5377.python-list at python.org>::
> |On Sunday 20 July 2003 13:48, Marc Wilson wrote:
> |> Hi,
> |>
> |> I'm a complete Python newbie, though I know at least one regular in
> |> here.
> |>
> |> :)
> |>
> |> I've just got Paint Shop Pro 8.0, and the functionality of the old
> |> ImageRobot add-on has been replaced with the new Python Scripting.
> |>
> |> So far, OK.
> |>
> |> What I'm trying to determine is: can I run these scripts from a
> |> command-line invocation?  I want to use the scripts to automatically
> |> convert files as they arrive, uploaded onto a website, not
> |> interactively.
> |>
> |> Has anyone played with this?
> |> --
> |> Marc Wilson
> |
> |Marc,
> |
> |This is not an answer to your question... but if you just want to convert
> | an image file into another format then upload it to a server you could
> | use a pure python solution (well pure python + PIL)
> |
> |PIL is here:-
> |
> |http://www.pythonware.com/products/pil/
> |
> |In fact a quick browse through the handbook and I found this:-
> |
> |http://www.pythonware.com/library/pil/handbook/pilconvert.htm
> |
> |and I quote:-
> |
> |"""
> |Convert an image from one format to another. The output format is
> | determined by the target extension, unless explicitly specified with the
> | -c option.
> |
> |    $ pilconvert lena.tif lena.png
> |    $ pilconvert -c JPEG lena.tif lena.tmp
> |
> |
> |"""
>
> It's a start- actually, we want to convert the file to JPEG (if not
> already), sharpen it, fix the size and also derive a thumbnail from it.
>
> We used something called Image Robot, a helper application from JASC.  Now
> that they have integrated this functionality into PSP, they no longer
> support IR, and we're having odd problems with it, so we're looking to see
> if we can do the same thing with a supported level.
>
> While I'm sure Python is a lovely language, the choice is due to PSP using
> the scripting engine: if I have to write something from scratch (or even
> from bits'n'bobs), I'll use a language I already know.
>
> |To upload the image to a server you could use the ftplib module...
>
> Already got it on the server- the customers upload the files using a web
> form.

Marc,

Point taken... I just can't resist showing you how easy it is in Python.....

# 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.


Cheers,
Martin.












More information about the Python-list mailing list