8 <meta charset="utf-8" />
9 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
10 <meta http-equiv="x-ua-compatible" content="ie=edge" />
11 <title>Format and Print Image Properties @ ImageMagick</title>
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 Bézier curves."/>
15 <meta name="application-url" content="https://www.imagemagick.org"/>
16 <meta name="generator" content="PHP"/>
17 <meta name="keywords" content="format, print, image, properties, 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-2017 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="canonical" href="https://www.imagemagick.org/script/escape.html"/>
29 <link rel="icon" href="../images/wand.png"/>
30 <link rel="shortcut icon" href="../images/wand.ico"/>
31 <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" />
32 <link rel="stylesheet" href="css/magick.css"/>
36 <div class="magick-masthead">
37 <div class="container">
38 <script async="async" src="http://localhost/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle"
40 data-ad-client="ca-pub-3129977114552745"
41 data-ad-slot="6345125851"
42 data-ad-format="auto"></ins>
44 (adsbygoogle = window.adsbygoogle || []).push({});
46 <nav class="magick-nav">
47 <a class="magick-nav-item " href="../index.html">Home</a>
48 <a class="magick-nav-item " href="download.html">Download</a>
49 <a class="magick-nav-item " href="command-line-tools.html">Tools</a>
50 <a class="magick-nav-item " href="command-line-processing.html">Command-line</a>
51 <a class="magick-nav-item " href="resources.html">Resources</a>
52 <a class="magick-nav-item " href="develop.html">Develop</a>
53 <a class="magick-nav-item " href="https://www.imagemagick.org/script/search.php">Search</a>
54 <a class="magick-nav-item float-right" href="https://www.imagemagick.org/discourse-server/">Community</a>
58 <div class="container">
59 <div class="magick-header">
60 <p class="lead magick-description">There are copious amounts of extra data associated with images (metadata), beyond the actual image pixels. This metadata can be useful, either for display, or for various calculations, or in modifying the behavior of later image processing operations. You can utilize percent escapes in a number of options, for 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 image.</p>
62 <div class="table-responsive">
63 <table class="table table-striped">
65 <td><b>Profile Data</b></td>
66 <td>Such as EXIF: data, containing focal lengths, exposures, dates, and in
67 come cases GPS locations.
70 <td><b>Attributes</b></td>
71 <td>These are directly involved with image data, and more commonly
72 modified as part of normal image processing. These include
73 width, height, depth, image type (colorspace), timing delays, and
74 background color. Most specific percent escapes is to access this
78 <td><b>Properties</b></td>
79 <td>These are stored as a table of free form strings, and are (if possible)
80 saved with the image (especially in MIFF and PNG image file formats).
81 These include: Labels, Captions, Comments.
84 <td><b>Artifacts</b></td>
85 <td>These are various operational (expert) settings that are saved for
86 use by various operators, or by the user for future use. It is just
87 a table of free-form strings. They are not saved with the image when
88 written. See Artifacts and Options below for details.
91 <td><b>Options</b></td>
92 <td>Also operational (expert) settings that are saved for
93 use by various operators, but are set globally for use by a whole
94 image list (also not saved). See Artifacts and Options below.
98 <h3 class="magick-header">Percent Escape Handling</h3>
100 <p>If you request a percent escape such as <code>%[key]</code> the setting
101 is looked for in the following order until the first match has been
105 <li>Handle special prefixes such as 'artifact:' 'option:' 'exif:', or
106 'fx:'. This includes and calculations and or globs of those prefixes such
107 as 'exif:*' or 'artifact:*' (see below).</li>
109 <li>If <code>key</code> contains a glob pattern (but no known prefix)
110 search free-form properties table.</li>
112 <li>If <code>key</code> is a special image 'attribute' name (see list
113 above) return the associated or calculated image attribute.</li>
115 <li>Search for setting as a free-form 'property'</li>
116 <li>Search for setting as a free-form 'artifact'</li>
117 <li>Search for setting as a free-form 'option'</li>
119 <li>Replace escape with empty string, and perhaps produce a warning.</li>
122 <p>Remember, all long name forms of percent escapes are handled in a is case
123 insensitive manner. </p>
125 <p><b>As of IM v6.8.0-5</b> you can now access the Artifact and Option
126 free-form string tables directly, allowing you to override the above sequence,
127 and avoid accessing an attribute or property of the same name.</p>
130 %[artifact:<var>setting</var>]
131 %[option:<var>setting</var>]
135 <h3 class="magick-header">Single Letter Attribute Percent Escapes</h3>
137 <p>Here are common single letter escapes (short form) is used to report the most
138 common attributes and properties of an image, such as: the image filename
139 filename, type, width, height. </p>
141 <div class="table-responsive">
142 <table class="table table-condensed table-striped">
149 <td>carriage return</td>
153 <td>less-than character.</td>
157 <td>greater-than character.</td>
161 <td>ampersand character.</td>
165 <td>a percent sign</td>
169 <td>file size of image read in</td>
173 <td>comment meta-data property</td>
177 <td>directory component of path</td>
181 <td>filename extension or suffix</td>
185 <td>filename (including suffix)</td>
189 <td>layer canvas page geometry (equivalent to "%Wx%H%X%Y")</td>
193 <td>current image height in pixels</td>
197 <td>image filename (note: becomes output filename for "info:")</td>
201 <td>CALCULATED: number of unique colors</td>
205 <td>label meta-data property</td>
209 <td>image file format (file magic)</td>
213 <td>number of images in current image sequence</td>
217 <td>output filename (used for delegates)</td>
221 <td>index of image in current image list</td>
225 <td>quantum depth (compile-time constant)</td>
229 <td>image class and colorspace</td>
233 <td>scene number (from input unless re-assigned)</td>
237 <td>filename without directory or extension (suffix)</td>
241 <td>unique temporary filename (used for delegates)</td>
245 <td>current width in pixels</td>
249 <td>x resolution (density)</td>
253 <td>y resolution (density)</td>
257 <td>image depth (as read in unless modified, image save depth)</td>
261 <td>image transparency channel enabled (true/false)</td>
265 <td>image compression type</td>
269 <td>image GIF dispose method</td>
273 <td>original image size (%wx%h; before any resizes)</td>
277 <td>page (canvas) height</td>
281 <td>Magick filename (original file exactly as given, including read mods)</td>
285 <td>page (canvas) offset ( = %X%Y )</td>
289 <td>page (canvas) size ( = %Wx%H )</td>
293 <td>image compression quality ( 0 = default )</td>
297 <td>?? scenes ??</td>
301 <td>image time delay (in centi-seconds)</td>
305 <td>image resolution units</td>
309 <td>page (canvas) width</td>
313 <td>page (canvas) x offset (including sign)</td>
317 <td>page (canvas) y offset (including sign)</td>
321 <td>unique filename (used for delegates)</td>
325 <td>CALCULATED: trim bounding box (without actually trimming)</td>
329 <td>CALCULATED: 'signature' hash of image values</td>
333 <p>Here is a sample command and its output for an image with filename
334 <code>bird.miff</code> and whose width is 512 and height is 480.</p>
337 -> identify -format "%m:%f %wx%h" bird.miff
338 MIFF:bird.miff 512x480
341 <p>Note that all single letter percent escapes can also be used using long
342 form (from IM version 6.7.6-9, see next). For example <code>%[f]</code> is
343 equivalent to the <code>%f</code> short form. </p>
345 <p><b>WARNING</b>: short form percent escapes are NOT performed when the percent
346 is after a number. For example, <code>10%x10</code> does not expand the
347 <code>%x</code> as a percent escape. If you specifically want to expand the
348 'x', use the long form which overrides this special case. EG:
349 <code>10%[x]10</code>. </p>
351 <p>Also be warned that calculated attributes can take some time to generate,
352 especially for large images.</p>
354 <h3 class="magick-header">Long Form Attribute Percent Escapes</h3>
356 <p>In addition to the above specific and calculated attributes are recognized
357 when enclosed in braces (long form):</p>
359 <div class="table-responsive">
360 <table class="table table-condensed table-striped">
363 <td>base filename, no suffixes (as %t)</td>
367 <td>caption meta-data property</td>
370 <td>%[caption:pointsize]</td>
371 <td>returns the pointsize computed during caption: processing (as of IM 6.9.1-0)</td>
375 <td>??? channels in use - colorspace ???</td>
379 <td>Number of unique colors in the image (as of IM 7.0.3.8)</td>
382 <td>%[colorspace]</td>
383 <td>Colorspace of Image Data (excluding transparency)</td>
386 <td>%[compression]</td>
387 <td>Image compression type (as of IM 7.0.3.8)</td>
390 <td>%[copyright]</td>
391 <td>ImageMagick Copyright String</td>
395 <td>depth of image for write (as input unless changed)</td>
398 <td>%[deskew:angle]</td>
399 <td>The deskew angle in degrees of rotation</td>
402 <td>%[directory]</td>
403 <td>directory part of filename (as %d)</td>
406 <td>%[distortion]</td>
407 <td>how well an image resembles a reference image (<a href="command-line-options.html#compare" >-compare</a>)</td>
411 <td>CALCULATED: entropy of the image</td>
414 <td>%[extension]</td>
415 <td>extension part of filename (as %e)</td>
419 <td>value of image gamma</td>
423 <td>??? window group ???</td>
427 <td>original height of image (when it was read in)</td>
430 <td>%[interlace]</td>
431 <td>Image interlace mode (as of IM 7.0.3.8)</td>
435 <td>CALCULATED: kurtosis statistic of image</td>
439 <td>label meta-data property</td>
442 <td>%[label:pointsize]</td>
443 <td>returns the pointsize computed during label: processing (as of IM 6.9.1-0)</td>
447 <td>coder used to read image (not the file suffix)</td>
451 <td>CALCULATED: maximum value statistic of image</td>
455 <td>CALCULATED: average value statistic of image</td>
459 <td>CALCULATED: minimum value statistic of image</td>
463 <td>The original name of the image</td>
467 <td>CALCULATED: is image fully-opaque?</td>
470 <td>%[orientation]</td>
471 <td>image orientation</td>
475 <td>Virtual canvas (page) geometry</td>
478 <td>%[profile:icc]</td>
479 <td>ICC profile info</td>
482 <td>%[profile:icm]</td>
483 <td>ICM profile info</td>
487 <td>list of any embedded profiles</td>
491 <td>Image quality value (as of IM 7.0.3.8)</td>
494 <td>%[rendering-intent]</td>
495 <td>Image rendering intent (as of IM 7.0.3.8)</td>
498 <td>%[resolution.x]</td>
499 <td>X density (resolution) without units</td>
502 <td>%[resolution.y]</td>
503 <td>Y density (resolution) without units</td>
507 <td>original scene number of image in input file</td>
511 <td>original size of image (when it was read in)</td>
515 <td>CALCULATED: skewness statistic of image</td>
518 <td>%[standard-deviation]</td>
519 <td>CALCULATED: standard deviation statistic of image</td>
523 <td>CALCULATED: image type</td>
527 <td>unique temporary filename ???</td>
531 <td>image resolution units</td>
535 <td>Version Information of this running ImageMagick</td>
539 <td>original width of image (when it was read in)</td>
543 <td>zero (unique filename for delegate use)</td>
547 <h3 class="magick-header">Properties</h3>
549 <p>All other long forms of percent escapes (not single letter long form) are
550 handled in a case insensitive manner. Such escapes will will attempt to look
551 up that name specific data sources. </p>
553 <p>The primary search space (if not a specific attribute listed above) is
554 a free-form property string. Such strings are associated and saved with
555 images, and are typically set using either the <a href="command-line-options.html#set" >-set</a>
556 CLI option (or API equivalent), or from special convenience options
557 (such as <a href="command-line-options.html#label"
558 >-label</a>, <a href="command-line-options.html#comment"
559 >-comment</a>, <a href="command-line-options.html#caption"
562 <p>These convenience options are globally saved (as 'global options' so thay can
563 be set before images are read), and later are transfered to the property of
564 individual images, only when they are read in. At that time any internal
565 percent escape present is then handled. </p>
567 <p>To change a property of an image already in memory, you need to use <a
568 href="command-line-options.html#set" >-set</a>.
571 <p>Note that properties, like attributes (and profiles), are saved with
572 images when write, if the image file format allows. </p>
575 <h3 class="magick-header">Artifacts and Options</h3>
577 <p>The previous percent escapes are associated with the primary Attributes and
578 Properties. Which is the original and primary focus of such percent escapes.
581 <p>However there are many operational settings that are used by various
582 ImageMagick operators that can be useful to set and later access. These
583 consist of per-image Artifacts, and Global options (associated with a list of
584 images, typically the current image list).</p>
586 <p>Note that the major difference between an artifact and a property is that
587 artifacts, being an internal operational setting, is not saved with images (if
588 such is possible). </p>
590 <p>For example when you use <code>-define 'distort:viewport=100x100'</code> you
591 are in fact generating a global option, which the <a href="command-line-options.html#distort"
592 >-distort</a> operator will use to modify its behavior (distorted output
595 <p>An Option is essentually a Artifact that has been stored globally as part
596 of a list of images (specifically a 'Wand' of images). As such they are
597 identical, in that a Option, is simply a global Artifact for all the
598 associated images. </p>
600 <p>As such you can use <code>-set 'option:distort:viewport' '100x100'</code> to
601 achieve the same result of setting a Artifact for the disort operation to use.
604 <p><b>Internal Handling of a Global Option...</b></p>
606 <p>The Core library ('MagickCore') does not generally directly understand
607 Global Options. As such, continuing the previous example, the
608 <code>DistortImages()</code> function only looks up an artifact to discover if
609 a 'viewport' has been provided to it. </p>
611 <p>How Global Options are used when a library function requests an Artifact is
612 one of the key differences between IMv6 and IMv7.</p>
614 <p>In <b>ImageMagick version 6</b>... before each operator, any global Options
615 are copied to per-image Artifacts, for every image in the current image list.
616 This allows various operators to find its operational 'defines' or Artifacts.
619 <p>In <b>ImageMagick version 7</b>... sets a link back to the global options
620 data, so that if a specific per-image Artifact is not found , then it will
621 look for a equivalent global Option for that image list. directly. This
622 saves coping these free-form options into artifacts repeatally, and means you
623 can now separately define a global option for a list, and a individual
624 overriding artifact for a specific image in that list. </p>
626 <p>Note that many API's that do not use Wands (PerlMagick for example using
627 arrays of images rather than a Wand). In these API's you will not have Global
628 Options, only per-image Artifacts. </p>
630 <p>In summery a Global Option, if available, is equivalent to a per-image
634 <h3 class="magick-header">Glob-Pattern Listing of Properties, Artifacts and Options</h3>
636 <p>The <var>setting</var> can contain a glob pattern. As such you can
637 now list all free-form string properties, artifacts, and options, (but not
638 specific image attributes) using...</p>
642 -print "__Properties__\n%[*]" \
643 -print "__Artifacts__\n%[artifact:*]" \
644 -print "__Options__\n%[option:*]" \
648 <p> The format of glob patterns are very specific and as such is generally
649 only used to list specific settings, such as when debugging, rather than being
650 used for image processing use. </p>
653 <h3 class="magick-header">Calculated Percent Escape Prefixes</h3>
655 <p>There are some special prefixes (before the first ':') which performs
656 calculations based on the user provided string that follows that prefix. For
657 example you can do a numerical calculation use <code>%[fx:...]</code> to
658 evaluate the given <a href="fx.html">FX</a> expressions:</p>
661 %[fx:<var>expression</var>]
664 <p>Use <code>pixel:</code> or <code>hex:</code> to evaluate a pixel color as defined by the <a
665 href="fx.html">FX</a>
669 %[pixel:<var>expression</var>]
672 <h3 class="magick-header">Specific Profile Percent Escape Prefixes</h3>
674 <p>You can also use the following special formatting syntax to print EXIF
675 mage meta-data that was included in the image read in:</p>
678 %[EXIF:<var>tag</var>]
681 <p>Choose <var>tag</var> from the following:</p>
683 <pre class="pre-scrollable">
684 * (print all EXIF tags, in keyword=data format)
685 ! (print all EXIF tags, in tag_number data format)
686 #hhhh (print data for EXIF tag #hhhh)
691 PhotometricInterpretation
711 PrimaryChromaticities
714 JPEGInterchangeFormat
715 JPEGInterchangeFormatLength
737 ComponentsConfiguration
738 CompressedBitsPerPixel
758 InteroperabilityOffset
760 SpatialFrequencyResponse
761 FocalPlaneXResolution
762 FocalPlaneYResolution
763 FocalPlaneResolutionUnit
771 <p>Surround the format specification with quotation marks to prevent your
772 shell from misinterpreting any spaces and square brackets.</p>
774 <p>The following special formatting syntax can be used to print IPTC
775 information contained in the file:</p>
778 %[IPTC:<var>dataset</var>:<var>record</var>]
781 <p>Select <var>dataset</var> and <var>record</var> from the following:</p>
783 <pre class="pre-scrollable:">
788 1:22 File Format Version
789 1:30 Service Identifier
792 1:60 Envelope Priority
795 1:90 Coded Character Set
796 1:100 UNO (Unique Name of Object)
802 2:03 Object Type Reference
803 2:05 Object Name (Title)
805 2:08 Editorial Update
807 2:12 Subject Reference
809 2:20 Supplemental Category
810 2:22 Fixture Identifier
812 2:26 Content Location Code
813 2:27 Content Location Name
818 2:40 Special Instructions
820 2:45 Reference Service
822 2:50 Reference Number
825 2:62 Digital Creation Date
826 2:63 Digital Creation Time
827 2:65 Originating Program
830 2:80 By-Line (Author)
831 2:85 By-Line Title (Author Position) [Not used in Photoshop 7]
835 2:100 Country/Primary Location Code
836 2:101 Country/Primary Location Name
837 2:103 Original Transmission Reference
841 2:116 Copyright Notice
843 2:120 Caption/Abstract
844 2:122 Caption Writer/Editor
845 2:125 Rasterized Caption
847 2:131 Image Orientation
848 2:135 Language Identifier
850 2:151 Audio Sampling Rate
851 2:152 Audio Sampling Resolution
854 2:200 ObjectData Preview File Format
855 2:201 ObjectData Preview File Format Version
856 2:202 ObjectData Preview Data
858 Pre-ObjectData Descriptor Record
860 7:20 Max Subfile Size
861 7:90 ObjectData Size Announced
862 7:95 Maximum ObjectData Size
867 Post ObjectData Descriptor Record
868 9:10 Confirmed ObjectData Size
871 <footer class="magick-footer">
872 <p><a href="support.html">Donate</a> •
873 <a href="sitemap.html">Sitemap</a> •
874 <a href="links.html">Related</a> •
875 <a href="security-policy.html">Security</a> •
876 <a href="architecture.html">Architecture</a>
878 <p><a href="escape.html#">Back to top</a> •
879 <a href="http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x89AB63D48277377A">Public Key</a> •
880 <a href="https://www.imagemagick.org/script/contact.php">Contact Us</a></p>
881 <p><small>© 1999-2017 ImageMagick Studio LLC</small></p>
883 </div><!-- /.container -->
885 <script src="https://localhost/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
886 <script src="../js/magick.html"></script>
890 <!-- Magick Cache 2nd June 2017 20:21 -->