question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compositing or extending a 32-bit magickImage caps the pixel values to 16-bit (65535)

See original GitHub issue

Magick.NET version

12.1.0.0

Environment (Operating system, version and so on)

Windows 10 x64 - Visual Studio 2019 v16.11.9

Description

Goal: merge two 32-bit images.

After extending a 32-bit image, all pixel values are capped to a value of 65535. After compositing a 32-bit image, the pixel values of the original image are correct (can be higher than 65535), but the pixel values of the new/added image are also capped at a value of 65535.

Steps to Reproduce

images.zip

  1. Download test images added as attachment
  2. Set path1 and path2 to the location of those images
  3. Call the functions below:

Example 1: Extent

static void ExtentImage(string path1, string path2)
{
            IMagickImage<float> image1 = new MagickImage(path1);
            IMagickImage<float> image2 = new MagickImage(path2);

            IMagickImage<float> result = new MagickImage(path1);
            result.Depth = 32; // already has a depth of 32, but added it just to be sure
            var pixels = result.GetPixelsUnsafe().GetValues(); // has pixel values above 65535

            result.Extent(image1.Width + image2.Width, image1.Height);
            var pixels_extent = result.GetPixelsUnsafe().GetValues(); // pixel values are not higher than 65535
}

Example 2: Composite

static void CompositeImage(string path1, string path2)
{
            IMagickImage<float> image1 = new MagickImage(path1);
            IMagickImage<float> image2 = new MagickImage(path2);

            IMagickImage<float> result = new MagickImage(path1);
            result.Depth = 32;
            var pixels = result.GetPixelsUnsafe().GetValues(); // has pixel values above 65535

            result.Composite(image2, image1.Width/2, 0, CompositeOperator.In);
            var pixels_comp = result.GetPixelsUnsafe().GetValues(); // old part of the image still has values above 65535, but new (added) image is capped at 65535
}

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dlemstracommented, Jan 11, 2023

In the next release clamping will be disabled by default when extending an image.

0reactions
CFekkescommented, Oct 18, 2022

Works like a charm, thanks a lot Dirk! Personally would disable the clamping for HDRI by default. It’s a bit confusing that this happens automatically.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Doesn't the Color Picker work in 16-bit mode?
When I switch Photoshop to 16-bit mode, the color picker seems to stay in 8-bit mode (the values only go up to 255...
Read more >
RE: Combining HDR/EXR files into a single PSD
I've been using Magick++ for a system which handles compositing image layers. ... See the example pixel value in the source EXR and...
Read more >
32bit exr file has incorrect bitdepth of 16. · Issue #479
I have a 32bit exr file with values [0-1]. ... I set it to TrueColorAlpha again the pixel values in the 32bit tiff...
Read more >
GraphicsMagick GM Utility
Name Mode Description 3FR r‑‑ Hasselblad Photo RAW 8BIM rw‑ Photoshop resource format 8BIMTEXT rw‑ Photoshop resource text format
Read more >
composite(1) — graphicsmagick-imagemagick-compat
Raw images are expected to have one byte per pixel unless gm is compiled in 16-bit quantum mode or in 32-bit quantum mode....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found