Thursday, January 21, 2016

Resizing a bunch of pictures

I want to upload some of my pictures to some social network. But all of them have big resolution, and so will take a long time to upload. Besides, some time I need to save storage space.

Again, I can use Gimp for that. But when you have 200 pics, or even much more Gimp is not a good option. Let's see how we can get this done easily in command line.

You need:
  • The software graphicsmagick installed (sudo aptitude install graphicsmagick)
  • A directory with your original pictures
  • A directory for your signed pictures
For this example, consider that:

  • My pictures are in ~/Pictures/Lake
  • My resized pictures will be at ~/Pictures/Lake/Small 
  • All my original pictures have an extension .jpg.
This task is resolved with this simple CLI instruction:

for i in $(ls ~/Pictures/Lake/*.jpg) ; do echo $i; gm convert -resize 30% "${i}" "$(dirname ${i})/Small/$(basename ${i})" ; done

Note that my result will be pictures 30% of the original, and with the same name. After this, view the results and make the pictures bigger or smaller.

See the results of my example:
Compare the size of both files


If this post may be useful to you, please "Like" it and share it.

No comments: