---
title: "Crop Image And Preserve Clipping Path"
canonical: https://www.graphicsmill.com/samples/Metadata/ClippingPath/CropImageAndPreserveClippingPath_cs
product: "Graphics Mill"
source: "Metadata/ClippingPath/CropImageAndPreserveClippingPath.cs"
---

# Crop Image And Preserve Clipping Path

Crops image and preserves clipping path.

## Instruction

Crop the image and preserve the clipping path while saving the result as a JPEG file.

## Usings

```csharp
using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;
```

## Code Snippet

```csharp
using (var reader = new JpegReader("Apple.jpg"))
using (var writer = new JpegWriter("CropImageAndPreserveClippingPath.jpg"))
using (var crop = new Crop(reader.Width / 6, 0, reader.Width / 2, reader.Height / 2))
{
    writer.AdobeResources = reader.AdobeResources;

    Pipeline.Run(reader + crop + writer);
}
```

## Explanation

The code:

- Reads the "Apple.jpg" image file.
- Crops the image using specified coordinates while preserving its clipping path.
- Saves the cropped image as "CropImageAndPreserveClippingPath.jpg" while retaining the Adobe resources (including clipping path).

## Tags

- [Adobe Resources](<https://www.graphicsmill.com/samples/tags/adobe-resources_md>): Working with Adobe image resource blocks
- [Crop](<https://www.graphicsmill.com/samples/tags/crop_md>): Cropping images
- [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

- [CropImageAndPreserveClippingPath.jpg](<https://www.graphicsmill.com/samples/Metadata/compiled/Debug/CropImageAndPreserveClippingPath_jpg>) (preview)

## Used APIs

- [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.Transforms.Crop](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Transforms_Crop.htm.md>)
