Search code examples
imageimagemagick

How to flip a dng image?


I need to flip 1400 dng images horizontally, eg along a vertical axis, so that left becomes right as in a mirror.

With imagemagick, it works well with tif images, using "magick convert -flop". But on dng, there is a tricky delegation issue because of an outdated dng lib.

Is there another way to do it or should I solve this delegation issue (this is a one-time need)? I feel that others would find helpful to find an documented alternative.

I have tried quite a few utilities (cli and gui, linux and windows) but none allows the flipped image to be saved as dng. In Digikam for example, the flip is only a flag, the pixels are not flipped. In others, one needs to save as tif or jpg.


Solution

  • I can't test this with your downstream processing software, and it may well ignore the flag I am setting, but here's what I have for what it's worth.

    If you use exiftool you can extract the "orientation" like this:

    exiftool -orientation  C02-322.dng 
    Orientation                     : Horizontal (normal)
    

    Or if you go numeric instead of interpreted:

    exiftool -n -orientation  C02-322.dng 
    Orientation                     : 1
    

    Then you can set the orientation. I set it to 2 or "mirrored horizontal" like this:

    exiftool -IFD0:Orientation#=2 C02-322.dng
    

    The values you can try are specified here.

    I then checked again with:

    exiftool -orientation  C02-322.dng
    Orientation                     : Mirror horizontal
    

    I have no idea whether your downstream processing will respect this. The modified version of the file is of identical length, so I guess all your existing DNG data has been carried forward correctly.