Bug in processing .Dng images

Hi,
I load a .dng image and save it to another format, 2 issues:

  1. The saved final image is too dark, even if I apply NormalizeHistogram nothing happens!
  2. The top and left corners have a little black space!
    See the snapshot:

Bug.jpg (287.1 KB)

@australian.dev.nerds

It seems you are experiencing issues with saving .DNG images, specifically regarding the output being too dark and having black spaces in the corners. Here are some suggestions to address these problems:

  1. Adjusting Brightness: If the saved image appears too dark, you might want to apply additional image processing techniques to enhance the brightness. While you mentioned using NormalizeHistogram, consider using other methods such as adjusting the brightness or contrast of the image before saving it. Unfortunately, the provided context does not specify how to do this directly, but you can explore the image processing capabilities of the Aspose.Imaging library to find suitable methods.

  2. Handling Black Corners: The black spaces in the corners could be a result of how the image is being cropped or processed. Ensure that the entire image area is being utilized when saving. You might want to check if there are any settings in the image options that control the output dimensions or cropping behavior.

Here is a basic example of how to load a .DNG image and save it as a JPEG using Aspose.Imaging, which you can modify to include additional processing steps:

using Aspose.Imaging;
using Aspose.Imaging.FileFormats.Dng;
using Aspose.Imaging.ImageOptions;

class Program
{
    static void Main()
    {
        string sourceFilePath = "Path_to_your_dng_file.dng";
        string destFilePath = "Path_to_save_your_image.jpg";

        // Load the DNG image
        using (DngImage image = (DngImage)Image.Load(sourceFilePath))
        {
            // Here you can apply additional processing like brightness adjustment

            // Save the image as JPEG
            image.Save(destFilePath, new JpegOptions());
        }
    }
}

Make sure to replace the file paths with your actual file locations. If you continue to face issues, consider checking the Aspose.Imaging documentation for more advanced image processing techniques or reaching out to the community for specific use cases.

If you have further questions or need more detailed assistance, feel free to ask!

Please advise if this generic algorithm is fine for loading all image types and save as all image types.

I also could load a dng to Image, then cast Image to RasterCachedImage and it works
But can’t cast that Image to RasterCachedMultipageImage

Using src As Image = Image.Load(sourceST, loadOpt)

Using rast As RasterCachedImage = TryCast(src, Aspose.Imaging.RasterCachedImage)
rast.CacheData
rast.Grayscale
rast.NormalizeHistogram

Select Case saveFormat
 Case Dng
  Using dest As FileFormats.Dng.DngImage = TryCast(rast, FileFormats.Dng.DngImage)
   dest.Save...
 Case Jpg
  Using dest As FileFormats.Jpeg.JpegImage = TryCast(rast, FileFormats.Jpeg.JpegImage)
   dest.Save...
... and go on ...

Is it fine for all formats?
Only Dng cannot cast to RasterCachedMultipageImage
Even Dng can cast to RasterCachedImage

Please show a workaround to cast Dng to RasterCachedMultipageImage
And perhaps a great idea to make it possible.

When Dng can cast to RasterCachedImage, then preventing RasterCachedMultipageImage is meaningless.

Thank you very much :slight_smile:

Oh and loading Dng then saving it as Psd discards all metadata and exif info :frowning:

@australian.dev.nerds , we are reviewing your request. You will be answered shortly!

Hello, @australian.dev.nerds ,
Dng is a single page format so it can not be casted to RasterCachedMultipageImage. As concerns Dng metadata loss after exporting to Psd, Dng does not currently support metadata processing. Our apologies for any inconvenience.

Thanks, but all other formats can be casted to RasterCachedMultipageImage!
Is Bmp multipage? So why it can cast to RasterCachedMultipageImage?!

Great logic anyway :smiley:

@australian.dev.nerds ,
BmpImage extends RasterCachedImage, so it can not be casted to RasterCachedMultipageImage:

Hope this helps!

Nice, because I tested that and it worked! Let’s see what your AI assistance told in this thread:

  1. RasterCachedImage vs. RasterCachedMultipageImage:

If you are unsure whether the image is single or multi-page, it is safer to use RasterCachedMultipageImage. This way, you can handle both scenarios without issues, even if the current image is not multi-page.

I think it’s better you take some time to test and learn your own sdk first :smiley:

Thanks.

@australian.dev.nerds ,
We will review your request. You will be answered shortly.

@australian.dev.nerds ,
Unfortunately, our AI forum assistant answer was a bit incorrect. You may check an Image instance class using safe casting to avoid any exceptions.
You could also take a look at Imaging Api Reference:

Hope this helps!

1 Like

Thanks, just please confirm the bug in the first post, black edges in the top/left corners when converting Dng images to other formats and assign the ticket no.
Also Dng contains important metadata/exif info, it’s a disaster when convcerting Dng to other formats those data are lost, not a bad idea to register a ticket for that.
Finally, do you know the magic number of Dng images for file detection?
Thanks.

@australian.dev.nerds
We did not manage to reproduce the issue with the black border in Dng. Would you mind to share an image sample, so we can reproduce the issue?

We have opened the following new ticket(s) for Dng matadata in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): IMAGINGNET-7665

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

1 Like

Hi,
Here you go, made by Adobe DNG itself from Canon RAW file, anyway, as you know, Dng files can have a thumbnail or preview jpec attached to them, once when converting from Dng, this preview small sized thumbnail was converted, instead of Dng itself, that’s not expected.

( This Dng does not have that preview thumbnail )
Dng.zip (185 Bytes)

After the conversion, please check the heavily darkened color tone of source vs destination.

@australian.dev.nerds
Thank you for these details, we will take them into account.

1 Like

Thanks, were you able to see the black border bug?

@australian.dev.nerds
We will review your request. You will be answered shortly.