Ceci est une ancienne révision du document !
Have you ever taken a large number of “portrait” orientation images, say of buildings, people or sailboats, and then once you downloaded them realized you would have to rotate all of them, perhaps hundreds of images? It can be done one-at-a-time with an image editor, like GIMP or mtPaint, or even in some image viewers, but it is a slow process. Some image viewers strip out Exif metadata, reduce the file resolution, or make other changes that may not be desired.
I recently had a large number of images to rotate 90 degrees and searched for a better way to do it. I found imgp (Image Processor), a Linux command line program that does the job quickly and efficiently.
Imgp was first written by SZ Lin at Debian and is now developed by Arun Prakash Jana and Ananya Jana of Rutgers University. It is free software, released under the GPL 3.0.
Imgp is a tiny program, written in Python. The download is only 13.9 kb and it takes up just 41.0 kb when installed. There have been nine public releases of imgp, starting with version 1.0 on 16 August 2016. It is packaged for Arch, Debian, Fedora, OpenSUSE, Raspbian, Slackware, Ubuntu and Void Linux and is available for Macs, through “homebrew”.
Despite its small size, imgp has some serious capabilities. It can rotate images to a specified angle, resize images to a fixed size or percentage, and convert PNG files to JPG format. It can also work recursively, changing all image files in a directory, including all its sub-directories. It can also strip out Exif metadata if desired.
Many new Linux users are intimidated by command line programs, but this one is simple to use and the home website provides a complete guide, including easy examples.
In testing the program I found that because I usually take some photos in “portrait” mode, which I want to rotate, and some in “landscape” mode, which I don’t want to rotate, the easiest way is to copy the images to be rotated into a new directory and then copy them back when done. Because I use a fixed named directory for that, called “rotate”, the command is always the same and can be just called up in the terminal with the “up arrow” key. This pretty much eliminates mistakes and also means you don’t have to memorize the command line syntax. I similarly use a directory named “shrink” for images to be reduced.
Here is an example of the command to rotate all the images in the directory named “rotate” to the left 90 degrees (which is right 270 degrees) (-o 270), recursively (-r) and overwrite (-w) the images with the newly rotated ones:
$ imgp -o 270 -r -w ~/rotate
This is an example of the command to resize all the images in the directory named “shrink”by 75% (-x 75), recursively (-r) and overwrite (-w) the images with the newly rotated ones:
$ imgp -x 75 -r -w ~/shrink
Hit “return” and it is done in mere seconds.
In my testing the only disadvantage to imgp is that rotating images is “lossy”, meaning that the file sizes are reduced in the process. This loss can be reduced to a minimum by setting the image “quality” to 95% (-q 95).
Imgp is hard to improve upon. It works very well and saves a lot of time in rotating or resizing large numbers of images manually using an image editor. It can be installed from the Ubuntu repositories, where it is found under “imgp”.
Home page: https://github.com/jarun/imgp