Implementing a user-specified image property

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
rmagick
Posts: 245
Joined: 2006-03-16T17:30:48-07:00
Location: Durham, NC, USA

Implementing a user-specified image property

Post by rmagick »

I'm thinking about supporting a way for an RMagick user to specify an arbitrary string property to be assigned to an image immediately after the image is read or otherwise created. What I'm going for is a way to easily identify a specific image for debugging purposes. (You could, for example, assign the filename and current line number of the Ruby script.) Because of the way RMagick works, the property would have to be initially assigned to the ImageInfo structure and then propagated to the Image.

I'm thinking I could add the property - let's name it the "user" property - to the ImageInfo structure with SetImageOption. Immediately after AcquireImage/ReadImage/whatever returns, if the "user" property exists, then I'd copy it to the Image structure via SetImageArtifact.

Is this an appropriate use of the Core API? Is there a better way?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Implementing a user-specified image property

Post by magick »

ImageMagick supports four types of properties: global properties, image options, image properties, and image artifacts. Global properties are stored / retrieved from the registry. Image options, associated with the ImageInfo structure, become image artifacts when an image is instantiated (Image structure) so your proposal to use this mechanism within RMagick is sound. The difference between image properties and image artifacts is that properties are public and artifacts are private. Private, here simply means the key/value pair is used internally whereas properties might end up in the image format when its written to disk.
rmagick
Posts: 245
Joined: 2006-03-16T17:30:48-07:00
Location: Durham, NC, USA

Re: Implementing a user-specified image property

Post by rmagick »

Thanks for the info. I was wondering about the difference between artifacts and properties. It was very simple to add this code to RMagick.
Post Reply