How to batch flip images on Linux using ImageMagick

247

Sometimes you’ll have to flip photos taken from the front camera of your phone to make them look normal, especially when there is mirror text in them. Flipping a number of such images one by one is not fun at all. This tutorial will show you how to batch flip image files horizontally and vertically on Linux using a command-line tool named ImageMagick.

Installing ImageMagick

Install the package named imagemagick in your system using the command below. If you aren’t using Debian or Ubuntu, make sure to have it installed properly from your distro’s repo.

sudo apt-get update
sudo apt-get install imagemagick

Batch flipping images horizontally

Go to the directory where the images file you want to flip are located in, and create an output directory for the output images.

mkdir output

Use the following command to batch flip all the JPG image files in the directory horizontally. Note that the option is named -flop. Feel free to adjust the command to match the file extension.

mogrify -path output -flop *.jpg

Batch flipping images vertically

Go to the directory where the images file you want to flip are located in, and create an output directory for the output images.

mkdir output

Use the following command to batch flip all the JPG image files in the directory vertically. Feel free to adjust the command to match the file extension.

mogrify -path output -flip *.jpg