Home | History | Annotate | Download | only in script
      1 
      2 
      3 
      4 
      5 <!DOCTYPE html>
      6 <html lang="en">
      7 <head>
      8   <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4" />
      9     <title>ImageMagick: Encipher or Decipher an Image</title>
     10   <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
     11   <meta name="application-name" content="ImageMagick"/>
     12   <meta name="description" content="ImageMagick is a software suite to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats (over 200) including PNG, JPEG, JPEG-2000, GIF, WebP, Postscript, PDF, and SVG. Use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bzier curves."/>
     13   <meta name="application-url" content="http://www.imagemagick.org"/>
     14   <meta name="generator" content="PHP"/>
     15   <meta name="keywords" content="encipher, or, decipher, an, image, ImageMagick, PerlMagick, image processing, image, photo, software, Magick++, OpenMP, convert"/>
     16   <meta name="rating" content="GENERAL"/>
     17   <meta name="robots" content="INDEX, FOLLOW"/>
     18   <meta name="generator" content="ImageMagick Studio LLC"/>
     19   <meta name="author" content="ImageMagick Studio LLC"/>
     20   <meta name="revisit-after" content="2 DAYS"/>
     21   <meta name="resource-type" content="document"/>
     22   <meta name="copyright" content="Copyright (c) 1999-2015 ImageMagick Studio LLC"/>
     23   <meta name="distribution" content="Global"/>
     24   <meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1"/>
     25   <link rel="icon" href="../image/wand.png"/>
     26   <link rel="shortcut icon" href="../image/wand.ico"/>
     27   <link rel="stylesheet" href="../css/magick.php"/>
     28 </head>
     29 <body>
     30 <div class="main">
     31 <div class="magick-masthead">
     32   <div class="container">
     33     <script async="async" src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>    <ins class="adsbygoogle"
     34          style="display:block"
     35          data-ad-client="ca-pub-3129977114552745"
     36          data-ad-slot="6345125851"
     37          data-ad-format="auto"></ins>
     38     <script>
     39       (adsbygoogle = window.adsbygoogle || []).push({});
     40     </script>
     41     <nav class="magick-nav">
     42       <a class="magick-nav-item " href="../index.php">Home</a>
     43       <a class="magick-nav-item " href="binary-releases.php">Download</a>
     44       <a class="magick-nav-item " href="command-line-tools.php">Tools</a>
     45       <a class="magick-nav-item " href="command-line-processing.php">Command-line</a>
     46       <a class="magick-nav-item " href="resources.php">Resources</a>
     47       <a class="magick-nav-item " href="api.php">Develop</a>
     48       <a class="magick-nav-item " href="search.php">Search</a>
     49       <a class="magick-nav-item pull-right" href="http://www.imagemagick.org/discourse-server/">Community</a>
     50     </nav>
     51   </div>
     52 </div>
     53 <div class="container">
     54 <div class="magick-header">
     55 <p class="text-center"><a href="cipher.php#encipher">Encipher an Image</a>  <a href="cipher.php#decipher">Decipher an Image</a>  <a href="cipher.php#caveats">Encipher and Decipher Caveats</a></p>
     56 
     57 <p class="lead magick-description">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 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 passphrase, they will be unable to view the original content.</p>
     58 
     59 <p>You could use an <a href="http://www.wizards-toolkit.org/script/encipher.php">enciphering</a> 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.</p>
     60 
     61 <h2 class="magick-header"><a id="encipher"></a>Encipher an Image</h2>
     62 
     63 <p>Use the <a href="command-line-options.php#encipher">-encipher</a> option to scramble your image so that it is unrecognizable.  The option requires a filename that contains your passphrase.  In this example we scramble an image and save it in the PNG format:</p>
     64 
     65 <pre>
     66 convert rose.jpg -encipher passphrase.txt rose.png
     67 </pre>
     68 
     69 <p>Here we encipher an image using another image as the passphrase:</p>
     70 
     71 <pre>
     72 convert rose.jpg -encipher smiley.gif rose.png
     73 </pre>
     74 
     75 <h2 class="magick-header"><a id="decipher"></a>Decipher an Image</h2>
     76 
     77 <p>Use the <a href="command-line-options.php#decipher">-decipher</a> option to unscramble your image so that it is recognizable once again.  The option requires a filename that contains your passphrase.  In this example we unscramble an image and save it in the JPEG format:</p>
     78 
     79 <pre>
     80 convert rose.png -decipher passphrase.txt rose.jpg
     81 </pre>
     82 
     83 <h2 class="magick-header"><a id="caveats"></a>Encipher and Decipher Caveats</h2>
     84 
     85 <p>Some formats do not support enciphered pixels-- the JPEG or GIF format, for
     86 example.  To ensure your image format is supported, encipher a test image and
     87 verify you can restore its original content <var>before</var> you encipher any
     88 additional images in that format.</p>
     89 
     90 <p>The image format may only support 8-bit and RGB (TrueColor). As such you may
     91 like to include the options "-depth 8 -type TrueColor" before the output
     92 filename.</p>
     93 
     94 <p>The passphrase can be any combinations of letters and symbols.  It should
     95 be a minimum of 12 character combinations to help ensure your image remains
     96 private.  Also make sure your passphrase file permissions prevent others from
     97 reading it otherwise unintended users may be able to view the original image
     98 content.</p>
     99 
    100 <p>You can only restore the original image content if you know your
    101 passphrase.  If you lose or forget it, your original image content is lost
    102 forever.</p>
    103 
    104 <p>ImageMagick only scrambles the image pixels.  The image metadata remains
    105 untouched and readable by anyone with access to the image file.</p>
    106 
    107 <p>ImageMagick uses the <a
    108 href="http://en.wikipedia.org/wiki/Advanced_Encryption_Standard">AES</a>
    109 cipher in Counter mode.  We use the the first half of your passphrase to derive the nonce.  The second half is the cipher key. When used correctly, AES-CTR provides a high level of confidentiality. To avoid information leaks, you must use a fresh passphrase for each image your encrypt.</p>
    110 
    111 <p>Currently only ImageMagick can restore your enciphered image content.  We
    112 use a standard cipher and mode so other vendors are could support enciphered image content.</p>
    113 
    114 <p>Some small practical examples of image enciphering can be found in IM
    115 Examples <a href="http://www.imagemagick.org/Usage/transform/#encipher"
    116 >Encrypting Image Data</a>. </p>
    117 
    118 </div>
    119   <footer class="magick-footer">
    120     <p><a href="support.php">Donate</a> 
    121      <a href="sitemap.php">Sitemap</a> 
    122     <a href="links.php">Related</a> 
    123     <a href="architecture.php">Architecture</a>
    124 </p>
    125     <p><a href="cipher.php#">Back to top</a> 
    126     <a href="http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x89AB63D48277377A">Public Key</a> 
    127     <a href="contact.php">Contact Us</a></p>
    128         <p><small>  1999-2016 ImageMagick Studio LLC</small></p>
    129   </footer>
    130 </div><!-- /.container -->
    131 
    132   <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    133   <script src="http://nextgen.imagemagick.org/js/magick.php"></script>
    134 </div>
    135 </body>
    136 </html>
    137