Is there a way to record a script that selects the top half of an image independent of the image size?
Thanks,
select the upper half of an image
Moderator: Kathy_9
-
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: select the upper half of an image
Yes, this is possible with scripts. The best way to do this is to record an initial script that creates a manual selection and then edit it to do the math so that makes the script intelligent.
My brain isn't working well enough for me to explain what I mean so I'm attaching a script that does what you want. It calls the "Custom Selection" command and uses the TargetDocument (the one that was active when you ran the script) to figure out how wide and tall the selection should be. I recorded the use of Custom Selection and then edited the script to use the TargetDocument.Width and TargetDocument.Height variables.
Just unzip this file into your Scripts-Restricted folder.
My brain isn't working well enough for me to explain what I mean so I'm attaching a script that does what you want. It calls the "Custom Selection" command and uses the TargetDocument (the one that was active when you ran the script) to figure out how wide and tall the selection should be. I recorded the use of Custom Selection and then edited the script to use the TargetDocument.Width and TargetDocument.Height variables.
Just unzip this file into your Scripts-Restricted folder.
- Attachments
-
- SelectTopHalf.zip
- (492 Bytes) Downloaded 104 times
https://levifiction.wordpress.com/
-
mangurian
- Posts: 122
- Joined: Wed Sep 01, 2010 4:54 am
- System_Drive: C
- 32bit or 64bit: 64 Bit
- motherboard: Dell Inc 0K3CM7 A00
- processor: Intel I7 11th Gen
- ram: 64 Gig
- Video Card: NVIDIA GeForce RTX 3060 [Display adapter]
- Hard_Drive_Capacity: 3 T
- Corel programs: VSP, PSP
- Location: Connecticut USA
Re: select the upper half of an image
Thanks. This gives me a great starting point.
Is there a way to assign the image width/height to a global variable for use throughout my script ?
Is there a way to assign the image width/height to a global variable for use throughout my script ?
-
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: select the upper half of an image
Scripts are written in Python, just use global variables the way Python does them.
Of course you don't need to unless you want your own copies.
By default PSP has a global object called App. This object contains a lot of information, but specifically 3 other objects that relate to the images/documents open inside of PSP. App.TargetDocument is the document that was active when you ran the script, App.ActiveDocument is the currently active document which can be changed through the use of the SelectDocument command. When you open a new image in script, for example, you will want to select the new document to make sure it's active. And the Documents list, an array.of document objects. Each document object contains a title member a Name member which is the full path of it's a file, as well as width and height info.
I highly recommend the Scripting for Script Authors PDF for more information.
Of course you don't need to unless you want your own copies.
By default PSP has a global object called App. This object contains a lot of information, but specifically 3 other objects that relate to the images/documents open inside of PSP. App.TargetDocument is the document that was active when you ran the script, App.ActiveDocument is the currently active document which can be changed through the use of the SelectDocument command. When you open a new image in script, for example, you will want to select the new document to make sure it's active. And the Documents list, an array.of document objects. Each document object contains a title member a Name member which is the full path of it's a file, as well as width and height info.
I highly recommend the Scripting for Script Authors PDF for more information.
https://levifiction.wordpress.com/
