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 http-equiv="Content-Type" content="text/html; charset=UTF-8" />
26 <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4" />
27 <link href="../www/escape.html" rel="canonical" />
28 <link href="../images/wand.png" rel="icon" />
29 <link href="../images/wand.ico" rel="shortcut icon" />
30 <link href="assets/magick.css" rel="stylesheet" />
34 <nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
35 <a class="navbar-brand" href="escape.html#">ImageMagick</a>
36 <button class="navbar-toggler collapsed" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
37 <span class="navbar-toggler-icon"></span>
40 <div class="navbar-collapse collapse" id="navbarsExampleDefault" style="">
41 <ul class="navbar-nav mr-auto">
42 <li class="nav-item ">
43 <a class="nav-link" href="../index.html">Home <span class="sr-only">(current)</span></a>
45 <li class="nav-item ">
46 <a class="nav-link" href="download.html">Download</a>
48 <li class="nav-item ">
49 <a class="nav-link" href="command-line-tools.html">Tools</a>
51 <li class="nav-item ">
52 <a class="nav-link" href="command-line-processing.html">Command-line</a>
54 <li class="nav-item ">
55 <a class="nav-link" href="resources.html">Resources</a>
57 <li class="nav-item ">
58 <a class="nav-link" href="develop.html">Develop</a>
61 <a class="nav-link" href="https://www.imagemagick.org/discourse-server/">Community</a>
64 <form class="form-inline my-2 my-lg-0" action="https://www.imagemagick.org/script/search.php">
65 <!-- <input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search"> -->
66 <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
70 <div class="container">
71 <script async="async" src="http://localhost/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle"
73 data-ad-client="ca-pub-3129977114552745"
74 data-ad-slot="6345125851"
75 data-ad-format="auto"></ins>
77 (adsbygoogle = window.adsbygoogle || []).push({});
81 <main role="main" class="container">
82 <div class="magick-template">
83 <div class="magick-header">
84 <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>
86 <div class="table-responsive">
87 <table class="table table-striped">
89 <td><b>Profile Data</b></td>
90 <td>Such as EXIF: data, containing focal lengths, exposures, dates, and in
91 come cases GPS locations.
94 <td><b>Attributes</b></td>
95 <td>These are directly involved with image data, and more commonly
96 modified as part of normal image processing. These include
97 width, height, depth, image type (colorspace), timing delays, and
98 background color. Most specific percent escapes is to access this
102 <td><b>Properties</b></td>
103 <td>These are stored as a table of free form strings, and are (if possible)
104 saved with the image (especially in MIFF and PNG image file formats).
105 These include: Labels, Captions, Comments.
108 <td><b>Artifacts</b></td>
109 <td>These are various operational (expert) settings that are saved for
110 use by various operators, or by the user for future use. It is just
111 a table of free-form strings. They are not saved with the image when
112 written. See Artifacts and Options below for details.
115 <td><b>Options</b></td>
116 <td>Also operational (expert) settings that are saved for
117 use by various operators, but are set globally for use by a whole
118 image list (also not saved). See Artifacts and Options below.
122 <h3>Percent Escape Handling</h3>
124 <p>If you request a percent escape such as <code>%[key]</code> the setting
125 is looked for in the following order until the first match has been
129 <li>Handle special prefixes such as 'artifact:' 'option:' 'exif:', or
130 'fx:'. This includes and calculations and or globs of those prefixes such
131 as 'exif:*' or 'artifact:*' (see below).</li>
133 <li>If <code>key</code> contains a glob pattern (but no known prefix)
134 search free-form properties table.</li>
136 <li>If <code>key</code> is a special image 'attribute' name (see list
137 above) return the associated or calculated image attribute.</li>
139 <li>Search for setting as a free-form 'property'</li>
140 <li>Search for setting as a free-form 'artifact'</li>
141 <li>Search for setting as a free-form 'option'</li>
143 <li>Replace escape with empty string, and perhaps produce a warning.</li>
146 <p>Remember, all long name forms of percent escapes are handled in a is case
147 insensitive manner. </p>
149 <p><b>As of IM v6.8.0-5</b> you can now access the Artifact and Option
150 free-form string tables directly, allowing you to override the above sequence,
151 and avoid accessing an attribute or property of the same name.</p>
153 <pre class="highlight"><code>%[artifact:<var>setting</var>]
154 %[option:<var>setting</var>]
158 <h3>Single Letter Attribute Percent Escapes</h3>
160 <p>Here are common single letter escapes (short form) is used to report the most
161 common attributes and properties of an image, such as: the image filename
162 filename, type, width, height. </p>
164 <div class="table-responsive">
165 <table class="table table-sm table-striped">
172 <td>carriage return</td>
176 <td>less-than character.</td>
180 <td>greater-than character.</td>
184 <td>ampersand character.</td>
188 <td>a percent sign</td>
192 <td>file size of image read in</td>
196 <td>comment meta-data property</td>
200 <td>directory component of path</td>
204 <td>filename extension or suffix</td>
208 <td>filename (including suffix)</td>
212 <td>layer canvas page geometry (equivalent to "%Wx%H%X%Y")</td>
216 <td>current image height in pixels</td>
220 <td>image filename (note: becomes output filename for "info:")</td>
224 <td>CALCULATED: number of unique colors</td>
228 <td>label meta-data property</td>
232 <td>image file format (file magic)</td>
236 <td>number of images in current image sequence</td>
240 <td>output filename (used for delegates)</td>
244 <td>index of image in current image list</td>
248 <td>quantum depth (compile-time constant)</td>
252 <td>image class and colorspace</td>
256 <td>scene number (from input unless re-assigned)</td>
260 <td>filename without directory or extension (suffix)</td>
264 <td>unique temporary filename (used for delegates)</td>
268 <td>current width in pixels</td>
272 <td>x resolution (density)</td>
276 <td>y resolution (density)</td>
280 <td>image depth (as read in unless modified, image save depth)</td>
284 <td>image transparency channel enabled (true/false)</td>
288 <td>image compression type</td>
292 <td>image GIF dispose method</td>
296 <td>original image size (%wx%h; before any resizes)</td>
300 <td>page (canvas) height</td>
304 <td>Magick filename (original file exactly as given, including read mods)</td>
308 <td>page (canvas) offset ( = %X%Y )</td>
312 <td>page (canvas) size ( = %Wx%H )</td>
316 <td>image compression quality ( 0 = default )</td>
320 <td>?? scenes ??</td>
324 <td>image time delay (in centi-seconds)</td>
328 <td>image resolution units</td>
332 <td>page (canvas) width</td>
336 <td>page (canvas) x offset (including sign)</td>
340 <td>page (canvas) y offset (including sign)</td>
344 <td>unique filename (used for delegates)</td>
348 <td>CALCULATED: trim bounding box (without actually trimming)</td>
352 <td>CALCULATED: 'signature' hash of image values</td>
356 <p>Here is a sample command and its output for an image with filename
357 <code>bird.miff</code> and whose width is 512 and height is 480.</p>
359 <pre class="highlight"><code>-> identify -format "%m:%f %wx%h" bird.miff
360 MIFF:bird.miff 512x480
363 <p>Note that all single letter percent escapes can also be used using long
364 form (from IM version 6.7.6-9, see next). For example <code>%[f]</code> is
365 equivalent to the <code>%f</code> short form. </p>
367 <p><b>WARNING</b>: short form percent escapes are NOT performed when the percent
368 is after a number. For example, <code>10%x10</code> does not expand the
369 <code>%x</code> as a percent escape. If you specifically want to expand the
370 'x', use the long form which overrides this special case. EG:
371 <code>10%[x]10</code>. </p>
373 <p>Also be warned that calculated attributes can take some time to generate,
374 especially for large images.</p>
376 <h3>Long Form Attribute Percent Escapes</h3>
378 <p>In addition to the above specific and calculated attributes are recognized
379 when enclosed in braces (long form):</p>
381 <div class="table-responsive">
382 <table class="table table-sm table-striped">
385 <td>base filename, no suffixes (as %t)</td>
389 <td>caption meta-data property</td>
392 <td>%[caption:pointsize]</td>
393 <td>returns the pointsize computed during caption: processing (as of IM 6.9.1-0)</td>
397 <td>??? channels in use - colorspace ???</td>
401 <td>Number of unique colors in the image (as of IM 7.0.3.8)</td>
404 <td>%[colorspace]</td>
405 <td>Colorspace of Image Data (excluding transparency)</td>
408 <td>%[compression]</td>
409 <td>Image compression type (as of IM 7.0.3.8)</td>
412 <td>%[copyright]</td>
413 <td>ImageMagick Copyright String</td>
417 <td>depth of image for write (as input unless changed)</td>
420 <td>%[deskew:angle]</td>
421 <td>The deskew angle in degrees of rotation</td>
424 <td>%[directory]</td>
425 <td>directory part of filename (as %d)</td>
428 <td>%[distortion]</td>
429 <td>how well an image resembles a reference image (<a href="command-line-options.html#compare" >-compare</a>)</td>
433 <td>CALCULATED: entropy of the image</td>
436 <td>%[extension]</td>
437 <td>extension part of filename (as %e)</td>
441 <td>value of image gamma</td>
445 <td>??? window group ???</td>
449 <td>original height of image (when it was read in)</td>
452 <td>%[interlace]</td>
453 <td>Image interlace mode (as of IM 7.0.3.8)</td>
457 <td>CALCULATED: kurtosis statistic of image</td>
461 <td>label meta-data property</td>
464 <td>%[label:pointsize]</td>
465 <td>returns the pointsize computed during label: processing (as of IM 6.9.1-0)</td>
469 <td>coder used to read image (not the file suffix)</td>
473 <td>CALCULATED: maximum value statistic of image</td>
477 <td>CALCULATED: average value statistic of image</td>
481 <td>CALCULATED: minimum value statistic of image</td>
485 <td>The original name of the image</td>
489 <td>CALCULATED: is image fully-opaque?</td>
492 <td>%[orientation]</td>
493 <td>image orientation</td>
497 <td>Virtual canvas (page) geometry</td>
500 <td>%[profile:icc]</td>
501 <td>ICC profile info</td>
504 <td>%[profile:icm]</td>
505 <td>ICM profile info</td>
509 <td>list of any embedded profiles</td>
513 <td>Image quality value (as of IM 7.0.3.8)</td>
516 <td>%[rendering-intent]</td>
517 <td>Image rendering intent (as of IM 7.0.3.8)</td>
520 <td>%[resolution.x]</td>
521 <td>X density (resolution) without units</td>
524 <td>%[resolution.y]</td>
525 <td>Y density (resolution) without units</td>
529 <td>original scene number of image in input file</td>
533 <td>original size of image (when it was read in)</td>
537 <td>CALCULATED: skewness statistic of image</td>
540 <td>%[standard-deviation]</td>
541 <td>CALCULATED: standard deviation statistic of image</td>
545 <td>CALCULATED: image type</td>
549 <td>unique temporary filename ???</td>
553 <td>image resolution units</td>
557 <td>Version Information of this running ImageMagick</td>
561 <td>original width of image (when it was read in)</td>
565 <td>zero (unique filename for delegate use)</td>
571 <p>All other long forms of percent escapes (not single letter long form) are
572 handled in a case insensitive manner. Such escapes will will attempt to look
573 up that name specific data sources. </p>
575 <p>The primary search space (if not a specific attribute listed above) is
576 a free-form property string. Such strings are associated and saved with
577 images, and are typically set using either the <a href="command-line-options.html#set" >-set</a>
578 CLI option (or API equivalent), or from special convenience options
579 (such as <a href="command-line-options.html#label"
580 >-label</a>, <a href="command-line-options.html#comment"
581 >-comment</a>, <a href="command-line-options.html#caption"
584 <p>These convenience options are globally saved (as 'global options' so thay can
585 be set before images are read), and later are transfered to the property of
586 individual images, only when they are read in. At that time any internal
587 percent escape present is then handled. </p>
589 <p>To change a property of an image already in memory, you need to use <a
590 href="command-line-options.html#set" >-set</a>.
593 <p>Note that properties, like attributes (and profiles), are saved with
594 images when write, if the image file format allows. </p>
597 <h3>Artifacts and Options</h3>
599 <p>The previous percent escapes are associated with the primary Attributes and
600 Properties. Which is the original and primary focus of such percent escapes.
603 <p>However there are many operational settings that are used by various
604 ImageMagick operators that can be useful to set and later access. These
605 consist of per-image Artifacts, and Global options (associated with a list of
606 images, typically the current image list).</p>
608 <p>Note that the major difference between an artifact and a property is that
609 artifacts, being an internal operational setting, is not saved with images (if
610 such is possible). </p>
612 <p>For example when you use <code>-define 'distort:viewport=100x100'</code> you
613 are in fact generating a global option, which the <a href="command-line-options.html#distort"
614 >-distort</a> operator will use to modify its behavior (distorted output
617 <p>An Option is essentually a Artifact that has been stored globally as part
618 of a list of images (specifically a 'Wand' of images). As such they are
619 identical, in that a Option, is simply a global Artifact for all the
620 associated images. </p>
622 <p>As such you can use <code>-set 'option:distort:viewport' '100x100'</code> to
623 achieve the same result of setting a Artifact for the disort operation to use.
626 <p><b>Internal Handling of a Global Option...</b></p>
628 <p>The Core library ('MagickCore') does not generally directly understand
629 Global Options. As such, continuing the previous example, the
630 <code>DistortImages()</code> function only looks up an artifact to discover if
631 a 'viewport' has been provided to it. </p>
633 <p>How Global Options are used when a library function requests an Artifact is
634 one of the key differences between IMv6 and IMv7.</p>
636 <p>In <b>ImageMagick version 6</b>... before each operator, any global Options
637 are copied to per-image Artifacts, for every image in the current image list.
638 This allows various operators to find its operational 'defines' or Artifacts.
641 <p>In <b>ImageMagick version 7</b>... sets a link back to the global options
642 data, so that if a specific per-image Artifact is not found , then it will
643 look for a equivalent global Option for that image list. directly. This
644 saves coping these free-form options into artifacts repeatally, and means you
645 can now separately define a global option for a list, and a individual
646 overriding artifact for a specific image in that list. </p>
648 <p>Note that many API's that do not use Wands (PerlMagick for example using
649 arrays of images rather than a Wand). In these API's you will not have Global
650 Options, only per-image Artifacts. </p>
652 <p>In summery a Global Option, if available, is equivalent to a per-image
656 <h3>Glob-Pattern Listing of Properties, Artifacts and Options</h3>
658 <p>The <var>setting</var> can contain a glob pattern. As such you can
659 now list all free-form string properties, artifacts, and options, (but not
660 specific image attributes) using...</p>
662 <pre class="highlight"><code>convert ... \
663 -print "__Properties__\n%[*]" \
664 -print "__Artifacts__\n%[artifact:*]" \
665 -print "__Options__\n%[option:*]" \
669 <p> The format of glob patterns are very specific and as such is generally
670 only used to list specific settings, such as when debugging, rather than being
671 used for image processing use. </p>
674 <h3>Calculated Percent Escape Prefixes</h3>
676 <p>There are some special prefixes (before the first ':') which performs
677 calculations based on the user provided string that follows that prefix. For
678 example you can do a numerical calculation use <code>%[fx:...]</code> to
679 evaluate the given <a href="fx.html">FX</a> expressions:</p>
681 <pre class="highlight"><code>%[fx:<var>expression</var>]
684 <p>Use <code>pixel:</code> or <code>hex:</code> to evaluate a pixel color as defined by the <a
685 href="fx.html">FX</a>
688 <pre class="highlight"><code>%[pixel:<var>expression</var>]
691 <h3>Specific Profile Percent Escape Prefixes</h3>
693 <p>You can also use the following special formatting syntax to print EXIF
694 mage meta-data that was included in the image read in:</p>
696 <pre class="highlight"><code>%[EXIF:<var>tag</var>]
699 <p>Choose <var>tag</var> from the following:</p>
701 <pre class="pre-scrollable"><code>
702 * (print all EXIF tags, in keyword=data format)
703 ! (print all EXIF tags, in tag_number data format)
704 #hhhh (print data for EXIF tag #hhhh)
709 PhotometricInterpretation
729 PrimaryChromaticities
732 JPEGInterchangeFormat
733 JPEGInterchangeFormatLength
755 ComponentsConfiguration
756 CompressedBitsPerPixel
776 InteroperabilityOffset
778 SpatialFrequencyResponse
779 FocalPlaneXResolution
780 FocalPlaneYResolution
781 FocalPlaneResolutionUnit
789 <p>Surround the format specification with quotation marks to prevent your
790 shell from misinterpreting any spaces and square brackets.</p>
792 <p>The following special formatting syntax can be used to print IPTC
793 information contained in the file:</p>
795 <pre class="highlight"><code>%[IPTC:<var>dataset</var>:<var>record</var>]
798 <p>Select <var>dataset</var> and <var>record</var> from the following:</p>
800 <pre class="pre-scrollable:">
805 1:22 File Format Version
806 1:30 Service Identifier
809 1:60 Envelope Priority
812 1:90 Coded Character Set
813 1:100 UNO (Unique Name of Object)
819 2:03 Object Type Reference
820 2:05 Object Name (Title)
822 2:08 Editorial Update
824 2:12 Subject Reference
826 2:20 Supplemental Category
827 2:22 Fixture Identifier
829 2:26 Content Location Code
830 2:27 Content Location Name
835 2:40 Special Instructions
837 2:45 Reference Service
839 2:50 Reference Number
842 2:62 Digital Creation Date
843 2:63 Digital Creation Time
844 2:65 Originating Program
847 2:80 By-Line (Author)
848 2:85 By-Line Title (Author Position) [Not used in Photoshop 7]
852 2:100 Country/Primary Location Code
853 2:101 Country/Primary Location Name
854 2:103 Original Transmission Reference
858 2:116 Copyright Notice
860 2:120 Caption/Abstract
861 2:122 Caption Writer/Editor
862 2:125 Rasterized Caption
864 2:131 Image Orientation
865 2:135 Language Identifier
867 2:151 Audio Sampling Rate
868 2:152 Audio Sampling Resolution
871 2:200 ObjectData Preview File Format
872 2:201 ObjectData Preview File Format Version
873 2:202 ObjectData Preview Data
875 Pre-ObjectData Descriptor Record
877 7:20 Max Subfile Size
878 7:90 ObjectData Size Announced
879 7:95 Maximum ObjectData Size
884 Post ObjectData Descriptor Record
885 9:10 Confirmed ObjectData Size
889 </main><!-- /.container -->
890 <footer class="magick-footer">
891 <p><a href="security-policy.html">Security</a> •
892 <a href="architecture.html">Architecture</a> •
893 <a href="links.html">Related</a> •
894 <a href="sitemap.html">Sitemap</a> •
895 <a href="http://pgp.mit.edu/pks/lookup?op=get&search=0x89AB63D48277377A">Public Key</a>
897 <p><a href="support.html">Donate</a> •
898 <a href="escape.html#">Back to top</a> •
899 <a href="https://www.imagemagick.org/script/contact.php">Contact Us</a></p>
900 <p><small>© 1999-2018 ImageMagick Studio LLC</small></p>
903 <!-- Javascript assets -->
904 <script src="assets/magick.js" crossorigin="anonymous"></script>
905 <script>window.jQuery || document.write('<script src="assets/jquery.min.js"><\/script>')</script>
908 <!-- Magick Cache 15th December 2017 20:25 -->