1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="-//W3C//DTD XHTML 1.1//EN" xml:lang="en" xsi:schemaLocation="http://www.w3.org/1999/xhtml http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd">
4 <meta http-equiv="content-type" content="text/html; charset=UTF-8"></meta>
5 <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4"></meta>
6 <title>ImageMagick: Format and Print Image Properties</title>
7 <meta http-equiv="content-language" content="en-US"></meta>
8 <meta http-equiv="content-type" content="text/html; charset=utf-8"></meta>
9 <meta http-equiv="reply-to" content="magick-users@imagemagick.org"></meta>
10 <meta name="application-name" content="ImageMagick"></meta>
11 <meta name="description" content="Use ImageMagick to convert, edit, or compose bitmap images in a variety of formats. In addition, resize, rotate, shear, distort or transform images automagically."></meta>
12 <meta name="application-url" content="http://www.imagemagick.org"></meta>
13 <meta name="generator" content="PHP"></meta>
14 <meta name="keywords" content="format, print, image, properties, ImageMagick, PerlMagick, image processing, OpenMP, software development library, image, photo, software, Magick++, MagickWand"></meta>
15 <meta name="rating" content="GENERAL"></meta>
16 <meta name="robots" content="INDEX, FOLLOW"></meta>
17 <meta name="generator" content="ImageMagick Studio LLC"></meta>
18 <meta name="author" content="ImageMagick Studio LLC"></meta>
19 <meta name="revisit-after" content="2 DAYS"></meta>
20 <meta name="resource-type" content="document"></meta>
21 <meta name="copyright" content="Copyright (c) 1999-2012 ImageMagick Studio LLC"></meta>
22 <meta name="distribution" content="Global"></meta>
23 <link rel="icon" href="../images/wand.png"></link>
24 <link rel="shortcut icon" href="../images/wand.ico" type="images/x-icon"></link>
25 <link rel="canonical" href="../index.html"></link>
26 <link rel="meta" type="application/rdf+xml" title="ICI" href="http://imagemagick.org/ici.rdf"></link>
28 <!-- Add jQuery library -->
29 <script type="text/javascript" src="http://localhost/ajax/libs/jquery/1.7/jquery.min.js"></script>
31 <!-- Add mousewheel plugin (this is optional) -->
32 <script type="text/javascript" src="http://www.imagemagick.org/fancybox/lib/jquery.mousewheel-3.0.6.pack.js"></script>
35 <link rel="stylesheet" href="http://www.imagemagick.org/fancybox/source/jquery.fancybox.css?v=2.0.6" type="text/css" media="screen"></link>
36 <script type="text/javascript" src="http://www.imagemagick.org/fancybox/source/jquery.fancybox.pack.js?v=2.0.6"></script>
38 <!-- Optionally add helpers - button, thumbnail and/or media -->
39 <link rel="stylesheet" href="http://www.imagemagick.org/fancybox/source/helpers/jquery.fancybox-buttons.css?v=1.0.2" type="text/css" media="screen"></link>
40 <script type="text/javascript" src="http://www.imagemagick.org/fancybox/source/helpers/jquery.fancybox-buttons.js?v=1.0.2"></script>
41 <script type="text/javascript" src="http://www.imagemagick.org/fancybox/source/helpers/jquery.fancybox-media.js?v=1.0.0"></script>
43 <link rel="stylesheet" href="http://www.imagemagick.org/fancybox/source/helpers/jquery.fancybox-thumbs.css?v=2.0.6" type="text/css" media="screen"></link>
44 <script type="text/javascript" src="http://www.imagemagick.org/fancybox/source/helpers/jquery.fancybox-thumbs.js?v=2.0.6"></script>
46 <script type="text/javascript">
47 $(document).ready(function() {
48 $(".fancybox").fancybox();
52 <!-- ImageMagick style -->
53 <style type="text/css" media="all">
54 @import url("../www/magick.css");
58 <body id="www-imagemagick-org">
62 <div class="titlebar">
63 <div style="margin: 17px auto; float: left;">
64 <script type="text/javascript">
66 google_ad_client = "pub-3129977114552745";
67 google_ad_slot = "5439289906";
68 google_ad_width = 728;
69 google_ad_height = 90;
74 <a href="../discourse-server">
75 <img src="../images/logo.jpg" alt="ImageMagick Logo" style="width: 123px; height: 118px; border: 0px; float: right;"></img></a>
76 <a href="../index.html">
77 <img src="../images/sprite.jpg" alt="ImageMagick Sprite" style="width: 114px; height: 118px; border: 0px; float: right;"></img></a>
83 <a title="About ImageMagick" href="../index.html">About ImageMagick</a>
86 <a title="Binary Releases" href="binary-releases.html">Binary Releases</a>
89 <a title="Binary Release: Unix" href="binary-releases.html#unix">Unix</a>
92 <a title="Binary Release: MacOS X" href="binary-releases.html#macosx">Mac OS X</a>
95 <a title="Binary Release: iOS" href="binary-releases.html#iOS">iOS</a>
98 <a title="Binary Release: Windows" href="binary-releases.html#windows">Windows</a>
100 <div class="sep"></div>
102 <a title="Command-line Tools" href="command-line-tools.html">Command-line Tools</a>
105 <a title="Command-line Tools: Processing" href="command-line-processing.html">Processing</a>
108 <a title="Command-line Tools: Options" href="command-line-options.html">Options</a>
111 <a title="Command-line Tools: Usage" href="http://www.imagemagick.org/Usage/">Usage</a>
114 <a title="Program Interfaces" href="api.html">Program Interfaces</a>
117 <a title="Program Interface: MagickWand" href="magick-wand.html">MagickWand</a>
120 <a title="Program Interface: MagickCore" href="magick-core.html">MagickCore</a>
123 <a title="Program Interface: PerlMagick" href="perl-magick.html">PerlMagick</a>
126 <a title="Program Interface: Magick++" href="magick++.html">Magick++</a>
128 <div class="sep"></div>
130 <a title="Install from Source" href="install-source.html">Install from Source</a>
133 <a title="Install from Source: Unix" href="install-source.html#unix">Unix</a>
136 <a title="Install from Source: Windows" href="install-source.html#windows">Windows</a>
139 <a title="Resources" href="resources.html">Resources</a>
142 <a title="Architecture" href="architecture.html">Architecture</a>
145 <a title="Download" href="download.html">Download</a>
147 <div class="sep"></div>
149 <a title="Search" href="search.html">Search</a>
151 <div class="sep"></div>
153 <a title="Site Map" href="sitemap.html">Site Map</a>
156 <a title="Site Map: Links" href="links.html">Links</a>
158 <div class="sep"></div>
160 <a title="Support ImageMagick Development" href="support.html">Support ImageMagick Development</a>
164 <div class="eastbar">
166 <div> <a class="FlattrButton" style="display:none;" rev="flattr;button:compact;" href="../index.html"></a></div>
168 <a href="http://flattr.com/thing/947300/Convert-Edit-And-Compose-Images" target="_blank">
169 <img src="http://api.flattr.com/button/flattr-badge-large.png" alt="Flattr this" title="Flattr this" width="93" height="20" border="0"></img></a>
177 <h1>ImageMagick Escapes</h1>
178 <p class="navigation-index"></p>
180 <div class="doc-section">
182 <p>Images in memory a lot of extra data assocated with them, beyond the actual
183 image data (cache) itself. This data can be very useful to users, either for
184 display, or for various calculations, or in modifying the behaviour of later
185 image processing operations.</p>
187 <p>Percent Escapes (of Image Propertes) are used in a number of options, for
188 example in <a href="command-line-options.html#format_identify_">-format</a> or in montage <a href="command-line-options.html#label">-label</a>, to print various properties and other settings associated with an
193 <td><b>Profile Data</b></td>
194 <td>Such as EXIF: data, containing focal lengths, exposures, dates, and in
195 come cases GPS locations.
198 <td><b>Attributes</b></td>
199 <td>These are directly involved with image data, and more commonly
200 modified as part of normal image processing. These include
201 width, height, depth, image type (colorspace), timing delays, and
202 background color. Most specific percent escapes is to access this
206 <td><b>Properties</b></td>
207 <td>These are stored as a table of free form strings, and are (if posible)
208 saved with the image (especially in MIFF and PNG image file formats).
209 These include: Labels, Captions, Comments.
212 <td><b>Artifacts</b></td>
213 <td>These are various operational (expert) settings that are saved for
214 use by various operators, or by the user for future use. It is just
215 a table of free-form strings. They are not saved with the image when
216 written. See Artifacts and Options below for details.
219 <td><b>Options</b></td>
220 <td>Also operational (expert) settings that are saved for
221 use by various operators, but are set globally for use by a whole
222 image list (also not saved). See Artifacts and Options below.
226 <h3>Percent Escape Handling</h3>
228 <p>If you request a percent escape such as <code>%[key]</code> the setting
229 is looked for in the following order until the first match has been
233 <li>Handle special prefixes such as 'artifact:' 'option:' 'exif:', or
234 'fx:'. This includes and calculations and or globs of those prefixes such
235 as 'exif:*' or 'artifact:*' (see below).</li>
237 <li>If <code>key</code> contains a glob pattern (but no known prefix)
238 search free-form properties table.</li>
240 <li>If <code>key</code> is a special image 'attribute' name (see list
241 above) return the associated or calculated image attribute.</li>
243 <li>Search for setting as a free-form 'property'</li>
244 <li>Search for setting as a free-form 'artifact'</li>
245 <li>Search for setting as a free-form 'option'</li>
247 <li>Replace escape with empty string, and perhaps produce a warning.</li>
250 <p>Remember, all long name forms of percent escapes are handled in a is case
251 insensitive manner. </p>
253 <p><b>As of IM v6.8.0-5</b> you can now access the Artifact and Option
254 free-form string tables directly, allowing you to override the above sequence,
255 and avoid accessing an attribute or property of the same name.</p>
258 %[artifact:<em class="arg">setting</em>]
259 %[option:<em class="arg">setting</em>]
263 <h3>Single Letter Attribute Percent Escapes</h3>
265 <p>Here are common single letter escapes (short form) is used to report the most
266 common attributes and properties of an image, such as: the image filename
267 filename, type, width, height. </p>
272 &lt; less-than character.
273 &gt; greater-than character.
274 &amp; ampersand character.
276 %b file size of image read in
277 %c comment meta-data property
278 %d directory component of path
279 %e filename extension or suffix
280 %f filename (including suffix)
281 %g layer canvas page geometry (equivalent to "%Wx%H%X%Y")
282 %h current image height in pixels
283 %i image filename (note: becomes output filename for "info:")
284 %k CALCULATED: number of unique colors
285 %l label meta-data property
286 %m image file format (file magic)
287 %n number of images in current image sequence
288 %o output filename (used for delegates)
289 %p index of image in current image list
290 %q quantum depth (compile-time constant)
291 %r image class and colorspace
292 %s scene number (from input unless re-assigned)
293 %t filename without directory or extension (suffix)
294 %u unique temporary filename (used for delegates)
295 %w current width in pixels
296 %x x resolution (density)
297 %y y resolution (density)
298 %z image depth (as read in unless modified, image save depth)
299 %A image transparency channel enabled (true/false)
300 %C image compression type
301 %D image GIF dispose method
302 %G original image size (%wx%h; before any resizes)
303 %H page (canvas) height
304 %M Magick filename (original file exactly as given, including read mods)
305 %O page (canvas) offset ( = %X%Y )
306 %P page (canvas) size ( = %Wx%H )
307 %Q image compression quality ( 0 = default )
309 %T image time delay (in centi-seconds)
310 %W page (canvas) width
311 %X page (canvas) x offset (including sign)
312 %Y page (canvas) y offset (including sign)
313 %Z unique filename (used for delegates)
314 %@ CALCULATED: trim bounding box (without actually trimming)
315 %# CALCULATED: 'signature' hash of image values
318 <p>Here is a sample command and its output for an image with filename
319 <code>bird.miff</code> and whose width is 512 and height is 480.</p>
321 <p class="crt"><span class="crtprompt"> $ </span><span class="crtin">identify -format "%m:%f %wx%h" bird.miff</span><span class="crtout">MIFF:bird.miff 512x480</span></p>
322 <p>Note that all single letter percent escapes can also be used using long
323 form (from IM version 6.7.6-9, see next). For example <code>%[f]</code> is
324 equivelent to the <code>%f</code> short form. </p>
326 <p><b>WARNING</b> short form percent escapes are NOT performed when the percent
327 is after a number. For example.. <code>10%x10</code> will not expand the
328 <code>%x</code> as a percent escape. If you specifically want to expanded the
329 'x', use the long form which overrides this special case. EG:
330 <code>10%[x]10</code>. </p>
332 <p>Also be warned that calculated attributes can take some time to generate,
333 especially for large images.</p>
335 <h3>Long Form Attribute Percent Escapes</h3>
337 <p>In addition to the above specific and calculated attributes are recognized
338 when enclosed in braces (long form):</p>
341 %[base] base filename, no suffixes (as %t)
342 %[channels] ??? channels in use - colorspace ???
343 %[colorspace] Colorspace of Image Data (excluding transparency)
344 %[copyright] ImageMagick Copyright String
345 %[depth] depth of image for write (as input unless changed)
346 %[deskew:angle] The deskew angle in degrees of rotation
347 %[directory] directory part of filename (as %d)
348 %[extension] extention part of filename (as %e)
349 %[gamma] value of image gamma
350 %[group] ??? window group ???
351 %[height] original height of image (when it was read in)
352 %[kurtosis] CALCULATED: kurtosis statistic of image
353 %[magick] coder used to read image (not the file suffix)
354 %[max] CALCULATED: maximum value statistic of image
355 %[mean] CALCULATED: average value statistic of image
356 %[min] CALCULATED: minimum value statistic of image
357 %[name] The original name of the image
358 %[opaque] CALCULATED: is image fully-opaque?
359 %[orientation] image orientation
360 %[page] Virtual canvas (page) geometry
361 %[resolution.y] X density (resolution) without units
362 %[resolution.x] Y density (resolution) without units
363 %[scene] original scene number of image in input file
364 %[size] original size of image (when it was read in)
365 %[skewness] CALCULATED: skewness statistic of image
366 %[standard-deviation] CALCULATED: standard-deviation statistic of image
367 %[type] CALCULATED: image type
368 %[unique] unique temporary filename ???
369 %[version] Version Information of this running ImageMagick
370 %[width] original width of image (when it was read in)
371 %[zero] zero (unique filename for delegate use)
376 <p>All other long forms of percent escapes (not single letter long form) are
377 handled in a case insensitive manner. Such escapes will will attempt to look
378 up that name specific data sources. </p>
380 <p>The primary search space (if not a specific attribute listed above) is
381 a free-form property string. Such strings are associated and saved with
382 images, and are typically set using either the <a href="command-line-options.html#set">-set</a>
383 CLI option (or API equivelent), or from special convenience options
384 (such as <a href="command-line-options.html#label">-label</a>, <a href="command-line-options.html#comment">-comment</a>, <a href="command-line-options.html#caption">-caption</a>). </p>
386 <p>These convenience options are globally saved (as 'global options' so thay can
387 be set before images are read), and later are transfered to the property of
388 individual images, only when they are read in. At that time any internal
389 percent escape present is then handled. </p>
391 <p>To change a property of an image already in memory, you need to use <a href="command-line-options.html#set">-set</a>.
394 <p>Note that properties, like attributes (and profiles), are saved with
395 images when write, if the image file format allows. </p>
398 <h3>Artifacts and Options</h3>
400 <p>The previous percent escapes are associated with the primary Attributes and
401 Properties. Which is the original and primary focus of such percent escapes.
404 <p>However there are many operational settings that are used by various
405 ImageMagick operators that can be useful to set and later access. These
406 consist of per-image Artifacts, and Global options (associated with a list of
407 images, typically the current image list).</p>
409 <p>Note that the major difference between an artifact and a property is that
410 artifacts, being an internal operational setting, is not saved with images (if
411 such is possible). </p>
413 <p>For example when you use <code>-define 'distort:viewport=100x100'</code> you
414 are in fact generating a global option, which the <a href="command-line-options.html#distort">-distort</a> operator will use to modify its behaviour (distorted output
417 <p>An Option is essentually a Artifact that has been stored globally as part
418 of a list of images (specifically a 'Wand' of images). As such they are
419 identical, in that a Option, is simply a global Artifact for all the
420 associated images. </p>
422 <p>As such you can use <code>-set 'option:distort:viewport' '100x100'</code> to
423 achieve the same result of setting a Artifact for the disort operation to use.
426 <p><b>Internal Handling of a Global Option...</b></p>
428 <p>The Core library ('MagickCore') does not generally directly understand
429 Global Options. As such, continuing the previous example, the
430 <code>DistortImages()</code> function only looks up an artifact to discover if
431 a 'viewport' has been provided to it. </p>
433 <p>How Global Options are used when a library function requests an Artifact is
434 one of the key differences between IMv6 and IMv7.</p>
436 <p>In <b>ImageMagick version 6</b>... before each operator, any global Options
437 are copied to per-image Artifacts, for every image in the current image list.
438 This allows various operators to find its operational 'defines' or Artifacts.
441 <p>In <b>ImageMagick version 7</b>... sets a link back to the global options
442 data, so that if a specific per-image Artifact is not found , then it will
443 look for a equivelent global Option for that image list. directly. This
444 saves coping these free-form options into artifacts repeatally, and means you
445 can now separally define a global option for a list, and a individual
446 overriding artifact for a specific image in that list. </p>
448 <p>Note that many API's that do not use Wands (PerlMagick for example using
449 arrays of images rather than a Wand). In these API's you will not have Global
450 Options, only per-image Artifacts. </p>
452 <p>In summery a Global Option, if available, is equivelent to a per-image
456 <h3>Glob-Pattern Listing of Properties, Artifacts and Options</h3>
458 <p>The <em class="arg">setting</em> can contain a glob pattern. As such you can
459 now list all free-form string properties, artifacts, and options, (but not
460 specific image attributes) using...</p>
464 -print "__Properties__\n%[*]" \
465 -print "__Artifacts__\n%[artifact:*]" \
466 -print "__Options__\n%[option:*]" \
470 <!-- This does not format right!
471 <p class='crt'><span class="crtprompt"> $ </span><span class='crtin'>convert ... \ </span><span class='crtout'> -print "__Properties__\n%[*]" \ </span><span class="crtprompt"> $ </span><span class='crtin'> -print "__Artifacts__\n%[artifact:*]" \ </span><span class='crtout'> -print "__Options__\n%[option:*]" \ </span><span class="crtprompt"> $ </span><span class='crtin'> ...</span></p>-->
473 <p> The format of glob patterns are very specific and as such is generally
474 only used to list specific settings, such as when debugging, rather than being
475 used for image processing use. </p>
478 <h3>Calculated Percent Escape Prefixes</h3>
480 <p>There are some special prefixes (before the first ':') which performs
481 calculations based on the user provided string that follows that prefix. For
482 example you can do a numerical calculation use <code>%[fx:...]</code> to
483 evaluate the given <a href="fx.html">FX</a> expressions:</p>
486 %[fx:<em class="arg">expression</em>]
489 <p>Use <code>pixel:</code> to evaluate a pixel color as defined by the <a href="fx.html">FX</a>
493 %[pixel:<em class="arg">expression</em>]
496 <h3>Specific Profile Percent Escape Prefixes</h3>
498 <p>You can also use the following special formatting syntax to print EXIF
499 mage meta-data that was included in the image read in:</p>
502 %[EXIF:<em class="arg">tag</em>]
505 <p>Choose <em class="arg">tag</em> from the following:</p>
508 * (print all EXIF tags, in keyword=data format)
509 ! (print all EXIF tags, in tag_number data format)
510 #hhhh (print data for EXIF tag #hhhh)
515 PhotometricInterpretation
535 PrimaryChromaticities
538 JPEGInterchangeFormat
539 JPEGInterchangeFormatLength
561 ComponentsConfiguration
562 CompressedBitsPerPixel
582 InteroperabilityOffset
584 SpatialFrequencyResponse
585 FocalPlaneXResolution
586 FocalPlaneYResolution
587 FocalPlaneResolutionUnit
595 <p>Surround the format specification with quotation marks to prevent your
596 shell from misinterpreting any spaces and square brackets.</p>
598 <p>The following special formatting syntax can be used to print IPTC
599 information contained in the file:</p>
602 %[IPTC:<em class="arg">dataset</em>:<em class="arg">record</em>]
605 <p>Select <em class="arg">dataset</em> and <em class="arg">record</em> from
613 1:22 File Format Version
614 1:30 Service Identifier
617 1:60 Envelope Priority
620 1:90 Coded Character Set
621 1:100 UNO (Unique Name of Object)
627 2:03 Object Type Reference
628 2:05 Object Name (Title)
630 2:08 Editorial Update
632 2:12 Subject Reference
634 2:20 Supplemental Category
635 2:22 Fixture Identifier
637 2:26 Content Location Code
638 2:27 Content Location Name
643 2:40 Special Instructions
645 2:45 Reference Service
647 2:50 Reference Number
650 2:62 Digital Creation Date
651 2:63 Digital Creation Time
652 2:65 Originating Program
655 2:80 By-Line (Author)
656 2:85 By-Line Title (Author Position) [Not used in Photoshop 7]
660 2:100 Country/Primary Location Code
661 2:101 Country/Primary Location Name
662 2:103 Original Transmission Reference
666 2:116 Copyright Notice
668 2:120 Caption/Abstract
669 2:122 Caption Writer/Editor
670 2:125 Rasterized Caption
672 2:131 Image Orientation
673 2:135 Language Identifier
675 2:151 Audio Sampling Rate
676 2:152 Audio Sampling Resolution
679 2:200 ObjectData Preview File Format
680 2:201 ObjectData Preview File Format Version
681 2:202 ObjectData Preview Data
683 Pre-ObjectData Descriptor Record
685 7:20 Max Subfile Size
686 7:90 ObjectData Size Announced
687 7:95 Maximum ObjectData Size
692 Post ObjectData Descriptor Record
693 9:10 Confirmed ObjectData Size
700 <span id="linkbar-west"> </span>
702 <span id="linkbar-center">
703 <a href="http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x89AB63D48277377A">Public Key</a> •
704 <a href="../discourse-server">Discourse Server</a> •
705 <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a> •
706 <a href="http://jqmagick.imagemagick.org/">JqMagick</a>
708 <span id="linkbar-east"> </span>
711 <span id="footer-west">© 1999-2014 ImageMagick Studio LLC</span>
712 <span id="footer-east"> <a href="contact.html">Contact the Wizards</a></span>
714 <div style="clear: both; margin: 0; width: 100%; "></div>