Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Python scripting with Paint Shop Pro 8.0

Reply
Thread Tools

Re: Python scripting with Paint Shop Pro 8.0

 
 
Martin Franklin
Guest
Posts: n/a
 
      07-21-2003
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/pi...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


"""

To upload the image to a server you could use the ftplib module...


Regards
Martin














 
Reply With Quote
 
 
 
 
Marc Wilson
Guest
Posts: n/a
 
      07-21-2003
In comp.lang.python, Martin Franklin
<(E-Mail Removed)> (Martin Franklin) wrote in
<(E-Mail Removed)>::

|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/pi...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 Wilson

Cleopatra Consultants Limited - IT Consultants
2 The Grange, Cricklade Street, Old Town, Swindon SN1 3HG
Tel: (44/0) 70-500-15051 Fax: (44/0) 870 164-0054
Mail: http://www.velocityreviews.com/forums/(E-Mail Removed) Web: http://www.cleopatra.co.uk
__________________________________________________ _______________
Try MailTraq at https://my.mailtraq.com/register.asp?code=cleopatra
 
Reply With Quote
 
 
 
 
Marc Wilson
Guest
Posts: n/a
 
      07-21-2003
In comp.lang.python, Martin Franklin
<(E-Mail Removed)> (Martin Franklin) wrote in
<(E-Mail Removed)>::

|On Monday 21 July 2003 12:29, Marc Wilson wrote:
|> In comp.lang.python, Martin Franklin
|> <(E-Mail Removed)> (Martin Franklin) wrote in
|>
|> <(E-Mail Removed)>::
|> |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/pi...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.

Groovy. I may become a Python convert. *sigh* I've not finished learning
perl yet, and now I've got a new shiny toy.

OK, I'll try installing the "proper" Python and see what's what.
--
Marc Wilson

Cleopatra Consultants Limited - IT Consultants
2 The Grange, Cricklade Street, Old Town, Swindon SN1 3HG
Tel: (44/0) 70-500-15051 Fax: (44/0) 870 164-0054
Mail: (E-Mail Removed) Web: http://www.cleopatra.co.uk
__________________________________________________ _______________
Try MailTraq at https://my.mailtraq.com/register.asp?code=cleopatra
 
Reply With Quote
 
Marc Wilson
Guest
Posts: n/a
 
      07-21-2003
In comp.lang.python, (E-Mail Removed) (John J. Lee) (John J. Lee) wrote in
<(E-Mail Removed)>::

|Marc Wilson <(E-Mail Removed)> writes:
|[...]
|> 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.
|[...]
|
|Very wise. It would take you a whole afternoon to learn Python well
|enough to do what you want with PIL <0.2 wink>.

Perhaps. It might take a whole day if the phone keeps ringing
|
|http://effbot.org/zone/pil-imageenhance.htm
|http://effbot.org/zone/pil-imagefilter.htm
|
|
|And I'm sure that afternoon will pay off again.

Prolly.

|OK, and another day to get out of the mess your OS (whichever one you
|use) will try to get you into with naming conventions, filesystem
|paths and other plumbing <0.8 wink>.

Win2K, so not the worst platform, nor the best, I imagine.
--
Marc Wilson

Cleopatra Consultants Limited - IT Consultants
2 The Grange, Cricklade Street, Old Town, Swindon SN1 3HG
Tel: (44/0) 70-500-15051 Fax: (44/0) 870 164-0054
Mail: (E-Mail Removed) Web: http://www.cleopatra.co.uk
__________________________________________________ _______________
Try MailTraq at https://my.mailtraq.com/register.asp?code=cleopatra
 
Reply With Quote
 
Peter Hansen
Guest
Posts: n/a
 
      07-21-2003
Marc Wilson wrote:
>
> Groovy. I may become a Python convert. *sigh* I've not finished learning
> perl yet, and now I've got a new shiny toy.


Excellent! You have much less to _un_learn then.
 
Reply With Quote
 
Marc Wilson
Guest
Posts: n/a
 
      07-21-2003
In comp.lang.python, Peter Hansen <(E-Mail Removed)> (Peter Hansen) wrote
in <(E-Mail Removed)>::

|Marc Wilson wrote:
|>
|> Groovy. I may become a Python convert. *sigh* I've not finished learning
|> perl yet, and now I've got a new shiny toy.
|
|Excellent! You have much less to _un_learn then.

I'm not here to participate in any religious wars.
--
Marc Wilson

Cleopatra Consultants Limited - IT Consultants
2 The Grange, Cricklade Street, Old Town, Swindon SN1 3HG
Tel: (44/0) 70-500-15051 Fax: (44/0) 870 164-0054
Mail: (E-Mail Removed) Web: http://www.cleopatra.co.uk
__________________________________________________ _______________
Try MailTraq at https://my.mailtraq.com/register.asp?code=cleopatra
 
Reply With Quote
 
Peter Hansen
Guest
Posts: n/a
 
      07-21-2003
Marc Wilson wrote:
>
> In comp.lang.python, Peter Hansen <(E-Mail Removed)> (Peter Hansen) wrote
> in <(E-Mail Removed)>::
>
> |Marc Wilson wrote:
> |>
> |> Groovy. I may become a Python convert. *sigh* I've not finished learning
> |> perl yet, and now I've got a new shiny toy.
> |
> |Excellent! You have much less to _un_learn then.
>
> I'm not here to participate in any religious wars.


Sorry, I must have misinterpreted your use of the word "convert" then.
 
Reply With Quote
 
Aahz
Guest
Posts: n/a
 
      07-23-2003
In article <(E-Mail Removed)>,
Marc Wilson <(E-Mail Removed)> wrote:
>
>Groovy. I may become a Python convert. *sigh* I've not finished learning
>perl yet, and now I've got a new shiny toy.


<smirk>
--
Aahz ((E-Mail Removed)) <*> http://www.pythoncraft.com/

This is Python. We don't care much about theory, except where it intersects
with useful practice. --Aahz
 
Reply With Quote
 
Marc Wilson
Guest
Posts: n/a
 
      07-24-2003
In comp.lang.python, Martin Franklin
<(E-Mail Removed)> (Martin Franklin) wrote in
<(E-Mail Removed)>::

|On Monday 21 July 2003 12:29, Marc Wilson wrote:
|> In comp.lang.python, Martin Franklin
|> <(E-Mail Removed)> (Martin Franklin) wrote in
|
|> 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.

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 Wilson

Cleopatra Consultants Limited - IT Consultants
2 The Grange, Cricklade Street, Old Town, Swindon SN1 3HG
Tel: (44/0) 70-500-15051 Fax: (44/0) 870 164-0054
Mail: (E-Mail Removed) Web: http://www.cleopatra.co.uk
__________________________________________________ _______________
Try MailTraq at https://my.mailtraq.com/register.asp?code=cleopatra
 
Reply With Quote
 
Duncan Booth
Guest
Posts: n/a
 
      07-24-2003
Marc Wilson <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

> 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?


How about this:

from PIL import Image, ImageFont, ImageDraw, ImageChops

im = Image.open("test.jpg")
im.thumbnail((128, 12, Image.ANTIALIAS)

font = ImageFont.truetype("arial.ttf", 30)

def AddOverlay(im, origin, text, angle=-45):
# Create an overlay with white text and subtract it from the image.
# This effectively blacks out the area to be overlaid.
overlay = Image.new(im.mode, im.size)
draw = ImageDraw.Draw(overlay)
draw.text(origin, text, (255, 255, 255), font=font)
overlay = overlay.rotate(angle)
stamped = ImageChops.subtract(im, overlay, 1, 0)


# Now create a red overlay and add it to the subtracted image
overlay = Image.new(im.mode, im.size)
draw = ImageDraw.Draw(overlay)
draw.text(origin, text, (255, 0, 0), font=font)
overlay = overlay.rotate(angle)
stamped = ImageChops.add(stamped, overlay, 1, 0)
return stamped

stamped = AddOverlay(im, (10, 50), "SOLD!")
stamped.show()


--
Duncan Booth (E-Mail Removed)
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Powerdesk Pro: viewing pspimage files from Paint Shop Pro? MitchellWmA Computer Support 1 10-05-2008 05:01 PM
paint shop pro 4 help The White Lady Computer Support 6 06-11-2004 04:09 PM
Paint Shop Pro now speaks German? User Computer Support 5 09-25-2003 07:07 AM
Re: Python scripting with Paint Shop Pro 8.0 Greg Brunet Python 4 07-23-2003 01:46 PM
Re: Python scripting with Paint Shop Pro 8.0 Aahz Python 5 07-22-2003 08:14 AM



Advertisments