select the upper half of an image

Moderator: Kathy_9

Post Reply
mangurian
Posts: 109
Joined: Wed Sep 01, 2010 4:54 am
operating_system: Windows 7 Home Premium
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: MSI IONA 1.0
processor: 3.20 gigahertz Intel Core i5 650
ram: 8 Gig
Video Card: NVIDIA GeForce GT 230
sound_card: Realtek High Definition Audio
Hard_Drive_Capacity: 2 T
Location: Connecticut USA

select the upper half of an image

Post by mangurian »

Is there a way to record a script that selects the top half of an image independent of the image size?
Thanks,
LeviFiction
Advisor
Posts: 5984
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, 9, X, XI, X2, X8,X9, 2018, 2019
Location: USA

Re: select the upper half of an image

Post by LeviFiction »

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.
Attachments
SelectTopHalf.zip
(492 Bytes) Downloaded 36 times
mangurian
Posts: 109
Joined: Wed Sep 01, 2010 4:54 am
operating_system: Windows 7 Home Premium
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: MSI IONA 1.0
processor: 3.20 gigahertz Intel Core i5 650
ram: 8 Gig
Video Card: NVIDIA GeForce GT 230
sound_card: Realtek High Definition Audio
Hard_Drive_Capacity: 2 T
Location: Connecticut USA

Re: select the upper half of an image

Post by mangurian »

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 ?
LeviFiction
Advisor
Posts: 5984
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, 9, X, XI, X2, X8,X9, 2018, 2019
Location: USA

Re: select the upper half of an image

Post by LeviFiction »

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.
Post Reply