Copy Clipping Path (Memory Friendly)

Adobe Resources Read Write Pipeline

Copies clipping path using memory-friendly Pipeline API.

Сode Snippet

// 2000-2997 Clipping path information
// http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/
const int FirstPathId = 2000;
const int LastPathId = 2997;

using (var reader = new JpegReader("Apple.jpg"))
using (var writer = new JpegWriter("CopyClippingPathMemoryFriendly.jpg"))
{
    if (reader.AdobeResources != null)
    {
        var adobeResources = new AdobeResourceDictionary();

        for (int i = FirstPathId; i <= LastPathId; i++)
        {
            if (reader.AdobeResources.Contains(i))
            {
                adobeResources[i] = reader.AdobeResources[i];
            }
        }

        writer.AdobeResources = adobeResources;
    }

    Pipeline.Run(reader + writer);
}

Input

Apple.jpg

Output

CopyClippingPathMemoryFriendly.jpg

For AI-assisted development: Download Graphics Mill Code Samples XML Catalog