can scale support 123*456?
Closed this issue · 8 comments
For example, I want to scale an image with a resolution of 3000x2000 to 100x100
maybe can support it like this ?
{scale : 100*100}
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
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.
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
I want to find them in different resolutions, so I need to scale them first.
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.
It works.
So when we use a specific resolution for scaling, it no longer forces the aspect ratio to be maintained?
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.)
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
cool !