Compress Image with FFmpeg
FFmpeg is a powerful tool to process video and audio files.
It can also be used to compress images.
FFmpeg uses mjpeg as the default codec for JPEG.
ffmpeg -i input.jpg -q:v 1 -vf scale=320:-1 output.jpg
-qscale:v 1means the quality of the output image is 1/31. The smaller the number, the better the quality.
1is the best quality,
31is the worst quality.
-vf scale=320:-1means the output image is scaled to 320px width, and the height is automatically calculated.