Can a script make Selection Fixed Size in inches?

Moderator: Kathy_9

Post Reply
JoeB
Posts: 2778
Joined: Fri Mar 28, 2008 10:04 pm
operating_system: Windows 8.1
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: LENOVO 4524PE4 ThinkCentre M91p
processor: 3.10 gigahertz Intel Quad Core i5-2400
ram: 8 GB
Hard_Drive_Capacity: 4.6 TB
Corel programs: PSP 9, X7 to 2019, 32 & 64-bit
Location: Canada

Can a script make Selection Fixed Size in inches?

Post by JoeB »

Because of the botched Crop Tool I use Selections to select an image area and then copy the selection as a new image. My Edit Selection script also makes it easy to edit the selection before copying/new image.

However, there are times when I have an image of a certain PPI resolution and I want to make a selection of a certain size in inches, for which the Crop Tool has an option. The Selection Fixed Size only has an option to fix the size in pixels. Can a script be created that would let a person select the Rectangle Selection tool and set the size of the selection in inches? It would, of course - or I believe anyway - have to read the image information and extract the PPI of the image before it could do so.

So it's just a concept in my mind, and thought I'd ask if it could be done. If so, it could make the Selection tool work as a better replacement for the crappy crop tool we're stuck with at the moment.
Regards,

JoeB
Using PSP 2019 64bit
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: Can a script make Selection Fixed Size in inches?

Post by LeviFiction »

Yes it is possible.

Code: Select all

        result = App.Do(Environment, 'ReturnImageInfo')
        Resolution = result['PixelsPerUnit']
        Units = result['Unit']
Will return either CM or Inches for the unit. And resolution is how many pixels make up that unit. Do the standard math to find the number of pixels, and make the selection.
https://levifiction.wordpress.com/
JoeB
Posts: 2778
Joined: Fri Mar 28, 2008 10:04 pm
operating_system: Windows 8.1
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: LENOVO 4524PE4 ThinkCentre M91p
processor: 3.10 gigahertz Intel Quad Core i5-2400
ram: 8 GB
Hard_Drive_Capacity: 4.6 TB
Corel programs: PSP 9, X7 to 2019, 32 & 64-bit
Location: Canada

Re: Can a script make Selection Fixed Size in inches?

Post by JoeB »

Thanks! I'll check it out and see if it was I was envisioning.

Am I supposed to edit the script? That is, does "Unit" accept the present PPI (whether it is inches or cm) or do I change it to Inches if I want Inches or CM if I want CM? I work in PPI, not PPCM.

Also, do I do the standard math myself, or does the script have a box that allows me to set the number of inches (including decimal amounts) because it already knows the PPI setting?

As you can see, I am looking for a script that allows me to just enter the number of inches H and W into a box (similar to the toolbar option allows you to do it with the crop tool) and the selection will automatically make a selection of that size in inches given the existing PPI of the image. I don't want to do the calculations myself, because I can already do that with the present Fixed Size option of the Selection tool. :-)
Regards,

JoeB
Using PSP 2019 64bit
JoeB
Posts: 2778
Joined: Fri Mar 28, 2008 10:04 pm
operating_system: Windows 8.1
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: LENOVO 4524PE4 ThinkCentre M91p
processor: 3.10 gigahertz Intel Quad Core i5-2400
ram: 8 GB
Hard_Drive_Capacity: 4.6 TB
Corel programs: PSP 9, X7 to 2019, 32 & 64-bit
Location: Canada

Re: Can a script make Selection Fixed Size in inches?

Post by JoeB »

Perhaps to make it a bit easier, I already will know the PPI of whatever image I'm working on. So if the input box requires me to put that PPI into the first field, for example, and then the height and width I want the selection rectangle to be into a second and third field, that's fine. It doesn't have to first determine the PPI if that adds to the problems creating the script. It just has to let me have one interface (like the Crop Tool has the Tool Options interface) in which I can enter the height and width I want the selection to be when I click OK. If I have to also add the PPI to that interface it's not a problem for me because, as I said, I already know the PPI of whatever particular image I'm working on so it's no problem also adding that info to the interface.
Regards,

JoeB
Using PSP 2019 64bit
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: Can a script make Selection Fixed Size in inches?

Post by LeviFiction »

I don't see why grabbing the information directly from the image would complicate anything. It's literally just those three lines to get the units and PPU (pixels per unit). And the math is easy.

Here is an old example script I made once. I think it does almost exactly what you want. The only thing it doesn't do is let you define the starting point. So you would have to move the selection rectangle after it's made. This is a bit moe complicated just because I created a custom dialog.
Attachments
SelectionByPrintSize.zip
(2.03 KiB) Downloaded 136 times
https://levifiction.wordpress.com/
JoeB
Posts: 2778
Joined: Fri Mar 28, 2008 10:04 pm
operating_system: Windows 8.1
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: LENOVO 4524PE4 ThinkCentre M91p
processor: 3.10 gigahertz Intel Quad Core i5-2400
ram: 8 GB
Hard_Drive_Capacity: 4.6 TB
Corel programs: PSP 9, X7 to 2019, 32 & 64-bit
Location: Canada

Re: Can a script make Selection Fixed Size in inches?

Post by JoeB »

LeviFiction wrote:I don't see why grabbing the information directly from the image would complicate anything. It's literally just those three lines to get the units and PPU (pixels per unit). And the math is easy.

Here is an old example script I made once. I think it does almost exactly what you want. The only thing it doesn't do is let you define the starting point. So you would have to move the selection rectangle after it's made. This is a bit moe complicated just because I created a custom dialog.
Thanks again. I don't mind moving the rectangle because I usually have to do that anyway with the Crop tool to get the part of the background that I want to use as the spine of the DVD cover I'm making. So that's definitely not an issue. I just wanted to be able to sort of make the Selection rectangle work like the Crop rectangle so that I could set it in inches (.600 in wide and 7.250 inches high). Then I can move it where I need it.

It's been a really busy day, and maybe a couple of days, but I'll get back here after I've had time to work with the info you've been kind enough to provide.
Regards,

JoeB
Using PSP 2019 64bit
JoeB
Posts: 2778
Joined: Fri Mar 28, 2008 10:04 pm
operating_system: Windows 8.1
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: LENOVO 4524PE4 ThinkCentre M91p
processor: 3.10 gigahertz Intel Quad Core i5-2400
ram: 8 GB
Hard_Drive_Capacity: 4.6 TB
Corel programs: PSP 9, X7 to 2019, 32 & 64-bit
Location: Canada

Re: Can a script make Selection Fixed Size in inches?

Post by JoeB »

I just gave the script a quick try in PSP 2019 and it works perfectly! Now I have no need to use the crop tool at all for any of my workflow, which is what I was trying to get away from. I'll be adding a button to my toolbar. I'll just add a bit so that it either starts with - or returns to - the Selection tool rather than remaining with whatever tool is active at the time. That will make it easy to move the selection if needed without my having to start the selection tool either before or after running the script. Much appreciated!
Regards,

JoeB
Using PSP 2019 64bit
Post Reply