Regular expression to determine ratio image with conditions
Posted: Thu Oct 24, 2019 11:23 am
Hello,
I need a little help if it is possible to do this :
- Have a flow that check orientation of images : landscape or portrait then resize homothetic image to specific dimension for Magento webfile : 1000x1640 px for portrait, or 1640x1000 px for landscape orientation
Condition : width < height => portrait then resize height to 1640 px, and crop center width to 1000 px
or width > height => landscape then resize width to 1000 px, and crop center height to 1640 px
Sometimes have images that ratio is not compatible with output format :
image is portrait orientation but the width is too small so I cannot use the script to crop for portrait dimension, but use the landscape setting.
for example have this image 3129x6569 px
width<height so portrait, resize 6569 px to 1640, ok but the width is 804 px... so I can't have 1000x1640 px
In fact, I have to ensure that ratio width/height is superior than 60% in my case.If not, first resize the width than crop center the height.
My flow works great to determine orientation, resize and crop center, I just need help to specify condition to the connector : is there a way to have a connection with a regular expression can do it ? but I didn't know how to write this condition in regex : width/height>60%
or if it is possible to do it
Best Regards,
Christian
I need a little help if it is possible to do this :
- Have a flow that check orientation of images : landscape or portrait then resize homothetic image to specific dimension for Magento webfile : 1000x1640 px for portrait, or 1640x1000 px for landscape orientation
Condition : width < height => portrait then resize height to 1640 px, and crop center width to 1000 px
or width > height => landscape then resize width to 1000 px, and crop center height to 1640 px
Sometimes have images that ratio is not compatible with output format :
image is portrait orientation but the width is too small so I cannot use the script to crop for portrait dimension, but use the landscape setting.
for example have this image 3129x6569 px
width<height so portrait, resize 6569 px to 1640, ok but the width is 804 px... so I can't have 1000x1640 px
In fact, I have to ensure that ratio width/height is superior than 60% in my case.If not, first resize the width than crop center the height.
My flow works great to determine orientation, resize and crop center, I just need help to specify condition to the connector : is there a way to have a connection with a regular expression can do it ? but I didn't know how to write this condition in regex : width/height>60%
or if it is possible to do it
Best Regards,
Christian