What I want to do is very simple. I've a file.png, which I want to mirror, i.e. the result should be a "reflection" of the original image.

I know big tools like GIMP and InkScape can do that, but I'm hoping for a command-line utility, something like convert (which sadly doesn't seem to have such an option, or at least it's not mentioned in the man page).

3 Answers 3


From quick reading of this, apparently convert calls this option -flop for horizontal mirroring, and -flip for vertical. All I needed to do was

convert -flop input.png output.png
  • 2
    sudo apt-get install imagemagick Jul 7, 2018 at 12:15
  • I have read something about changing convert to magick. So if something goes wrong, try magick.
    – Sigur
    Jul 7, 2018 at 21:10
  • If you get error magick.exe: no images found for operation -flop at CLI arg 1 @ error/operation.c/CLIOption/5353., try magick input.png -flop output.png. It works for me. Thanks. Nov 1, 2021 at 8:45

If you want to overwrite in-place and you have a ton of image files in the same folder, mogrify from the ImageMagick suite seems to be the easiest way to achieve this:

# mirror in the vertical axis:
mogrify -flip *.jpg

# mirror in the horizontal axis:
mogrify -flop *.jpg
  • Note that mirroring horizontally (flopping) is actually reflecting in a vertical plane and mirroring vertically (flipping) is reflecting in a horizontal plane. Nov 12, 2022 at 0:34

For this particular task convert is probably the best way to go, but for this kind of thing I often use the netpbm library, which is installable (as you would expect) with apt install netpbm. Then

  pngtopnm input.png | pnmflip -lr \
    | (other transformations if desired) \  
    | pnmtopng > output.png

For this task it's overkill, but I often find myself writing one-off scripts to transform or analyze PNM files in peculiar ways that wouldn't be available in convert. This is relatively easy, because PNM is pretty much the simplest imaginable bitmap graphic format.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .