I had a series of images taken with a camera that needed to be sent via email. The pictures were stored in rather large jpeg files. Each file was between 1.5 and 3MB. To avoid Gmail's size limits (25MB at the time of writing), and a long wait while the files were uploaded, I decided to try to compress the files to a maximum of 400K each, even if that meant giving up some of the quality. The solution is, of course, to use Imagemagick, the Swiss army knife of image processing. If you don't have it yet, you should install it. In Ubuntu:
sudo apt-get install imagemagickFor simple conversion jobs, Imagemagick's convert program is very easy to use: it figures out the desired conversion by the suffixes of the argument file names:
convert scanned-text.jpg scanned-text.pdfwill work as expected. So, to do what I wanted, all I needed was the correct option to tell convert that it needed to reduce the file size of the image:
convert image.jpg some-option image-small.jpgUnfortunately, there are a lot of options. To save you searching, here's the one that did the job:
convert image.jpg -define jpg:extent=400KB image-small.jpgAnd on the screen, there was no noticeabe loss of quality in the smaller versions of the image files.
No comments:
Post a Comment