I'm trying to generate images thumbnails using ffmpeg. The folder contains various jpeg files with different resolutions.
ffmpeg -y -i input1.jpg -filter_complex "scale=(iw*sar)*max(238/(iw*sar)\,358/ih):ih*max(238/(iw*sar)\,358/ih), crop=238:358" thumbnail.jpg
It works with most images in the folder but crop=238:358
will fail depending on certain images resolutions:
input1.jpg: 500x800
resize and crop successful
input2.jpg: 470x800
resize and crop fails:
Invalid too big or non positive size for width '238' or height '358'
The problem happens when scaled images get 237px
instead of 238px
due to aspect ratio scaling.
Since this is a script processing a bunch of files, I'm looking for a solution that can handle all images resolutions