blob: 5e718a74ec81663af6c65126efc9dc9dd67880ae [file] [log] [blame]
cristyd2432012015-05-04 23:15:15 +00001<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2<html lang="en">
cristyad41c0c2012-10-31 00:49:28 +00003<head>
cristyd2432012015-05-04 23:15:15 +00004 <meta charset="utf-8">
5 <meta http-equiv="X-UA-Compatible" content="IE=edge">
6 <meta name="viewport" content="width=device-width, initial-scale=1">
cristyffb69ed2010-12-25 00:06:48 +00007 <title>ImageMagick: Encipher or Decipher an Image</title>
cristyd2432012015-05-04 23:15:15 +00008 <meta http-equiv="content-language" content="en-US">
9 <meta http-equiv="content-type" content="text/html; charset=utf-8">
10 <meta http-equiv="reply-to" content="magick-users@imagemagick.org">
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 Bézier 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-2012 ImageMagick Studio LLC">
23 <meta name="distribution" content="Global">
24 <link rel="icon" href="../images/wand.png">
25 <link rel="shortcut icon" href="../images/wand.ico" type="images/x-icon">
26 <link rel="stylesheet" href="www/css/bootstrap.min.css">
27 <link rel="stylesheet" href="www/css/magick.css">
cristyad41c0c2012-10-31 00:49:28 +000028</head>
29
cristyd2432012015-05-04 23:15:15 +000030<body>
cristyad41c0c2012-10-31 00:49:28 +000031<div class="main">
cristyd2432012015-05-04 23:15:15 +000032<div class="magick-masthead">
33 <div class="container">
34 <script type="text/javascript">
35 <!--
36 google_ad_client = "pub-3129977114552745";
37 google_ad_slot = "5439289906";
38 google_ad_width = 728;
39 google_ad_height = 90;
40 //-->
41 </script>
42 <center><script type="text/javascript" src="http://localhost/pagead/show_ads.js">
43 </script></center>
44 <nav class="magick-nav">
45 <a class="magick-nav-item " href="http://www.imagemagick.org/ImageMagick-7.0.0/index.html">Home</a>
46 <a class="magick-nav-item " href="binary-releases.html">Downloads</a>
47 <a class="magick-nav-item " href="command-line-tools.html">Tools</a>
48 <a class="magick-nav-item " href="command-line-options.html">Options</a>
49 <a class="magick-nav-item " href="api.html">Development</a>
50 <a class="magick-nav-item" href="../discourse-server">Community</a>
51 <a class="magick-nav-item navbar-right " href="search.html">Search</a>
52 </nav>
53 </div>
54</div>
55<div class="container">
56<div class="magick-header">
57<p class="text-center"><a href="cipher.html#encipher">Encipher an Image</a><a href="cipher.html#decipher">Decipher an Image</a><a href="cipher.html#caveats">Encipher and Decipher Caveats</a></p>
cristyad41c0c2012-10-31 00:49:28 +000058
cristyd2432012015-05-04 23:15:15 +000059<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>
cristy3ed852e2009-09-05 21:47:34 +000060
61<p>You could use an <a href="http://www.wizards-toolkit.org/www/encipher.html">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>
62
cristyd2432012015-05-04 23:15:15 +000063<h2 class="magick-header"><a id="encipher"></a>Encipher an Image</h2>
cristy3ed852e2009-09-05 21:47:34 +000064
cristy751980d2012-06-03 23:18:35 +000065<p>Use the <a href="command-line-options.html#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>
cristy3ed852e2009-09-05 21:47:34 +000066
cristyd2432012015-05-04 23:15:15 +000067<p class="crt"><span class="crtprompt"> $magick&gt; </span><span class="crtin">convert rose.jpg -encipher passphrase.txt rose.png</span></p>
cristybebec402010-04-23 19:19:08 +000068<p>Here we encipher an image using another image as the passphrase:</p>
cristy3ed852e2009-09-05 21:47:34 +000069
cristyd2432012015-05-04 23:15:15 +000070<p class="crt"><span class="crtprompt"> $magick&gt; </span><span class="crtin">convert rose.jpg -encipher smiley.gif rose.png</span></p>
71<h2 class="magick-header"><a id="decipher"></a>Decipher an Image</h2>
cristy3ed852e2009-09-05 21:47:34 +000072
cristy751980d2012-06-03 23:18:35 +000073<p>Use the <a href="command-line-options.html#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>
cristy3ed852e2009-09-05 21:47:34 +000074
cristyd2432012015-05-04 23:15:15 +000075<p class="crt"><span class="crtprompt"> $magick&gt; </span><span class="crtin">convert rose.png -decipher passphrase.txt rose.jpg</span></p>
76<h2 class="magick-header"><a id="caveats"></a>Encipher and Decipher Caveats</h2>
cristy3ed852e2009-09-05 21:47:34 +000077
cristyd0bda5e2010-09-21 16:22:45 +000078<p>Some formats do not support enciphered pixels-- the JPEG or GIF format, for
79example. To ensure your image format is supported, encipher a test image and
cristyd2432012015-05-04 23:15:15 +000080verify you can restore its original content <var>before</var> you encipher any
cristyd0bda5e2010-09-21 16:22:45 +000081additional images in that format.</p>
cristy3ed852e2009-09-05 21:47:34 +000082
cristy8ee7f242013-06-20 16:08:44 +000083<p>The image format may only support 8-bit and RGB (TrueColor). As such you may
cristyd0bda5e2010-09-21 16:22:45 +000084like to include the options "-depth 8 -type TrueColor" before the output
cristy8ee7f242013-06-20 16:08:44 +000085filename.</p>
cristy3ed852e2009-09-05 21:47:34 +000086
cristyd0bda5e2010-09-21 16:22:45 +000087<p>The passphrase can be any combinations of letters and symbols. It should
88be a minimum of 12 character combinations to help ensure your image remains
89private. Also make sure your passphrase file permissions prevent others from
90reading it otherwise unintended users may be able to view the original image
91content.</p>
cristy3ed852e2009-09-05 21:47:34 +000092
cristyd0bda5e2010-09-21 16:22:45 +000093<p>You can only restore the original image content if you know your
94passphrase. If you lose or forget it, your original image content is lost
95forever.</p>
cristy3ed852e2009-09-05 21:47:34 +000096
cristyd0bda5e2010-09-21 16:22:45 +000097<p>ImageMagick only scrambles the image pixels. The image metadata remains
98untouched and readable by anyone with access to the image file.</p>
cristy3ed852e2009-09-05 21:47:34 +000099
cristyd2432012015-05-04 23:15:15 +0000100<p>ImageMagick uses the <a href="http://en.wikipedia.org/wiki/Advanced_Encryption_Standard">AES</a>
cristy8ee7f242013-06-20 16:08:44 +0000101cipher 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>
cristyd0bda5e2010-09-21 16:22:45 +0000102
103<p>Currently only ImageMagick can restore your enciphered image content. We
cristy8ee7f242013-06-20 16:08:44 +0000104use a standard cipher and mode so other vendors are could support enciphered image content.</p>
cristyd0bda5e2010-09-21 16:22:45 +0000105
106<p>Some small practical examples of image enciphering can be found in IM
cristyd2432012015-05-04 23:15:15 +0000107Examples <a href="http://www.imagemagick.org/Usage/transform/#encipher">Encrypting Image Data</a>. </p>
cristy3ed852e2009-09-05 21:47:34 +0000108
cristybebec402010-04-23 19:19:08 +0000109</div>
cristyd2432012015-05-04 23:15:15 +0000110 <footer class="magick-footer">
111 <div class="magick-nav-item navbar-left">
112 <a href="support.html">Donations</a>
113 </div>
114 <div class="magick-nav-item navbar-right">
115 <a class="FlattrButton" style="display:none;" rev="flattr;button:compact;" href="http://www.imagemagick.org/"></a>
116 <noscript>
117 <a href="http://flattr.com/thing/947300/Convert-Edit-And-Compose-Images" target="_blank">
118 <img src="http://api.flattr.com/button/flattr-badge-large.png" alt="Flattr this" title="Flattr this" border="0"></a>
119 </noscript>
120 </div>
121 <p><a href="sitemap.html">Sitemap</a>
122 <a href="links.html">Related</a>
123 <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Image Studio</a>
124 <a href="http://jqmagick.imagemagick.org/">JqMagick</a>
125 <a href="http://pgp.mit.edu:11371/pks/lookup?op=get&amp;search=0x89AB63D48277377A">Public Key</a>
126</p>
127 <p><a href="cipher.html#">Back to top</a>
128 <a href="contact.html">Contact Us</a></p>
129 </footer>
130</div><!-- /.container -->
cristyad41c0c2012-10-31 00:49:28 +0000131
cristyd2432012015-05-04 23:15:15 +0000132 <script src="https://localhost/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
133 <script src="../js/bootstrap.min.js"></script>
134 <script type="text/javascript">
135 /* */
136 (function() {
137 var s = document.createElement('offline-script'), t = document.getElementsByTagName('offline-script')[0];
138 s.type = 'text/javascript';
139 s.async = true;
140 s.src = 'http://api.flattr.com/js/0.6/load.js?mode=auto';
141 t.parentNode.insertBefore(s, t);
142 })();
143 /* */
144 </script>
cristyad41c0c2012-10-31 00:49:28 +0000145</div>
cristyad41c0c2012-10-31 00:49:28 +0000146</body>
147</html>