Image.Rectangle Crop
- Morten Lerager
- Posts: 69
- Joined: 08 Oct 2021, 14:53
- Location: Denmark
Image.Rectangle Crop
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
(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. Asiair.
Asi294mc. AA8.
Asi294mc. AA8.
Re: Image.Rectangle Crop
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
Re: Image.Rectangle Crop
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.
"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.
- Morten Lerager
- Posts: 69
- Joined: 08 Oct 2021, 14:53
- Location: Denmark
Re: Image.Rectangle Crop
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
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. Asiair.
Asi294mc. AA8.
Asi294mc. AA8.
Re: Image.Rectangle Crop
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:
This could be modified to work on selected rectangles too, where cx, cy, and size are calculated from the active rectangle.
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)
- Morten Lerager
- Posts: 69
- Joined: 08 Oct 2021, 14:53
- Location: Denmark
Re: Image.Rectangle Crop
Thank's Fabio
I look into it and return with a solution.
I look into it and return with a solution.
HEQ5 Pro 150PDS 60mm guide. Asiair.
Asi294mc. AA8.
Asi294mc. AA8.
- Morten Lerager
- Posts: 69
- Joined: 08 Oct 2021, 14:53
- Location: Denmark
Re: Image.Rectangle Crop
Hi'
I came up with this solution.
Not so smooth as i was aimed for. But it' works
The Crop will be in a Aspect Ratio of 3:2
Preselect a rectangle. The hight is used to calculate the crop width
' *** Aspect Ratio ***
' *** AstroArt 8 ***
' *** 28:11:21 Morten Lerager ***
' Make rectangle selection
' The Hight will be used for Calc. the size.
' So the width is Only for only for determination the center
AR=1.5 '=Aspect Ratio 3:2
x1 = Image.Rectangle.X1
y1 = Image.Rectangle.Y1
x2 = Image.Rectangle.X2
y2 = Image.Rectangle.Y2
if x1 = x2 then
print "Select rectangle with a Height to Crop before RUN"
end
end if
height=(y2-y1)
IF frac(height/2) = 0.5 Then
y2=y2+1
height=height+1
endif
HW=int(height*1.5/2)
xcen=(x2-x1)/2+x1
x1=xcen-HW
x2=xcen+HW
If x1<0 then
Print "X<0 out of border"
END
end if
If x2>Image.Width then
Print "X> Image Width out of border"
END
end if
Image.Points.Add(x1,y1)
Image.Points.Add(x2,y1)
Image.Points.Add(x2,y2)
Image.Points.Add(x1,y2)
Input "Do yot want to Crop at these four points Y/N ?", answer
IF answer <> "Y" and answer <> "y" then
Image.Points.Clear
Print "STOPPED"
END
end if
Image.Points.Clear
Image.PrepareUndo
Image.crop (x1,y1,x2,y2)
Image.Update
I came up with this solution.
Not so smooth as i was aimed for. But it' works
The Crop will be in a Aspect Ratio of 3:2
Preselect a rectangle. The hight is used to calculate the crop width
' *** Aspect Ratio ***
' *** AstroArt 8 ***
' *** 28:11:21 Morten Lerager ***
' Make rectangle selection
' The Hight will be used for Calc. the size.
' So the width is Only for only for determination the center
AR=1.5 '=Aspect Ratio 3:2
x1 = Image.Rectangle.X1
y1 = Image.Rectangle.Y1
x2 = Image.Rectangle.X2
y2 = Image.Rectangle.Y2
if x1 = x2 then
print "Select rectangle with a Height to Crop before RUN"
end
end if
height=(y2-y1)
IF frac(height/2) = 0.5 Then
y2=y2+1
height=height+1
endif
HW=int(height*1.5/2)
xcen=(x2-x1)/2+x1
x1=xcen-HW
x2=xcen+HW
If x1<0 then
Print "X<0 out of border"
END
end if
If x2>Image.Width then
Print "X> Image Width out of border"
END
end if
Image.Points.Add(x1,y1)
Image.Points.Add(x2,y1)
Image.Points.Add(x2,y2)
Image.Points.Add(x1,y2)
Input "Do yot want to Crop at these four points Y/N ?", answer
IF answer <> "Y" and answer <> "y" then
Image.Points.Clear
Print "STOPPED"
END
end if
Image.Points.Clear
Image.PrepareUndo
Image.crop (x1,y1,x2,y2)
Image.Update
HEQ5 Pro 150PDS 60mm guide. Asiair.
Asi294mc. AA8.
Asi294mc. AA8.
Re: Image.Rectangle Crop
Thanks Morten, I confirm that in AA8 Service pack 1 there will be a script command to select rectangles.
Fabio.
Fabio.
- Morten Lerager
- Posts: 69
- Joined: 08 Oct 2021, 14:53
- Location: Denmark
Re: Image.Rectangle Crop
Oh, thats greeat news Fabio, thank you.
i will be looking forward to it.
i will be looking forward to it.
HEQ5 Pro 150PDS 60mm guide. Asiair.
Asi294mc. AA8.
Asi294mc. AA8.