Copy link to clipboard
Copied
I have images that with differnt dimentions, mix with protrait and lanscape, is there any script can detect the image size then auto crop to best fit aspect raio : 1:1, 2:3, 3:4, 4:5, 5:7, 2:1, 3:1 / 3:2, 4:3, 5:4, 7:5, 1:2, 1:)
I tried ask chatGPT to help (LOL), it gave me some messy and cofused code.
Then I did a lot searches, no resources can provide some hints to start to code it.
Any ideas ? Thanks
Copy link to clipboard
Copied
Thank you for sharing!
Copy link to clipboard
Copied
You are welcome, all credtits to @c.pfaffenbichler , he is a real kind expert !!
Copy link to clipboard
Copied
You are welcome, all credtits to @c.pfaffenbichler , he is a real kind expert !!
By @Calvin21914323wi10
That he is!
However, I do also thank you for sharing the final code so that others looking for a similar solution have a possible solution.
Copy link to clipboard
Copied
I added 2 lines only
By @Calvin21914323wi10
Your photo is always cropped from the top left corner. Do you think this is correct?
Copy link to clipboard
Copied
var bounds = [0,0,targetW, targetH]
The first 2 parameter you can adjust to fit your need, I haven't digging more detail. You can try and share you results.
Copy link to clipboard
Copied
The script has been refined here: