Flip image using command line

We often find it convenient to flip an image vertically or horizontally using a command line tool. Many programs can do this; we will give examples using ImageMagick and IrfanView.

In general, modifying an image in any way including cropping, flipping, rotating, etc. is a lossy process if the image compression algorithm used is lossy such as JPEG. Lossless compression formats such as PNG will remain lossless with this operation.

We assume the input image is named “in.png”, while the modified image will be written to “out.png”.

ImageMagick is a command-line oriented program available for just about any operating system including Windows, Mac and Linux. The order of the commands is important in ImageMagick.

Vertical flip the image by:

convert in.png -flip out.png

Horizontal flip the image by:

convert in.png -flop out.png

IrfanView has been popular for decades on Windows and WINE as a no-cost (not open source) image viewing and simple modification program that handles many formats. IrfanView can also be used from the command line under these conditions (we assume 64-bit Irfanview)

  1. install IrfanView directly, not via the Microsoft App Store.
  2. add to user PATH c:/Program Files/IrfanView

The order of the commands is important. These commands do not open the IrfanView GUI–they are “headless” operations. If there are spaces in the file paths, they must be enclosed in quotes like “c:/my pics/in.png”

Vertical flip the image by:

i_view64 in.png /vflip /convert=out.png

Horizontal flip the image by:

i_view64 in.png /hflip /convert=out.png