iseahound / ImagePut

A core library for images in AutoHotkey. Supports AutoHotkey v1 and v2.
https://www.autohotkey.com/boards/viewtopic.php?f=83&t=76633
MIT License
116 stars 24 forks source link

can scale support 123*456? #7

Closed telppa closed 2 years ago

telppa commented 2 years ago

For example, I want to scale an image with a resolution of 3000x2000 to 100x100 maybe can support it like this ?

{scale : 100*100}

iseahound commented 2 years ago

Which is better?

{scale: [100, 200]}

{w: 100, h: 200}

{size: [100, 200]}

I don't want to parse a string, and 100*100 = 10000

iseahound commented 2 years ago

Also please let me know what the purpose is. I can't think of a case where it would be useful since this changes the image data.

telppa commented 2 years ago

I choose {size: [100, 200]}

Maybe it would be better to add two parameters?

forceSize means ignore the original ratio forced scaling. size means follow the original ratio.

{size: [100, 200]}

{forceSize: [100, 100]}

2 cases.

1 is that people will want to scale some images of different resolutions to a uniform size, e.g. 3000x2000 6000x4000 to 1000x667 .

2 is searching images in different resolution.

For example, this tree looks like this in 1920x1080 tree1

looks like this in 800x600. tree2

I want to find them in different resolutions, so I need to scale them first.

iseahound commented 2 years ago

I've updated a version that uses:

{scale: [100, 200]} ; Easiest to implement.

ImagePutWindow({image: 0, crop: [0, 0, 200, 200], scale: 3})
ImagePutWindow({image: 0, crop: [0, 0, 200, 200], scale: [123, 345]})

Let me know if it works, and you can close the issue.

telppa commented 2 years ago

It works.

So when we use a specific resolution for scaling, it no longer forces the aspect ratio to be maintained?

iseahound commented 2 years ago

I think the feature you are alluding to is something like setting the width or height only and using the aspect ratio to fill in the blank.

; If the original size is 200×200
scale: [100, ] ; Unspecified height becomes 100. 
scale: [, 100] ; Unspecified width becomes 100. 

That's why I was considering {w: 100, h: 200} as a more clear way to outline this possible feature.

If this is what you want let me know. (If you are talking about fill / fit where excess is cropped or filled in to a specific color, then that's different.)

iseahound commented 2 years ago

I have implemented the suggestion. Let me know if this is what you meant.

; Scale width automatically.
ImagePutWindow({image: 0, crop: [0, 0, 200, 100], scale: ["", 500]})

; Scale height automatically.
ImagePutWindow({image: 0, crop: [0, 0, 200, 100], scale: [500, ""]})

; You can use scale: ["auto", 500] or any string including the blank string.

Updated documentation https://github.com/iseahound/ImagePut/wiki/Crop,-Scale,-&-Other-Flags#scale

telppa commented 2 years ago

cool !