---
title: "Copy Clipping Path (Memory Friendly)"
canonical: https://www.graphicsmill.com/samples/Metadata/ClippingPath/CopyClippingPathMemoryFriendly_cs
product: "Graphics Mill"
source: "Metadata/ClippingPath/CopyClippingPathMemoryFriendly.cs"
---

# Copy Clipping Path (Memory Friendly)

Copies clipping path using memory-friendly Pipeline API.

## Instruction

Copy specific Adobe resources (clipping paths) from a JPEG image and save it as a new JPEG using memory-friendly processing.

## Usings

```csharp
using Aurigma.GraphicsMill.Codecs;
```

## Code Snippet

```csharp
// 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);
}
```

## Explanation

The code:

- Reads a JPEG image and checks for Adobe resources (clipping paths).
- Copies the specified clipping path resources (from `FirstPathId` to `LastPathId`) to a new `AdobeResourceDictionary`.
- Saves the image with the copied Adobe resources to a new JPEG file using memory-friendly pipeline processing.

## Tags

- [Adobe Resources](<https://www.graphicsmill.com/samples/tags/adobe-resources_md>): Working with Adobe image resource blocks
- [Pipeline](<https://www.graphicsmill.com/samples/tags/pipeline_md>): Working with images via the Pipeline API
- [Read](<https://www.graphicsmill.com/samples/tags/read_md>): Reading images with codecs
- [Write](<https://www.graphicsmill.com/samples/tags/write_md>): Writing images with codecs

## Input

- [Apple.jpg](<https://www.graphicsmill.com/samples/Metadata/compiled/Debug/Apple_jpg>) (preview)

## Output

- [CopyClippingPathMemoryFriendly.jpg](<https://www.graphicsmill.com/samples/Metadata/compiled/Debug/CopyClippingPathMemoryFriendly_jpg>) (preview)

## Used APIs

- [Aurigma.GraphicsMill.Codecs.AdobeResourceDictionary](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_AdobeResourceDictionary.htm.md>)
- [Aurigma.GraphicsMill.Codecs.ImageReader.AdobeResources](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Codecs_ImageReader_AdobeResources.htm.md>)
- [Aurigma.GraphicsMill.Codecs.JpegReader](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_JpegReader.htm.md>)
- [Aurigma.GraphicsMill.Codecs.JpegWriter](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_JpegWriter.htm.md>)
- [Aurigma.GraphicsMill.Codecs.JpegWriter.AdobeResources](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Codecs_JpegWriter_AdobeResources.htm.md>)
- [Aurigma.GraphicsMill.Codecs.MetadataDictionary.Contains(Object)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Codecs_MetadataDictionary_Contains_1_d02429b3.htm.md>)
