ImageMagick: Encipher or Decipher an Image
Author: ImageMagick Studio LLC
Description: ImageMagick® is a software suite to create, edit, and compose bitmap images. It can read, convert and write images in a variety of formats (about 100) including GIF, JPEG, JPEG-2000, PNG, PDF, PhotoCD, TIFF, and DPX. Use ImageMagick to translate, flip, mirror, rotate, scale, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves. ImageMagick is free software delivered as a ready-to-run binary distribution or as source code that you can freely use, copy, modify, and distribute. Its license is compatible with the GPL. It runs on all major operating systems. The functionality of ImageMagick is typically utilized from the command line or you can use the features from programs written in your favorite programming language. Choose from these interfaces: MagickCore (C), MagickWand (C), ChMagick (Ch), Magick++ (C++), JMagick (Java), L-Magick (Lisp), PascalMagick (Pascal), PerlMagick (Perl), MagickWand for PHP (P [cell cut: 1167 characters, first 1000 kept]
Keywords: encipher, or, decipher, an, image, ImageMagick, ImageMagic, MagickCore, MagickWand, PerlMagick, Magick++, RMagick, PythonMagick, JMagick, TclMagick, Image, Magick, Magic, Wand, ImageMagickObject

## Introduction to Enciphering and Deciphering Images Most images, by design, are made to be viewed often and by many people. Web images, for example, may be viewed hundreds of times a day by a multitude of web vistors. However, in some cases, you may want to keep a particular image private so that only you or perhaps a select group of your friends or web visitors can view it. ImageMagick permits you to scramble your images such that unless someone knows your secret key, they will be unable to view the original content. You could use an enciphering utility to scramble your image but they typically scramble the entire file making it unrecognizable as an image format. With ImageMagick, only the pixels are scrambled. The scrambled image continues to be recognized as an image and will even display in your web page. However, the content appears as gibberish, nothing like the original content. ## Encipher an Image Use the -encipher option to scramble your image so that it is unrecognizable. The option requires a filename that contains your secret key. In this example we scramble an image and save it in the PNG format:
      convert rose.jpg -encipher passphrase.txt rose.png
Here we encipher an image using another image as the passphrase:
      convert rose.jpg -encipher smiley.gif rose.png
## Decipher an Image Use the -decipher option to unscramble your image so that it is recognizable once again. The option requires a filename that contains your secret key. In this example we unscramble an image and save it in the JPEG format:
      convert rose.png -decipher passphrase.txt rose.jpg
## Encipher and Decipher Caveats Some formats do not support enciphered pixels-- the JPEG or GIF format, for example. To ensure your image format is supported, encipher a test image and verify you can restore its original content before you encipher any additional images in that format. The passphrase can be any combinations of letters and symbols. It should be a minimum of 12 character combinations to ensure your image remains private. Also make sure your passphrase file permissions prevent others from reading it otherwise unintended users may be able to view the original image content. You can only restore the original image content if you know your passphrase. If you lose or forget it, your original image content is lost forever. ImageMagick only scrambles the image pixels. The image metadata remains untouched and readable by anyone with access to the image file. ImageMagick uses the AES cipher in cipher feedback mode. We use the passphrase to derive the cipher key and the required nonce. Currently only ImageMagick can restore your enciphered image content. We use a standard cipher and mode so other vendors are encouraged to support enciphered image content. Support for enciphering and deciphering image pixels is not enabled by default. To enable it, use this Unix/Linux command:
      ./configure --enable-cipher
Under Windows, set the `MAGICKCORE_CIPHER_SUPPORT` definition in the `magick-config.h` configuration file and build. |

Discourse Server • Mailing Lists • Cafe • Studio