On Friday, 18 September 2020 14:58:59 BST tastytea wrote:
> On 2020-09-18 13:32+0000 Alan Mackenzie <a...@muc.de> wrote:
> > Hello, Gentoo!
> > 
> > I've a number of jpeg files, 17 to be precise, which are high
> > resolution and are around 3½ megabytes each.  I would like to
> > compress them down to around 100 kb each.
> > 
> > I'm sure this is possible, if tedious, in gimp, somehow, but I can't
> > for the life of me work out how (since it's years since I last did
> > this).
> > 
> > What is the best way (minimal learning, scriptable if possible), to do
> > this?
> 
> I'm not aware of a way that allows you to specify a file size, but you
> can use convert from media-gfx/imagemagick to re-compress and/or resize
> the files. For example:
> 
> convert -quality 50 in.jpg out.jpg
> convert -resize 1000 in.jpg out.jpg
> 
> The last command makes the image 1000px wide and sets the height
> automatically to the right value.
> 
> Hope this helps,
> tastytea

I would also recommend convert, which can be scripted to run in a directory 
and compress all jpeg files therein to a lower resolution.  Something like 
this ought to do the job:

#!/bin/bash
for i in *.jpg; do
  name=${i%.jpg}
  convert -compress JPEG -quality 95 ${i} ${name}_compressed.jpg
done

You'll need to adjust the -quality parameter to your liking.

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to