Image.Rectangle Crop

Scripts and programs to automate Astroart
Post Reply
User avatar
Morten Lerager
Posts: 13
Joined: 08 Oct 2021, 14:53
Location: Denmark

Image.Rectangle Crop

Post by Morten Lerager » 15 Nov 2021, 15:56

Hi' AA's
(Nothing about Alcoholic)
Trying to make it easy to crop to a known aspect ratio.
I can make a crop by the Image.crop (x1,y1,x2,y2)
But that's very "hard coded" (Inflexible)
Then we have the Image.Rectangle but as I read it, it's only for returning size, not for setting.
I want a macro to act like :
Make a Rectangle Selection
Press ^R
Read the coordinate and change them according to aspect ratio.
Then move the selection as normal ^ mouse
And then do a Crop.

So how to do that :?:
HEQ5 Pro 150PDS 60mm Guide Lacerta
Baader MPCC EOS 2000D. AA8

Iver
Posts: 55
Joined: 08 Jan 2019, 04:32

Re: Image.Rectangle Crop

Post by Iver » 16 Nov 2021, 02:45

Hi Morten, open an image you want to crop then drag a rectangle the size and position you want. Next open define Macro and then use the slider to find Crop. Double click crop and name the macro. When you run that macro it will crop the image that is open or you can load the images you want cropped and they will all be cropped.
Iver

fabdev
Posts: 282
Joined: 03 Dec 2018, 21:43

Re: Image.Rectangle Crop

Post by fabdev » 16 Nov 2021, 04:03

Hi, may you explain the pass:
"Read the coordinate and change them according to aspect ratio" ?
What is the goal of the processing? Maybe there's a different way to do that.
Fabio.

User avatar
Morten Lerager
Posts: 13
Joined: 08 Oct 2021, 14:53
Location: Denmark

Re: Image.Rectangle Crop

Post by Morten Lerager » 16 Nov 2021, 17:05

Thank's Fabio
The goal is to crop in etc 3:2 format.
As I understand the crop as it is, I'll have to do the calc. every time. The macro is for simulate crop as we know it in PS or Gimp. Make a selection with giving aspect ration.

@Iver that way will only make the same crop every time.
Same as the Image.crop x1,x2,y1,y2
HEQ5 Pro 150PDS 60mm Guide Lacerta
Baader MPCC EOS 2000D. AA8

fabdev
Posts: 282
Joined: 03 Dec 2018, 21:43

Re: Image.Rectangle Crop

Post by fabdev » 17 Nov 2021, 02:07

OK.
It's not possible to select a rectangle via scripts, but since usually a selection is centered around an object, this script could solve:
Select a point on the subject then:

Code: Select all

sizeX = 300
sizeY = 200
if Image.Points.Count <> 1 then
   Message("Please select a point")
   end
end if
cx = Image.GetPointX
cy = Image.GetPointY
x1 = cx - sizeX / 2
y1 = cy - sizeY / 2
x2 = x1 + sizeX - 1
y2 = y1 + sizeY - 1
Image.PrepareUndo
Image.Crop(x1, y1, x2, y2)
This could be modified to work on selected rectangles too, where cx, cy, and size are calculated from the active rectangle.

User avatar
Morten Lerager
Posts: 13
Joined: 08 Oct 2021, 14:53
Location: Denmark

Re: Image.Rectangle Crop

Post by Morten Lerager » 17 Nov 2021, 18:45

Thank's Fabio
I look into it and return with a solution.
HEQ5 Pro 150PDS 60mm Guide Lacerta
Baader MPCC EOS 2000D. AA8

Post Reply