Implementing a user-specified image property
Posted: 2008-10-26T15:24:02-07:00
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?
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?