Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old


Query a named attribute.

Component Version macOS Windows Linux Server iOS SDK
GraphicsMagick 2.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "GMImage.GetAttribute"; ImageRef; name { ; Encoding } )   More


Parameter Description Example Flags
ImageRef The image reference number. 1
name The name of the attribute.
Encoding The text encoding.
Default is UTF-8.
Possible encoding names: ANSI, ISO-8859-1, Latin1, Mac, Native, UTF-8, DOS, Hex, Base64 or Windows. More listed in the FAQ.
UTF8 Optional


Returns the value as string.


Query a named attribute.
Any number of named attributes may be attached to the image. For example, the image comment is a named image attribute with the name "comment". EXIF tags are attached to the image as named attributes. Use the syntax "EXIF:<tag>" to request an EXIF tag similar to "EXIF:DateTime":

Unicode characters are escaped with backslash followed by three digits. If encoding is UTF-8 for example the encoding \303\244 represents an "ä".

For IPTC keywords, better use GMImage.GetIPTCProfileValues to get all keywords.


Read EXIF DateTime:

MBS( "GMImage.GetAttribute"; $image; "EXIF:DateTime" )

Query IPTC Keywords:

MBS("GMImage.GetAttribute"; $img; "IPTC:2:25"; "UTF-8")

Query JPEG Quality used to compress image:

Set Variable [$img; Value:MBS("GMImage.NewFromContainer"; Image::InputImage)]
Set Variable [$value; Value:MBS("GMImage.GetAttribute"; $img; "JPEG-Quality")]
Show Custom Dialog ["JPEG Quality used to compress image"; $value]
Set Variable [$r; Value:MBS("GMImage.Release"; $img)]

Read PNG original color type:

MBS("GMimage.GetAttribute"; $image; "png:IHDR.color-type-orig")
// Value is combination of 0 = gray, 1 = palette, 2 = color, 4 = alpha
// e.g. 4 = Gray + Alpha, 6 = RGBA, 2 = RGB, 0 = Gray

Query JPEG Colorspace:

MBS("GMImage.GetAttribute"; $img; "JPEG-Colorspace-Name") & " " & MBS("GMImage.GetAttribute"; $img; "JPEG-Colorspace")
// the numbers are: 1 = grayscale, 2 = RGB, 3 = YCbCr, 4 = CMYK, 5 = YCCK

Show GPS location:

Set Variable [ $img ; Value: MBS("GMImage.NewFromContainer"; GraphicsMagick Exif::InputImage) ]
Set Variable [ $lat ; Value: MBS("GMImage.GetAttribute"; $img; "EXIF:GPSLatitude") ]
Set Variable [ $long ; Value: MBS("GMImage.GetAttribute"; $img; "EXIF:GPSLongitude") ]
Show Custom Dialog [ "GPS" ; $lat & " / " & $long ]
Set Variable [ $r ; Value: MBS("GMImage.Release"; $img) ]

See also

Release notes

Example Databases

Blog Entries

This function checks for a license.

Created 18th August 2014, last changed 24th February 2021

GMImage.GetAntiAlias - GMImage.GetAttributeNames