- ffmpeg -i #{uri_or_path} -f lavfi -i color=c=white \
- -filter_complex "[0:v] scale='min(#{max_width},iw)':'min(#{max_height},ih)': \
- force_original_aspect_ratio=decrease [scaled]; \
- [1][scaled] scale2ref [bg][img]; [bg] setsar=1 [bg]; [bg][img] overlay=shortest=1" \
- -loglevel quiet -f image2 -vcodec mjpeg -frames:v 1 -q:v #{quality} pipe:1