8 <meta charset="utf-8" />
9 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
10 <title>Format and Print Image Properties @ ImageMagick</title>
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="https://www.imagemagick.org" />
14 <meta name="generator" content="PHP" />
15 <meta name="keywords" content="format, print, image, properties, 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-2017 ImageMagick Studio LLC" />
23 <meta name="distribution" content="Global" />
24 <meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1" />
25 <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4" />
26 <link href="https://www.imagemagick.org/script/escape.html" rel="canonical" />
27 <link href="../images/wand.png" rel="icon" />
28 <link href="../images/wand.ico" rel="shortcut icon" />
29 <link href="css/magick.css" rel="stylesheet" />
32 <div class="magick-masthead">
33 <div class="container">
34 <script async="async" src="http://localhost/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle"
36 data-ad-client="ca-pub-3129977114552745"
37 data-ad-slot="6345125851"
38 data-ad-format="auto"></ins>
40 (adsbygoogle = window.adsbygoogle || []).push({});
42 <nav class="nav magick-nav">
43 <a class="nav-link " href="../index.html">Home</a>
44 <a class="nav-link " href="download.html">Download</a>
45 <a class="nav-link " href="command-line-tools.html">Tools</a>
46 <a class="nav-link " href="command-line-processing.html">Command-line</a>
47 <a class="nav-link " href="resources.html">Resources</a>
48 <a class="nav-link " href="develop.html">Develop</a>
49 <a class="nav-link " href="https://www.imagemagick.org/script/search.php">Search</a>
50 <a class="nav-link float-right" href="https://www.imagemagick.org/discourse-server/">Community</a>
54 <div class="container">
55 <div class="magick-header">
56 <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>
58 <div class="table-responsive">
59 <table class="table table-striped">
61 <td><b>Profile Data</b></td>
62 <td>Such as EXIF: data, containing focal lengths, exposures, dates, and in
63 come cases GPS locations.
66 <td><b>Attributes</b></td>
67 <td>These are directly involved with image data, and more commonly
68 modified as part of normal image processing. These include
69 width, height, depth, image type (colorspace), timing delays, and
70 background color. Most specific percent escapes is to access this
74 <td><b>Properties</b></td>
75 <td>These are stored as a table of free form strings, and are (if possible)
76 saved with the image (especially in MIFF and PNG image file formats).
77 These include: Labels, Captions, Comments.
80 <td><b>Artifacts</b></td>
81 <td>These are various operational (expert) settings that are saved for
82 use by various operators, or by the user for future use. It is just
83 a table of free-form strings. They are not saved with the image when
84 written. See Artifacts and Options below for details.
87 <td><b>Options</b></td>
88 <td>Also operational (expert) settings that are saved for
89 use by various operators, but are set globally for use by a whole
90 image list (also not saved). See Artifacts and Options below.
94 <h3>Percent Escape Handling</h3>
96 <p>If you request a percent escape such as <code>%[key]</code> the setting
97 is looked for in the following order until the first match has been
101 <li>Handle special prefixes such as 'artifact:' 'option:' 'exif:', or
102 'fx:'. This includes and calculations and or globs of those prefixes such
103 as 'exif:*' or 'artifact:*' (see below).</li>
105 <li>If <code>key</code> contains a glob pattern (but no known prefix)
106 search free-form properties table.</li>
108 <li>If <code>key</code> is a special image 'attribute' name (see list
109 above) return the associated or calculated image attribute.</li>
111 <li>Search for setting as a free-form 'property'</li>
112 <li>Search for setting as a free-form 'artifact'</li>
113 <li>Search for setting as a free-form 'option'</li>
115 <li>Replace escape with empty string, and perhaps produce a warning.</li>
118 <p>Remember, all long name forms of percent escapes are handled in a is case
119 insensitive manner. </p>
121 <p><b>As of IM v6.8.0-5</b> you can now access the Artifact and Option
122 free-form string tables directly, allowing you to override the above sequence,
123 and avoid accessing an attribute or property of the same name.</p>
126 %[artifact:<var>setting</var>]
127 %[option:<var>setting</var>]
131 <h3>Single Letter Attribute Percent Escapes</h3>
133 <p>Here are common single letter escapes (short form) is used to report the most
134 common attributes and properties of an image, such as: the image filename
135 filename, type, width, height. </p>
137 <div class="table-responsive">
138 <table class="table table-sm table-striped">
145 <td>carriage return</td>
149 <td>less-than character.</td>
153 <td>greater-than character.</td>
157 <td>ampersand character.</td>
161 <td>a percent sign</td>
165 <td>file size of image read in</td>
169 <td>comment meta-data property</td>
173 <td>directory component of path</td>
177 <td>filename extension or suffix</td>
181 <td>filename (including suffix)</td>
185 <td>layer canvas page geometry (equivalent to "%Wx%H%X%Y")</td>
189 <td>current image height in pixels</td>
193 <td>image filename (note: becomes output filename for "info:")</td>
197 <td>CALCULATED: number of unique colors</td>
201 <td>label meta-data property</td>
205 <td>image file format (file magic)</td>
209 <td>number of images in current image sequence</td>
213 <td>output filename (used for delegates)</td>
217 <td>index of image in current image list</td>
221 <td>quantum depth (compile-time constant)</td>
225 <td>image class and colorspace</td>
229 <td>scene number (from input unless re-assigned)</td>
233 <td>filename without directory or extension (suffix)</td>
237 <td>unique temporary filename (used for delegates)</td>
241 <td>current width in pixels</td>
245 <td>x resolution (density)</td>
249 <td>y resolution (density)</td>
253 <td>image depth (as read in unless modified, image save depth)</td>
257 <td>image transparency channel enabled (true/false)</td>
261 <td>image compression type</td>
265 <td>image GIF dispose method</td>
269 <td>original image size (%wx%h; before any resizes)</td>
273 <td>page (canvas) height</td>
277 <td>Magick filename (original file exactly as given, including read mods)</td>
281 <td>page (canvas) offset ( = %X%Y )</td>
285 <td>page (canvas) size ( = %Wx%H )</td>
289 <td>image compression quality ( 0 = default )</td>
293 <td>?? scenes ??</td>
297 <td>image time delay (in centi-seconds)</td>
301 <td>image resolution units</td>
305 <td>page (canvas) width</td>
309 <td>page (canvas) x offset (including sign)</td>
313 <td>page (canvas) y offset (including sign)</td>
317 <td>unique filename (used for delegates)</td>
321 <td>CALCULATED: trim bounding box (without actually trimming)</td>
325 <td>CALCULATED: 'signature' hash of image values</td>
329 <p>Here is a sample command and its output for an image with filename
330 <code>bird.miff</code> and whose width is 512 and height is 480.</p>
333 -> identify -format "%m:%f %wx%h" bird.miff
334 MIFF:bird.miff 512x480
337 <p>Note that all single letter percent escapes can also be used using long
338 form (from IM version 6.7.6-9, see next). For example <code>%[f]</code> is
339 equivalent to the <code>%f</code> short form. </p>
341 <p><b>WARNING</b>: short form percent escapes are NOT performed when the percent
342 is after a number. For example, <code>10%x10</code> does not expand the
343 <code>%x</code> as a percent escape. If you specifically want to expand the
344 'x', use the long form which overrides this special case. EG:
345 <code>10%[x]10</code>. </p>
347 <p>Also be warned that calculated attributes can take some time to generate,
348 especially for large images.</p>
350 <h3>Long Form Attribute Percent Escapes</h3>
352 <p>In addition to the above specific and calculated attributes are recognized
353 when enclosed in braces (long form):</p>
355 <div class="table-responsive">
356 <table class="table table-sm table-striped">
359 <td>base filename, no suffixes (as %t)</td>
363 <td>caption meta-data property</td>
366 <td>%[caption:pointsize]</td>
367 <td>returns the pointsize computed during caption: processing (as of IM 6.9.1-0)</td>
371 <td>??? channels in use - colorspace ???</td>
375 <td>Number of unique colors in the image (as of IM 7.0.3.8)</td>
378 <td>%[colorspace]</td>
379 <td>Colorspace of Image Data (excluding transparency)</td>
382 <td>%[compression]</td>
383 <td>Image compression type (as of IM 7.0.3.8)</td>
386 <td>%[copyright]</td>
387 <td>ImageMagick Copyright String</td>
391 <td>depth of image for write (as input unless changed)</td>
394 <td>%[deskew:angle]</td>
395 <td>The deskew angle in degrees of rotation</td>
398 <td>%[directory]</td>
399 <td>directory part of filename (as %d)</td>
402 <td>%[distortion]</td>
403 <td>how well an image resembles a reference image (<a href="command-line-options.html#compare" >-compare</a>)</td>
407 <td>CALCULATED: entropy of the image</td>
410 <td>%[extension]</td>
411 <td>extension part of filename (as %e)</td>
415 <td>value of image gamma</td>
419 <td>??? window group ???</td>
423 <td>original height of image (when it was read in)</td>
426 <td>%[interlace]</td>
427 <td>Image interlace mode (as of IM 7.0.3.8)</td>
431 <td>CALCULATED: kurtosis statistic of image</td>
435 <td>label meta-data property</td>
438 <td>%[label:pointsize]</td>
439 <td>returns the pointsize computed during label: processing (as of IM 6.9.1-0)</td>
443 <td>coder used to read image (not the file suffix)</td>
447 <td>CALCULATED: maximum value statistic of image</td>
451 <td>CALCULATED: average value statistic of image</td>
455 <td>CALCULATED: minimum value statistic of image</td>
459 <td>The original name of the image</td>
463 <td>CALCULATED: is image fully-opaque?</td>
466 <td>%[orientation]</td>
467 <td>image orientation</td>
471 <td>Virtual canvas (page) geometry</td>
474 <td>%[profile:icc]</td>
475 <td>ICC profile info</td>
478 <td>%[profile:icm]</td>
479 <td>ICM profile info</td>
483 <td>list of any embedded profiles</td>
487 <td>Image quality value (as of IM 7.0.3.8)</td>
490 <td>%[rendering-intent]</td>
491 <td>Image rendering intent (as of IM 7.0.3.8)</td>
494 <td>%[resolution.x]</td>
495 <td>X density (resolution) without units</td>
498 <td>%[resolution.y]</td>
499 <td>Y density (resolution) without units</td>
503 <td>original scene number of image in input file</td>
507 <td>original size of image (when it was read in)</td>
511 <td>CALCULATED: skewness statistic of image</td>
514 <td>%[standard-deviation]</td>
515 <td>CALCULATED: standard deviation statistic of image</td>
519 <td>CALCULATED: image type</td>
523 <td>unique temporary filename ???</td>
527 <td>image resolution units</td>
531 <td>Version Information of this running ImageMagick</td>
535 <td>original width of image (when it was read in)</td>
539 <td>zero (unique filename for delegate use)</td>
545 <p>All other long forms of percent escapes (not single letter long form) are
546 handled in a case insensitive manner. Such escapes will will attempt to look
547 up that name specific data sources. </p>
549 <p>The primary search space (if not a specific attribute listed above) is
550 a free-form property string. Such strings are associated and saved with
551 images, and are typically set using either the <a href="command-line-options.html#set" >-set</a>
552 CLI option (or API equivalent), or from special convenience options
553 (such as <a href="command-line-options.html#label"
554 >-label</a>, <a href="command-line-options.html#comment"
555 >-comment</a>, <a href="command-line-options.html#caption"
558 <p>These convenience options are globally saved (as 'global options' so thay can
559 be set before images are read), and later are transfered to the property of
560 individual images, only when they are read in. At that time any internal
561 percent escape present is then handled. </p>
563 <p>To change a property of an image already in memory, you need to use <a
564 href="command-line-options.html#set" >-set</a>.
567 <p>Note that properties, like attributes (and profiles), are saved with
568 images when write, if the image file format allows. </p>
571 <h3>Artifacts and Options</h3>
573 <p>The previous percent escapes are associated with the primary Attributes and
574 Properties. Which is the original and primary focus of such percent escapes.
577 <p>However there are many operational settings that are used by various
578 ImageMagick operators that can be useful to set and later access. These
579 consist of per-image Artifacts, and Global options (associated with a list of
580 images, typically the current image list).</p>
582 <p>Note that the major difference between an artifact and a property is that
583 artifacts, being an internal operational setting, is not saved with images (if
584 such is possible). </p>
586 <p>For example when you use <code>-define 'distort:viewport=100x100'</code> you
587 are in fact generating a global option, which the <a href="command-line-options.html#distort"
588 >-distort</a> operator will use to modify its behavior (distorted output
591 <p>An Option is essentually a Artifact that has been stored globally as part
592 of a list of images (specifically a 'Wand' of images). As such they are
593 identical, in that a Option, is simply a global Artifact for all the
594 associated images. </p>
596 <p>As such you can use <code>-set 'option:distort:viewport' '100x100'</code> to
597 achieve the same result of setting a Artifact for the disort operation to use.
600 <p><b>Internal Handling of a Global Option...</b></p>
602 <p>The Core library ('MagickCore') does not generally directly understand
603 Global Options. As such, continuing the previous example, the
604 <code>DistortImages()</code> function only looks up an artifact to discover if
605 a 'viewport' has been provided to it. </p>
607 <p>How Global Options are used when a library function requests an Artifact is
608 one of the key differences between IMv6 and IMv7.</p>
610 <p>In <b>ImageMagick version 6</b>... before each operator, any global Options
611 are copied to per-image Artifacts, for every image in the current image list.
612 This allows various operators to find its operational 'defines' or Artifacts.
615 <p>In <b>ImageMagick version 7</b>... sets a link back to the global options
616 data, so that if a specific per-image Artifact is not found , then it will
617 look for a equivalent global Option for that image list. directly. This
618 saves coping these free-form options into artifacts repeatally, and means you
619 can now separately define a global option for a list, and a individual
620 overriding artifact for a specific image in that list. </p>
622 <p>Note that many API's that do not use Wands (PerlMagick for example using
623 arrays of images rather than a Wand). In these API's you will not have Global
624 Options, only per-image Artifacts. </p>
626 <p>In summery a Global Option, if available, is equivalent to a per-image
630 <h3>Glob-Pattern Listing of Properties, Artifacts and Options</h3>
632 <p>The <var>setting</var> can contain a glob pattern. As such you can
633 now list all free-form string properties, artifacts, and options, (but not
634 specific image attributes) using...</p>
638 -print "__Properties__\n%[*]" \
639 -print "__Artifacts__\n%[artifact:*]" \
640 -print "__Options__\n%[option:*]" \
644 <p> The format of glob patterns are very specific and as such is generally
645 only used to list specific settings, such as when debugging, rather than being
646 used for image processing use. </p>
649 <h3>Calculated Percent Escape Prefixes</h3>
651 <p>There are some special prefixes (before the first ':') which performs
652 calculations based on the user provided string that follows that prefix. For
653 example you can do a numerical calculation use <code>%[fx:...]</code> to
654 evaluate the given <a href="fx.html">FX</a> expressions:</p>
657 %[fx:<var>expression</var>]
660 <p>Use <code>pixel:</code> or <code>hex:</code> to evaluate a pixel color as defined by the <a
661 href="fx.html">FX</a>
665 %[pixel:<var>expression</var>]
668 <h3>Specific Profile Percent Escape Prefixes</h3>
670 <p>You can also use the following special formatting syntax to print EXIF
671 mage meta-data that was included in the image read in:</p>
674 %[EXIF:<var>tag</var>]
677 <p>Choose <var>tag</var> from the following:</p>
679 <pre class="pre-scrollable"><code>
680 * (print all EXIF tags, in keyword=data format)
681 ! (print all EXIF tags, in tag_number data format)
682 #hhhh (print data for EXIF tag #hhhh)
687 PhotometricInterpretation
707 PrimaryChromaticities
710 JPEGInterchangeFormat
711 JPEGInterchangeFormatLength
733 ComponentsConfiguration
734 CompressedBitsPerPixel
754 InteroperabilityOffset
756 SpatialFrequencyResponse
757 FocalPlaneXResolution
758 FocalPlaneYResolution
759 FocalPlaneResolutionUnit
767 <p>Surround the format specification with quotation marks to prevent your
768 shell from misinterpreting any spaces and square brackets.</p>
770 <p>The following special formatting syntax can be used to print IPTC
771 information contained in the file:</p>
774 %[IPTC:<var>dataset</var>:<var>record</var>]
777 <p>Select <var>dataset</var> and <var>record</var> from the following:</p>
779 <pre class="pre-scrollable:">
784 1:22 File Format Version
785 1:30 Service Identifier
788 1:60 Envelope Priority
791 1:90 Coded Character Set
792 1:100 UNO (Unique Name of Object)
798 2:03 Object Type Reference
799 2:05 Object Name (Title)
801 2:08 Editorial Update
803 2:12 Subject Reference
805 2:20 Supplemental Category
806 2:22 Fixture Identifier
808 2:26 Content Location Code
809 2:27 Content Location Name
814 2:40 Special Instructions
816 2:45 Reference Service
818 2:50 Reference Number
821 2:62 Digital Creation Date
822 2:63 Digital Creation Time
823 2:65 Originating Program
826 2:80 By-Line (Author)
827 2:85 By-Line Title (Author Position) [Not used in Photoshop 7]
831 2:100 Country/Primary Location Code
832 2:101 Country/Primary Location Name
833 2:103 Original Transmission Reference
837 2:116 Copyright Notice
839 2:120 Caption/Abstract
840 2:122 Caption Writer/Editor
841 2:125 Rasterized Caption
843 2:131 Image Orientation
844 2:135 Language Identifier
846 2:151 Audio Sampling Rate
847 2:152 Audio Sampling Resolution
850 2:200 ObjectData Preview File Format
851 2:201 ObjectData Preview File Format Version
852 2:202 ObjectData Preview Data
854 Pre-ObjectData Descriptor Record
856 7:20 Max Subfile Size
857 7:90 ObjectData Size Announced
858 7:95 Maximum ObjectData Size
863 Post ObjectData Descriptor Record
864 9:10 Confirmed ObjectData Size
867 <footer class="magick-footer">
868 <p><a href="support.html">Donate</a> •
869 <a href="sitemap.html">Sitemap</a> •
870 <a href="links.html">Related</a> •
871 <a href="security-policy.html">Security</a> •
872 <a href="architecture.html">Architecture</a>
874 <p><a href="escape.html#">Back to top</a> •
875 <a href="http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x89AB63D48277377A">Public Key</a> •
876 <a href="https://www.imagemagick.org/script/contact.php">Contact Us</a></p>
877 <p><small>© 1999-2017 ImageMagick Studio LLC</small></p>
879 </div><!-- /.container -->
881 <script src="https://localhost/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
882 <script src="../js/magick.html"></script>
885 <!-- Magick Cache 13th July 2017 06:38 -->