GMImage.GetAttribute
--------------------

Query a named attribute.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [GraphicsMagick](component_GraphicsMagick.md) | [2.0](newinversion20.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "GMImage.GetAttribute"; ImageRef; Name { ; Encoding } ) 

**MBS**( **"GMImage.GetAttribute";** /\* Query a named attribute. \*/  
**$ImageRef**; /\* The image reference number.e.g. 1 \*/   
**$Name**; /\* The name of the attribute. \*/   
**$Encoding**) /\* Optional; The text encoding.  
Default is UTF-8.e.g. UTF8 \*/ 

### Parameters

| 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](https://www.monkeybreadsoftware.com/filemaker/faq.shtml). | UTF8 | Optional |

### Result

Returns the value as string.

### Description

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:&lt;tag&gt;" 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 "ä". This changed in v15.3 where the plugin automatically decodes this.  
  
For IPTC keywords, better use [GMImage.GetIPTCProfileValues](GMImageGetIPTCProfileValues.md) to get all keywords.  
### Examples

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](GMImageNewFromContainer.md)"; 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](GMImageRelease.md)"; $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") &amp; " " &amp; 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](GMImageNewFromContainer.md)"; 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 &amp; " / " &amp; $long \]   
Set Variable \[ $r ; Value: MBS ("[GMImage.Release](GMImageRelease.md)"; $img ) \]  
Get all Exif values as list with name=value:

 Set Variable \[ $tag ; Value: "\*" \]  
Set Variable \[ $value ; Value: MBS ("GMImage.GetAttribute"; $img ; "EXIF:" &amp; $tag ) \]  
<small>  
Example result:   
Make=Apple  
Model=iPhone 4S  
Orientation=1  
...</small>Get all Exif values as list id=value:

 Set Variable \[ $tag ; Value: "!" \]  
Set Variable \[ $value ; Value: MBS ("GMImage.GetAttribute"; $img ; "EXIF:" &amp; $tag ) \]  
<small>  
Example result:   
\#010f=Apple  
\#0110=iPhone 4S  
\#0112=1  
...</small>Get an EXIF vsalue based on hex noted id:

 Set Variable \[ $tag ; Value: "#0110" \]  
Set Variable \[ $value ; Value: MBS ("GMImage.GetAttribute"; $img ; "EXIF:" &amp; $tag ) \]  
<small>  
Example result: iPhone 4S</small>### See also

- [GMImage.GetAttributeNames](GMImageGetAttributeNames.md)
- [GMImage.GetAttributesJSON](GMImageGetAttributesJSON.md)
- [GMImage.GetComment](GMImageGetComment.md)
- [GMImage.GetIPTCProfile](GMImageGetIPTCProfile.md)
- [GMImage.GetIPTCProfileValues](GMImageGetIPTCProfileValues.md)
- [GMImage.New](GMImageNew.md)
- [GMImage.NewFromContainer](GMImageNewFromContainer.md)
- [GMImage.Release](GMImageRelease.md)
- [GMImage.SetAttribute](GMImageSetAttribute.md)

### Release notes

- **Version 15.3**
    - Improved [GMImage.GetAttribute](https://www.mbsplugins.eu/GMImageGetAttribute.shtml) and [GMImage.GetAttributesJSON](https://www.mbsplugins.eu/GMImageGetAttributesJSON.shtml) to decode high characters in text values.
- **Version 9.2**
    - Added [GMImage.GetAttributeNames](http://www.mbsplugins.eu/GMImageGetAttributeNames.shtml) and [GMImage.GetAttributesJSON](http://www.mbsplugins.eu/GMImageGetAttributesJSON.shtml) functions.

### Example Databases

- [GraphicsMagick/GraphicsMagick Exif](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/GraphicsMagick/GraphicsMagick%20Exif.shtml#1ScriptAnchor_)
- [GraphicsMagick/GraphicsMagick IPTC](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/GraphicsMagick/GraphicsMagick%20IPTC.shtml#1ScriptAnchor_)

### Blog Entries

- [Goodies 38: Copy calculation text as html or styled text](https://www.monkeybreadsoftware.com/filemaker/SyntaxColoring/38-Copycalculationtextashtmlorstyledtext.shtml)
- [MBS FileMaker Plugin, version 15.3pr1](https://www.mbsplugins.de/archive/2025-06-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [GraphicsMagick in FileMaker, part 19](https://www.mbsplugins.de/archive/2022-12-19/GraphicsMagick_in_FileMaker_pa/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 18th August 2014 , last changed 20th May 2025

  
[GMImage.GetAntiAlias](GMImageGetAntiAlias.md) - [GMImage.GetAttributeNames](GMImageGetAttributeNames.md)

[HTML Version](GMImageGetAttribute.shtml)