Skip to content

Commit

Permalink
Added example about reading a thumbnail from a raw image.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemstra committed Nov 9, 2023
1 parent 0a30193 commit 8068d80
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
1 change: 1 addition & 0 deletions Magick.NET.sln
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{6D1DE15B-E
docs\LosslessCompression.md = docs\LosslessCompression.md
docs\ReadingImages.md = docs\ReadingImages.md
docs\Readme.md = docs\Readme.md
docs\ReadRawThumbnail.md = docs\ReadRawThumbnail.md
docs\ResizeImage.md = docs\ResizeImage.md
docs\UsingColors.md = docs\UsingColors.md
docs\Watermark.md = docs\Watermark.md
Expand Down
29 changes: 29 additions & 0 deletions docs/ReadRawThumbnail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Read raw thumbnail

## Read thumbnail from raw image

```C#
// Setup DNG read defines
var defines = new DngReadDefines
{
ReadThumbnail = true
};

// Create empty image
using var image = new MagickImage();

// Copy the defines to the settings
image.Settings.SetDefines(defines);

// Read only meta data of the image
image.Ping(SampleFiles.StillLifeCR2);

// Get thumbnail data
var thumbnailData = image.GetProfile("dng:thumbnail")?.GetData();

if (thumbnailData != null)
{
// Read the thumbnail image
using var thumbnail = new MagickImage(thumbnailData);
}
```
2 changes: 2 additions & 0 deletions docs/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ provide you with some help on how to use Magick.NET.
- [Exif data](ExifData.md)
- Read exif data
- Create thumbnail from exif data
- [Read raw thumbnail](ReadRawThumbnail.md)
- Read thumbnail from raw image
- [Lossless compression](LosslessCompression.md)
- Lossless compress JPEG logo
- [Detailed debug information](DetailedDebugInformation.md)
Expand Down
37 changes: 37 additions & 0 deletions samples/Magick.NET.Samples/ReadRawThumbnail.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright Dirk Lemstra https://github.com/dlemstra/Magick.NET.
// Licensed under the Apache License, Version 2.0.

using ImageMagick;
using ImageMagick.Formats;

namespace Magick.NET.Samples;

public static class ReadRawThumbnailSamples
{
public static void ReadRawThumbnail()
{
// Setup DNG read defines
var defines = new DngReadDefines
{
ReadThumbnail = true
};

// Create empty image
using var image = new MagickImage();

// Copy the defines to the settings
image.Settings.SetDefines(defines);

// Read only meta data of the image
image.Ping(SampleFiles.StillLifeCR2);

// Get thumbnail data
var thumbnailData = image.GetProfile("dng:thumbnail")?.GetData();

if (thumbnailData != null)
{
// Read the thumbnail image
using var thumbnail = new MagickImage(thumbnailData);
}
}
}

0 comments on commit 8068d80

Please sign in to comment.