This documentation is for the old version. Go to the latest Graphics Mill docs

Loading and Saving Adobe Image Resource Blocks

Adobe® applications (Adobe® Photoshop® and the others) store metadata in special format called Adobe® image resource blocks. This metadata format is used to store non-pixel data associated with an image, such as image resolution, color management settings, clipping path and so on. Graphics Mill for .NET supports manipulation with Adobe image resource blocks for TIFF and JPEG image formats.

Understanding of Adobe Image Resource Blocks Format

The metadata format consists of independable pieces of structured data, each of them corresponds to information type defined in specification. Each piece of data (image resource block) consisits of the following fields:

  • Unique identifier;
  • Name;
  • Size of resource data;
  • Resource data.

Format in which resource data is stored depends on type of image resource block. All supported types of image resource blocks and their formats are listed in Adobe Photoshop File Format Specification.

Graphics Mill for .NET has two classes which deals with Adobe image resource blocks: AdobeResourceBlock and AdobeResourceDictionary. AdobeResourceBlock stores information about particular Image resource block: name, resource data and its size. Graphics Mill for .NET does not include tools for resource data manipulation. This class just stores it as a binary buffer and users should parse and construct it by themselves. AdobeResourceDictionary class represents collection of AdobeResourceBlock instances. This class is constructed as hash-table, which stores instances of AdobeResourceBlock and provides access to them by unique identifiers. These identifiers correspond to image resource block types and defined in specification.


No validation of the resource data internal structure is performed during encoding so user is responsible for providing correctly filled AdobeResourceBlock instances. Files which have been saved with incorrect Adobe® image resource blocks can produce errors during opening or processing in Adobe® applications.

Reading Adobe Image Resource Blocks

As mentoined above, Graphics Mill for .NET supports Adobe Image Resource Blocks metadata for TIFF and JPEG file formats. To extract the metadata you need to get AdobeResources property value of TiffReader or JpegReader instance. If an image on which the reader is opened contains Adobe Image Resource Blocks the property returns AdobeResourceDictionary collection storing image resource blocks, otherwise the property returns null. The code sample below demonstrates how to use these classes to extract metadata from image files.

Writing Adobe Image Resource Blocks

To write Adobe Image Resource Blocks metadata along with TIFF or JPEG image you need to prepare AdobeResourceDictionary collection filled in blocks needed to save. Then you just pass this collection to the AdobeResources property of opened TiffWriter or JpegWriter instance. The second way is to put Adobe® image resource blocks into TiffEncoderOptions or JpegEncoderOptions, and pass it to the Bitmap.Save method.

Example of Adobe Image Resource Blocks Usage

The following code sample demonstrates how to remove thumbnail from Adobe® image resource blocks and mark the image as copyrighted. Thumbnail block ID is 0x0409 and copyright flag ID is 0x040A.

Visual Basic
Dim srcFileName As String = "c:/mountain.jpg"
Dim dstFileName As String = "c:/mountain2.jpg"

' Open reader on the file you need to modify metadata for   
Dim reader As New Aurigma.GraphicsMill.Codecs.JpegReader(srcFileName)
Dim adobeResources As Aurigma.GraphicsMill.Codecs.AdobeResourceDictionary = reader.AdobeResources
If adobeResources Is Nothing Then
    adobeResources = New Aurigma.GraphicsMill.Codecs.AdobeResourceDictionary
End If

' Create new adobe image resource block with the required metadata
Dim arBlock As New Aurigma.GraphicsMill.Codecs.AdobeResourceBlock("Copyright", New Byte() {1})
' Set this block to the item with 0x040A ID (copyright flag)
adobeResources.Item(&H40A) = arBlock
' Remove a block with 0x0409 (thumbnail data)

' Write new bitmap and metadata
Dim writer As New Aurigma.GraphicsMill.Codecs.JpegWriter()
writer.AdobeResources = adobeResources

string srcFileName = @"c:/mountain.jpg";
string dstFileName = @"c:/mountain2.jpg";

using (Aurigma.GraphicsMill.Codecs.JpegReader reader = new Aurigma.GraphicsMill.Codecs.JpegReader())
    // Open reader on the file you need to modify metadata for  
    Aurigma.GraphicsMill.Codecs.AdobeResourceDictionary adobeResources = reader.AdobeResources;
    if (adobeResources == null)
        adobeResources = new Aurigma.GraphicsMill.Codecs.AdobeResourceDictionary();
    // Create new adobe image resource block with the required metadata
    Aurigma.GraphicsMill.Codecs.AdobeResourceBlock arBlock = new
        Aurigma.GraphicsMill.Codecs.AdobeResourceBlock("Copyright", new byte[] { 1 });
    // Set this block to the item with 0x040A ID (copyright flag)
    adobeResources[0x040A] = arBlock;
    // Remove a block with 0x0409 (thumbnail data)

    // Write new bitmap and metadata
    using (Aurigma.GraphicsMill.Codecs.JpegWriter writer = new Aurigma.GraphicsMill.Codecs.JpegWriter())
        writer.AdobeResources = adobeResources;

See Also