Need to update IPTC info from Python script

Corel Paint Shop Pro

Moderator: Kathy_9

Post Reply
johnkorb
Posts: 9
Joined: Wed Jan 02, 2013 7:08 am
operating_system: Windows 7 Ultimate
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: ASUS P8H67-V
processor: i7 2600
ram: 16GB
Video Card: ASUS RADEON HD 6870
sound_card: Realtec
Hard_Drive_Capacity: 7TB
Monitor/Display Make & Model: Dual Samsung 27" 1920x1080 LED

Need to update IPTC info from Python script

Post by johnkorb »

I have a Python batch script that updates the EXIF information, but I need for it to also update the IPTC values. I don't have a list of Python functions available in PaintShop Pro X5 Ultimate, so I hope that someone either in the user community or at Corel can help me with information on how to update my Python batch script to update the IPTC values as well. Below is a copy of the Python script I developed (less the variable initializations for the title_description, instructions_text, author_name, and copyright_notice variables).

Code: Select all

from PSPApp import *

# Set values below for title_description, instructions_text, author_name, copyright_notice.


def ScriptProperties():
    return {
        'Author': author_name,
        'Copyright': author_name',
        'Description': u'Adds Image Author EXIF Information',
        'Host': u'PaintShop Pro',
        'Host Version': u'15.00'
        }

def Do(Environment):
    # EnableOptimizedScriptUndo
    App.Do( Environment, 'EnableOptimizedScriptUndo', {
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                'Version': ((15,0,0),1)
                }
            })

    # ImageInfo
    App.Do( Environment, 'ImageInfo', {
            'ArtistName': author_name, 
            'CopyrightHolder': copyright_notice, 
            'Description': instructions_text, 
            'Title': title_description, 
            'DisplayArtist': True, 
            'DisplayConditions': True, 
            'DisplayDate': True, 
            'DisplayGPS': True, 
            'DisplayImage': True, 
            'DisplayInput': True, 
            'DisplayMakernote': True, 
            'DisplayDataOnly': True, 
            'ExifTitle': title_description, 
            'ExifArtistName': author_name, 
            'ExifCopyright': copyright_notice, 
            'ExifComments': instructions_text, 
            'ActivePage': App.Constants.ImageInfoPropertySheet.CreatorPage, 
            'City': u'Fairfax', 
            'State': u'VA', 
            'Country': u'USA', 
            'Credit': author_name, 
            'Source': None, 
            'Headline': title_description, 
            'DescWriter': None, 
            'Instructions': instructions_text, 
            'TransRef': None, 
            'Urgency': None, 
            'ExifOrientation': 1, 
            'ExifDateTimeDigitized': None, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                'Version': ((15,0,0),1)
                }
            })

    ImageInfo = App.Do( Environment, 'ReturnImageInfo' )
    CurFileName        = ImageInfo['FileName']

    print "[------ Finished File: ",CurFileName," ------]"
Thanks!

John
PS - If someone has documentation on the functions in PaintShop Pro X5 Ultimate callable from Python and can pass it along, that would be great!
LeviFiction
Advisor
Posts: 6831
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Alienware M17xR4
processor: Intel Core i7-3630QM CPU - 2_40GH
ram: 6 GB
Video Card: NVIDIA GeForce GTX 660M
sound_card: Sound Blaster Recon3Di
Hard_Drive_Capacity: 500GB
Corel programs: PSP: 8-2023
Location: USA

Re: Need to update IPTC info from Python script

Post by LeviFiction »

Hello,

I don't think Corel has made new documentation for scripting since version XI of PSP. Now, we were promised new documentation on scripting for X5 but we'll see what happens. As far as I know they have not yet released anything new on scripting. Now, while scripting has changed in various ways most of the commands and functions still work as expected. Some may have additional parameters but that's not a biggie unless you're hoping to use those.

From the old API your code looks like it properly identifies the IPTC information. And I don't know of any bug in PSP that prevents saving out the IPTC information in X5. So if it's not saving out then the big question is whether or not the scripting internal documentation has been kept up to date.

"GetCommandInfo" doesn't seem to be returning a Parameter list, which is odd. But also what I was afraid of. If that information isn't included when running that command then all we have to go off of is the old API documentation.

If you don't already have the API documentation for XI or the Scripting for Script Authors help guide you should still be able to download them from here: ftp://ftp.corel.com/pub/documentation/PSP/

It's sometimes a bit slow to respond so be patient.
https://levifiction.wordpress.com/
johnkorb
Posts: 9
Joined: Wed Jan 02, 2013 7:08 am
operating_system: Windows 7 Ultimate
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: ASUS P8H67-V
processor: i7 2600
ram: 16GB
Video Card: ASUS RADEON HD 6870
sound_card: Realtec
Hard_Drive_Capacity: 7TB
Monitor/Display Make & Model: Dual Samsung 27" 1920x1080 LED

Re: Need to update IPTC info from Python script

Post by johnkorb »

Thanks! I'll give it a try. I'll download a copy of the "Scripting for Script Authors" document as well. If I can't find a solution there, I'll contact Corel support as I've had X5 Ultimate less than 30 days.
johnkorb
Posts: 9
Joined: Wed Jan 02, 2013 7:08 am
operating_system: Windows 7 Ultimate
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: ASUS P8H67-V
processor: i7 2600
ram: 16GB
Video Card: ASUS RADEON HD 6870
sound_card: Realtec
Hard_Drive_Capacity: 7TB
Monitor/Display Make & Model: Dual Samsung 27" 1920x1080 LED

Re: Need to update IPTC info from Python script

Post by johnkorb »

If you don't already have the API documentation or the Scripting for Script Authors help guide you should still be able to download them from here: ftp://ftp.corel.com/pub/documentation/PSP/
Unfortunately I did not see either of the documents at that page, but a search found the link:

http://learning-psp.blogspot.com/2009/0 ... re-to.html

The information is somewhat dated, but I'll review it and see what I find.

Thanks again for your help!

John

Update:
I discovered that when I click on the link in your post, my IE9 browser was blocking access to the FTP site and redirecting me to the PHP documentation page. For whatever reason, the links from the above blogspot page worked. Running Filezilla and going to ftp.corel.com/pub/documentation/PSP/ worked as well. I'm not sure why IE9 doesn't like the link in your post. Copying the link and pasting it into Chrome works...

Anyway, thanks for the link! I've been reading the documents and it looks like my code SHOULD be updating the IPTC values, but it isn't. I'll try contacting Corel directly and see what they say.
Post Reply