Home | History | Annotate | Download | only in www
      1 
      2 
      3 
      4 
      5 <!DOCTYPE html>
      6 <html lang="en">
      7 <head>
      8     <title>ImageMagick: Color Management</title>
      9   <meta charset="utf-8" />
     10   <meta http-equiv="X-UA-Compatible" content="IE=edge" />
     11   <meta name="viewport" content="width=device-width, initial-scale=1" />
     12   <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
     13   <meta name="application-name" content="ImageMagick"/>
     14   <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."/>
     15   <meta name="application-url" content="http://www.imagemagick.org"/>
     16   <meta name="generator" content="PHP"/>
     17   <meta name="keywords" content="color, management, ImageMagick, PerlMagick, image processing, image, photo, software, Magick++, OpenMP, convert"/>
     18   <meta name="rating" content="GENERAL"/>
     19   <meta name="robots" content="INDEX, FOLLOW"/>
     20   <meta name="generator" content="ImageMagick Studio LLC"/>
     21   <meta name="author" content="ImageMagick Studio LLC"/>
     22   <meta name="revisit-after" content="2 DAYS"/>
     23   <meta name="resource-type" content="document"/>
     24   <meta name="copyright" content="Copyright (c) 1999-2016 ImageMagick Studio LLC"/>
     25   <meta name="distribution" content="Global"/>
     26   <meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1"/>
     27   <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4" />
     28   <link rel="icon" href="../images/wand.png"/>
     29   <link rel="shortcut icon" href="../images/wand.ico"/>
     30   <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Roboto:900,400,400italic,700,700italic,300,300italic|Open+Sans:300italic,400italic,700italic,300,400,600,700">
     31   <link rel="stylesheet" href="css/magick.css"/>
     32 </head>
     33 <body>
     34 <div class="main">
     35 <div class="magick-masthead">
     36   <div class="container">
     37     <script async="async" src="http://localhost/pagead/js/adsbygoogle.js"></script>    <ins class="adsbygoogle"
     38          style="display:block"
     39          data-ad-client="ca-pub-3129977114552745"
     40          data-ad-slot="6345125851"
     41          data-ad-format="auto"></ins>
     42     <script>
     43       (adsbygoogle = window.adsbygoogle || []).push({});
     44     </script>
     45     <nav class="magick-nav">
     46       <a class="magick-nav-item " href="../index.html">Home</a>
     47       <a class="magick-nav-item " href="binary-releases.html">Download</a>
     48       <a class="magick-nav-item " href="command-line-tools.html">Tools</a>
     49       <a class="magick-nav-item " href="command-line-processing.html">Command-line</a>
     50       <a class="magick-nav-item " href="resources.html">Resources</a>
     51       <a class="magick-nav-item " href="api.html">Develop</a>
     52       <a class="magick-nav-item " href="http://www.imagemagick.org/script/search.php">Search</a>
     53       <a class="magick-nav-item pull-right" href="https://www.imagemagick.org/discourse-server/">Community</a>
     54     </nav>
     55   </div>
     56 </div>
     57 <div class="container">
     58 <div class="magick-header">
     59 
     60 <p class="lead magick-description">Color management has changed significantly between ImageMagick version 6.7.5-5 and 6.8.0-3 in order to better conform to color and grayscale standards.</p>
     61 
     62 <p>The first major change was to swap -colorspace RGB and -colorspace sRGB. In earlier versions, RGB really meant non-linear sRGB. With the completion of the changes, RGB now means linear color and sRGB means non-linear color in terms of their respective colorspaces.</p>
     63 
     64 <p>ImageMagick supports color profiles, however, for images without a profile or a declaration of colorspace, ImageMagick assumes non-linear sRGB.  Most image processing algorithms assume a linear colorspace, therefore it might be prudent to convert to linear color or remove the gamma function before certain image processing algorithms are applied. For example,</p>
     65 
     66 <pre>
     67 convert myimage.jpg -colorspace RGB -resize 200% -colorspace sRGB mybigimage.jpg
     68 </pre>
     69 
     70 <p>To declare that an image is linear RGB rather than sRGB, you can use the set option:</p>
     71 
     72 <pre>
     73 convert myimage.png -set colorspace RGB myRGBimage.png
     74 </pre>
     75 
     76 <p>Afterwards, the verbose information for the output file lists the colorspace as RGB. This only works on image types containing meta data that distinguishes between linear RGB and non-linear sRGB, such as PNG and GIF. Therefore, if the above command is run with a JPG or TIF output format, the verbose information for the colorspace still shows sRGB. In order to properly have the JPG output know that it is linear RGB, include an appropriate color profile.</p>
     77 
     78 
     79 <p>The second major change treats any grayscale image as linear rather than non-linear, as it was previously.  This change is appropriate, since many types of processing requires a linear colorspace. This means that the conversion of a color image to grayscale via <code>-colorspace gray</code> looks darker relative to previous versions of ImageMagick (note that desaturating to convert to grayscale does not convert the image to linear grayscale). If you prefer to keep the conversion to non-linear grayscale, set the colorspace of the input to linear RGB so that <code>-colorspace gray</code> does not apply the gamma correction during the conversion process. For example, the following produces a non-linear grayscale result.</p>
     80 
     81 <pre>
     82 convert myimage.png -set colorspace RGB -colorspace gray myRGBimage.png
     83 </pre>
     84 
     85 <p>The same concept is needed when separating channels. Normally, the conversion to separate each channel of an sRGB color image produces separate linear grayscale images. However the same concept can be applied, if it is desired to keep the separate channels as non-linear grayscale. For example, the following produces non-linear grayscale channels.</p>
     86 
     87 <pre>
     88 convert myimage.png -set colorspace RGB -separate myimage_channels_%d.png
     89 </pre>
     90 
     91 <p>When separating and recombining channels, with potential intermediate processing, it is important to identify the colorspace used, especially during the recombination. For example,</p>
     92 
     93 <pre>
     94 convert myimage.png -separate myimage_channels_%d.png
     95 convert myimage_channels_*.png -combine myimage2.png
     96 </pre>
     97 
     98 <p>In the above example, the result is darker than the original, because the channels were separate as linear gray and subsequently combined as linear color. In order to return the channels back to sRGB, one must change the colorspace from RGB back to sRGB after the <code>-combine</code> step.</p>
     99 
    100 <pre>
    101 convert myimage.png -separate myimage_channels_%d.png
    102 convert myimage_channels_*.png -combine -colorspace sRGB myimage2.png
    103 </pre>
    104 
    105 <p>If one desires to separate to non-linear grayscale channels, recombine them later, perhaps after some processing, then use the same concept as above for maintaining non-linear grayscale:</p>
    106 
    107 <pre>
    108 convert myimage.png -set colorspace RGB -separate myimage_channels_%d.png
    109 convert myimage_channels_*.png -combine -colorspace RGB -set colorspace sRGB myimage2.png
    110 </pre>
    111 
    112 <p>When converting to another colorspace and back, such as between sRGB and HSL, the following two commands handle the first case of linear channels and the second case of non-linear channels:</p>
    113 
    114 <pre>
    115 convert myimage.png -colorspace HSL -separate myimage_channels_%d.png
    116 convert myimage_channels_*.png -set colorspace HSL -combine -colorspace sRGB myimage2.png
    117 </pre>
    118 
    119 <pre>
    120 convert myimage.png -set colorspace RGB -colorspace HSL -separate myimage_channels_%d.png
    121 convert myimage_channels_*.png -set colorspace HSL -combine -colorspace RGB -set colorspace sRGB myimage2.png
    122 </pre>
    123 
    124 <p>A majority of the image formats assume an sRGB colorspace (e.g. JPEG, PNG, etc.). A few support only linear RGB (e.g. EXR, DPX, CIN, HDR) or only linear GRAY (e.g. PGM). A few formats support CMYK. For example JPG does, but PNG does not. Then there is the occasional format that also supports LAB (that is CieLAB) (e.g. TIFF, PSD, JPG, JP2). For additional information, see the <a href="formats.html#colorspace" >Colorspace</a> and <a href="formats.html#supported" >Supported Formats</a> pages.</p>
    125 
    126 <p>When specifying individual colors as <code>rgb(...)</code> or hex, these colors will still be interpreted as non-linear, that is, as sRGB colors. However if one wants to create linear colors, use <code>icc-color(rgb,r,g,b)"</code>, where <code>r</code>, <code>g</code>, and <code>b</code> are in the range 0 to 1. See the <a href="color.html" >Color</a> page.</p>
    127 
    128 <p>There are now also distinctions between linear and non-linear shades of gray. Any named shade of gray, such as black, white or numbered grays like <code>gray50</code> are non-linear gray. However, <code>gray(...)</code> is now linear gray. Hex grayscale values are non-linear.</p>
    129 
    130 <p>This means that you need to be careful when you create grayscale gradients. For example, <code>gradient:</code>, <code>gradient:"white-black"</code>, <code>gradient:"gray100-gray0"</code> generates non-linear gradients, however <code>gradient:"gray(255)-gray(0)"</code> or <code>gradient:"gray(100%)-gray(0%)"</code> generates linear gradients.</p>
    131 
    132 </div>
    133   <footer class="magick-footer">
    134     <p><a href="support.html">Donate</a> 
    135      <a href="sitemap.html">Sitemap</a> 
    136     <a href="links.html">Related</a> 
    137     <a href="architecture.html">Architecture</a>
    138 </p>
    139     <p><a href="color-management.html#">Back to top</a> 
    140     <a href="http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x89AB63D48277377A">Public Key</a> 
    141     <a href="http://www.imagemagick.org/script/contact.php">Contact Us</a></p>
    142         <p><small>  1999-2016 ImageMagick Studio LLC</small></p>
    143   </footer>
    144 </div><!-- /.container -->
    145 
    146   <script src="https://localhost/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    147   <script src="../js/magick.html"></script>
    148 </div>
    149 </body>
    150 </html>
    151