Syntax PaintshopProX3
Moderator: Kathy_9
Syntax PaintshopProX3
I'm using PaintShop ProX3 on a windows 7 system. My software is up to date Version 13.2.1.20. I am trying to create a script for batch processing, but I want to use the "save as" function but when I run the script I want the script to save with the new file name and not the file name used for the script. The script Python code is:
# FileSaveAs
App.Do( Environment, 'FileSaveAs', {
'Encoding': {
'JPG': {
'Variant': App.Constants.JpegFormat.Standard,
'CompressionFactor': 20,
'ChromaSubSampling': App.Constants.ChromaSubSampling.YCC_1x1_1x1_1x1,
'EXIF': True,
'EmbedJPGICC': True
}
},
'FileName': u'C:\\Users\\Alain\\Documents\\Bank\\Site\\Arc-en-ciel\\pic1f1'\
u'0.jpg',
So what would be the synthax that I need to use to get it to use the original file name instead of the Pic1 file name?
I appreciate anyone with good info,
Alain
# FileSaveAs
App.Do( Environment, 'FileSaveAs', {
'Encoding': {
'JPG': {
'Variant': App.Constants.JpegFormat.Standard,
'CompressionFactor': 20,
'ChromaSubSampling': App.Constants.ChromaSubSampling.YCC_1x1_1x1_1x1,
'EXIF': True,
'EmbedJPGICC': True
}
},
'FileName': u'C:\\Users\\Alain\\Documents\\Bank\\Site\\Arc-en-ciel\\pic1f1'\
u'0.jpg',
So what would be the synthax that I need to use to get it to use the original file name instead of the Pic1 file name?
I appreciate anyone with good info,
Alain
-
LeviFiction
- Advisor
- Posts: 6831
- Joined: Thu Oct 02, 2008 1:07 pm
- 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: synthax PaintshopProX3
There are default objects in the App object for things like this. I would use TargetDocument though others might suggest ActiveDocument. For this script they are pretty much exactly the same thing. ActiveDocument is dynamic and can change during the course of your script as it's the one that is currently active in the editor. The TargetDocument is usually the one that was active when you started the script.
These contain a special variable called "Name" that includes the complete path name of the image.
'FileName': App.TargetDocument.Name
If you only want the current name and not the current path of the image you can use "Title" instead of name.
I couldn't find the scripting links in the knowledgebase right now, it's possible they are still moving most of the knowledgebase over to the new system.
But I did find a blog posting with links to the relevant scripting information. "Scripting for Script authors" shows you a lot of what can be done with scripting and teaching you the basics.
http://learning-psp.blogspot.com/2009/0 ... re-to.html
These contain a special variable called "Name" that includes the complete path name of the image.
'FileName': App.TargetDocument.Name
If you only want the current name and not the current path of the image you can use "Title" instead of name.
I couldn't find the scripting links in the knowledgebase right now, it's possible they are still moving most of the knowledgebase over to the new system.
But I did find a blog posting with links to the relevant scripting information. "Scripting for Script authors" shows you a lot of what can be done with scripting and teaching you the basics.
http://learning-psp.blogspot.com/2009/0 ... re-to.html
https://levifiction.wordpress.com/
Re: synthax PaintshopProX3
Thank you, I will look into all the info you've me. I appreciate this alot.
Al
Al
Re: synthax PaintshopProX3
Thanks again, but I'm not quite achieving my goal. I've consulted the sites you recomended and on one of the Command API file I only get empty HTML pages. But your instructions for the targetDocument were right on targert. The problem I'm still having is that the reason for the script is because I want to use multiple frames on multiple pictures. This is why I produce the "Save as" fonction and move on to the other frame. But I need for that save to keep a numerical value i.e. pic01f01; pic01f02 ect and when I move to the next picture, it his to save as pic02f01; pic02f02. I've tried using the sequence option, in the Bactch process, but it only safes as 01, regardles of the TargetDocument command. I can manually give the numerical attribute to each save, but how do I get the software to add it to the original file name, so as to have a different file on each save.
Al
Al
-
LeviFiction
- Advisor
- Posts: 6831
- Joined: Thu Oct 02, 2008 1:07 pm
- 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: synthax PaintshopProX3
The blank pages surprises me, though I didn't download them myself. I should to see if the link is still accurate. If not then I'll see if I can't find a more accurate link to the APIs.
That problem is closer to a python issue than one with scripting in PSP.
There are sample scripts at Suz's Place on using a script to process an entire folder without the batch processing command. Doing it this way you can keep track of the value itself.
http://suzsplace.com
They also have examples of allowing a script to save data between runs. You could keep track of value itself if you did this since the script runs once per image in the batch process command. Then all you would have to do is add the value:
TargetDocument.Name + str(inum)
inum = inum + 1
Since I've never done this myself I'm just throwing out random ideas that may or may not work. Cassel on the forums here is pretty adept at scripting, definitely more than I am. Suz herself, the owner of that site, is also excellent if you want to go this direction.
But depending on how the script works you might be able to do this without the script or without using the "SaveAs" option in the script and just relying on the options in the batch processing command.
Care to share the steps the script takes? Or the script itself?
That problem is closer to a python issue than one with scripting in PSP.
There are sample scripts at Suz's Place on using a script to process an entire folder without the batch processing command. Doing it this way you can keep track of the value itself.
http://suzsplace.com
They also have examples of allowing a script to save data between runs. You could keep track of value itself if you did this since the script runs once per image in the batch process command. Then all you would have to do is add the value:
TargetDocument.Name + str(inum)
inum = inum + 1
Since I've never done this myself I'm just throwing out random ideas that may or may not work. Cassel on the forums here is pretty adept at scripting, definitely more than I am. Suz herself, the owner of that site, is also excellent if you want to go this direction.
But depending on how the script works you might be able to do this without the script or without using the "SaveAs" option in the script and just relying on the options in the batch processing command.
Care to share the steps the script takes? Or the script itself?
https://levifiction.wordpress.com/
Re: synthax PaintshopProX3
Sorry if it took me a while to reply but I did go on suzsplace.com and I wrote to her. She was gracious enough to respond and send me a script that she made. I don't doubt in her script but I don't see myself using the script individually for each picture (that is not using the batch file). So I used some of the commands and added it to the ones I already have. Now I'm almost there but not quite. To make a long story short here is the latest SaveAs command that I've come up with:
'FileName': App.TargetDocument.Name + str(+01) + ".jpg",
But what this gives me is a final product of *.jpg1.jpg The string is only addes after the .jpg, but if I could subtract the original .jpg first and then add the str, this would work. Do you have any suggestions?
i.e. 'FileName': App.TargetDocument.Name (-.jpg) + str(+01) + ".jpg", I've tried it and it didn't work.
Thanks again
Al
'FileName': App.TargetDocument.Name + str(+01) + ".jpg",
But what this gives me is a final product of *.jpg1.jpg The string is only addes after the .jpg, but if I could subtract the original .jpg first and then add the str, this would work. Do you have any suggestions?
i.e. 'FileName': App.TargetDocument.Name (-.jpg) + str(+01) + ".jpg", I've tried it and it didn't work.
Thanks again
Al
-
LeviFiction
- Advisor
- Posts: 6831
- Joined: Thu Oct 02, 2008 1:07 pm
- 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: synthax PaintshopProX3
Honestly, if you tell me what it is you're doing I might be able to help you avoid having to use the SaveAs option altogether. The Batch Process command is very useful and versatile.
But what you want to do is import the os library. So underneath the code from PSPApp import * just add the code import os
Now you have access to the command os.path.splitext().
This command returns two strings in a pair. So we'll create two special variables "Opath" and "oext". The first one will hold the path and filename. The second one will hold the extension.
Then inside the SaveAs command do this
Or you can replace "oext" with ".jpg" either way is fine.
But what you want to do is import the os library. So underneath the code from PSPApp import * just add the code import os
Code: Select all
from PSPApp import *
//add this
import os
This command returns two strings in a pair. So we'll create two special variables "Opath" and "oext". The first one will hold the path and filename. The second one will hold the extension.
Code: Select all
(opath, oext) = os.path.splitext(App.TargetDocument.Name)
Code: Select all
'FileName': opath + str(+01) + oext
https://levifiction.wordpress.com/
Re: synthax PaintshopProX3
Eureka! It works, thank you very much. I apoligize if I'm not clear as to what I want to do. I'm not trying to be mysterious or anything but I'm trying to be as short and sweet as possible. I don't really know how else to put it than saying I'm trying to put multiple frames on multiple pictures, each needing to have different names. The idea is to create a tool for me to determine the best frame for the different picture. This hopefully will allow me to determine the best sutted frame or finish for the picture before either buying a frame or give it a certain finish before having it laminated. So I don't know if this satisfies what I'm trying to do, but this script will certainly save me alot of time.
If its not too much trouble can you tell me if I can give a letter attribute rather than a number; i.e. l=low res, m=medium res, or wm for watermark. So that the str in the 'FileName': opath + str(+01) + oext can be a letter instead of a number.
As I'm trying to do the multiple frames, the function seems to alter the original pictures (such as borders) which is carried on to the next frame. When I did this manually, I would do the Undo function, but in this case for the script, it removes the whole previous action (frame and all). I've tried to put in "# Undo", it does seem to work but it removes the last action (SaveAs) when I really want to undo the last frame (so as to get the original picture) but keep the last action taken.
Thanks again,
Al
If its not too much trouble can you tell me if I can give a letter attribute rather than a number; i.e. l=low res, m=medium res, or wm for watermark. So that the str in the 'FileName': opath + str(+01) + oext can be a letter instead of a number.
As I'm trying to do the multiple frames, the function seems to alter the original pictures (such as borders) which is carried on to the next frame. When I did this manually, I would do the Undo function, but in this case for the script, it removes the whole previous action (frame and all). I've tried to put in "# Undo", it does seem to work but it removes the last action (SaveAs) when I really want to undo the last frame (so as to get the original picture) but keep the last action taken.
Thanks again,
Al
Re: synthax PaintshopProX3
I would just like to thank you for the reference of http://suzsplace.com/ She's been a great help.
Thanks again,
Al
Thanks again,
Al
Re: synthax PaintshopProX3
Thanks for all the feed back you have given me, it really helped. As I'm working more with my and developping working methods, it would be helpful if I could save my work in different forlders. This is in the script, when a .gif file is created it goes in one forlder, the .jpg in another and the watermark in a third folder. My script up to now is:
from PSPApp import *
import os
def ScriptProperties():
return {
'Author': u'Alain Thibault',
'Copyright': u'',
'Description': u'',
'Host': u'PaintShop Photo Pro',
'Host Version': u'13.00 Alpha 00000000.0000000000.00'
}
def Do(Environment):
# EnableOptimizedScriptUndo
App.Do( Environment, 'EnableOptimizedScriptUndo', {
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((13,0,0),1)
}
})
(opath, oext) = os.path.splitext(App.TargetDocument.Name)
# FileSaveAs
App.Do( Environment, 'FileSaveAs', {
'Encoding': {
'JPG': {
'Variant': App.Constants.JpegFormat.Standard,
'CompressionFactor': 20,
'ChromaSubSampling': App.Constants.ChromaSubSampling.YCC_1x1_1x1_1x1,
'EXIF': True,
'EmbedJPGICC': True
}
},
'FileName': opath + "hd" + ".jpg",
'FileFormat': App.Constants.FileFormat.JPG,
'FormatDesc': u'JPG JPEG ',
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.AllAlways,
'Version': ((13,0,0),1)
},
'DefaultProperties': []
})
but I want the different paths to be :
'FileName': u'C:\\Users\\Alain\\Desktop\\upload\\download\\targetdocument + jpg',
'FileName': u'C:\\Users\\Alain\\Desktop\\upload\\image\\targetdocument + gif',
What the modifications that I need to do?
Thanks again for all your help.
Alain
from PSPApp import *
import os
def ScriptProperties():
return {
'Author': u'Alain Thibault',
'Copyright': u'',
'Description': u'',
'Host': u'PaintShop Photo Pro',
'Host Version': u'13.00 Alpha 00000000.0000000000.00'
}
def Do(Environment):
# EnableOptimizedScriptUndo
App.Do( Environment, 'EnableOptimizedScriptUndo', {
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((13,0,0),1)
}
})
(opath, oext) = os.path.splitext(App.TargetDocument.Name)
# FileSaveAs
App.Do( Environment, 'FileSaveAs', {
'Encoding': {
'JPG': {
'Variant': App.Constants.JpegFormat.Standard,
'CompressionFactor': 20,
'ChromaSubSampling': App.Constants.ChromaSubSampling.YCC_1x1_1x1_1x1,
'EXIF': True,
'EmbedJPGICC': True
}
},
'FileName': opath + "hd" + ".jpg",
'FileFormat': App.Constants.FileFormat.JPG,
'FormatDesc': u'JPG JPEG ',
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.AllAlways,
'Version': ((13,0,0),1)
},
'DefaultProperties': []
})
but I want the different paths to be :
'FileName': u'C:\\Users\\Alain\\Desktop\\upload\\download\\targetdocument + jpg',
'FileName': u'C:\\Users\\Alain\\Desktop\\upload\\image\\targetdocument + gif',
What the modifications that I need to do?
Thanks again for all your help.
Alain
