
Capture original dimensions in an ImageMagick filename: property before an operation changes the image if those original dimensions belong in the output name. A filename expression evaluated later can otherwise describe a different processing state. Decide whether the name should record the input or the final artifact.
The set option reference documents dimension capture and the filename: prefix required for output-name substitution. The property reference explains current dimensions and expansion behavior.
Define what the filename should assert
For a hypothetical cropped source, a name containing the original width and height is provenance information. A name claiming final dimensions is a description of the saved output. Those labels can legitimately differ, but they should not be interchangeable.
Choose a property name that describes the intended state, such as filename:source_size. A generic key called size makes a later command harder to interpret when both source and output dimensions are involved.
Capture the value before the state changes
This proposed POSIX-shell example uses a built-in demonstration image:
magick rose: -set filename:source_size '%wx%h' -crop 20x20+0+0 +repage 'crop-from-%[filename:source_size].png'
The stored property is set before cropping. The final output name therefore identifies the captured source-size state, rather than making a promise about the crop's final dimensions.
The example has not been executed. Use a new destination and adapt quoting to the actual shell. If two sources share the same dimensions, this name alone is not unique; retain a source identifier or another deliberate collision strategy.
Compare capture time with output time
Move the capture only when its meaning should change. Capturing after the crop is appropriate if the filename should record that later size, but calling it source_size would then be misleading.
Do not confuse a filename: property with an ordinary comment or label that happens to contain dimensions. The manual restricts output filename modification to the documented prefix.
Verify both the name and file properties
Read the actual output dimensions independently, then compare the saved filename with the intended naming assertion. A file can have a correctly formatted name that accurately records an earlier state while containing a smaller final image.
The source-to-product filename mapping guide explains why a convenient technical label does not replace asset identity. Keep that mapping in the approved version record if this output enters a delivery.
No file has been generated or inspected here. This procedure concerns the point of property expansion, not a universal naming convention or automatic collision prevention.
Related tasks
- How Do I Keep AI Product Images Matched to the Correct SKU?
- How Do I Keep the Approved AI Image or Video from Getting Lost Among Revisions?
Sources and scope
- ImageMagick Command-line Options: set: Capture dimensions in a filename:-prefixed property before changing the image; the point at which -set expands the value determines the stored label.
- ImageMagick Command-line Processing: Immediate operators, persistent settings and isolated image stacks have different command-line scope.
This guide follows official ImageMagick 7 documentation captured on October 23, 2026 (Asia/Shanghai), whose site identifies release 7.1.2-34. Examples are proposed and have not been executed. Confirm the installed build, available formats and actual shell quoting before use.
Prepared by Imagild Editorial, the company editorial team responsible for these guides. AI assisted research and drafting. This is documentation-based guidance with proposed examples, not a claim of hands-on testing or an independent product review. Report a correction.
Cover: Pignatta / Pixabay, Pixabay Content License. This is an illustrative source photograph, not an application screenshot or a generated test result.