Save Properties

Hello,
Some questions on save options, if you don’t mind please?

Property BitsPerPixel is ReadOnly, so how to set the big depth of saved images, ie 16-bits vs 24-bits vs 32-bits vs 48-bits vs 64-bits

How to set the DPI when saving?

And is there any Boolean property to enable/disable these 3 when saving?
Grayscale - Anti Aliasing - High Quality Rendering Mode

Thanks :slight_smile:

@australian.dev.nerds , derived from ImageOptionsBase classes are used for specifying bitsPerPixel property for image export. For example take a look at:
https://reference.aspose.com/imaging/net/aspose.imaging/imageoptionsbase/
https://reference.aspose.com/imaging/net/aspose.imaging.imageoptions/pngoptions/
https://reference.aspose.com/imaging/net/aspose.imaging.imageoptions/bmpoptions/
https://reference.aspose.com/imaging/net/aspose.imaging.imageoptions/tiffoptions/

As for Anti Aliasing and High Quality Rendering Mode options control you should set ImageOptionsBase.VectorRasterizationOptions for Vector format images:
https://reference.aspose.com/imaging/net/aspose.imaging.imageoptions/vectorrasterizationoptions/
or Graphics class properties for Rasters:
https://reference.aspose.com/imaging/net/aspose.imaging/graphics/

1 Like

Hello and thanks, however, the docs won’t specify valid values for BitDepth properties of:
png:
https://reference.aspose.com/imaging/net/aspose.imaging.imageoptions/pngoptions/bitdepth/
bmp:
https://reference.aspose.com/imaging/net/aspose.imaging.imageoptions/bmpoptions/bitsperpixel/
tiff:
https://reference.aspose.com/imaging/net/aspose.imaging.imageoptions/tiffoptions/bitsperpixel/

And I didn’t find the b/w or grayscale property for:
TiffOptions / TgaOptions / GifOptions / BmpOptions / Jpeg2000Options
Do they have a boolean property for grayscale saving?
Thanks :slight_smile:

@australian.dev.nerds ,
use PngOptions.ColorType property to set BitsPerPixel (TruecolorWithAlpha = 32, Truecolor = 24, other are 1 - 8). By the way, one of upcoming releases is going to contain updated PngOptions class with more informative code docs.

As for TIFF, this format uses more advanced options. Take a look here, consider TiffOptions(TiffExpectedFormat) ctor and BitsPerSample property: Manipulating TIFF Images|Documentation
You are getting grayscale export image due to using TiffOptions ctor with TiffExpectedFormat.Default resulting a BW. Try using new TiffOptions(TiffExpectedFormat.Jpeg) to keep color, take a look at code reference.

This thing with ‘Grayscale’ is about using default TiffOptions, other formats preserve colors by default or can be configured to export a grayscale. Please take a look at the different image options specs. You could also take a look at Grayscale | Aspose.Imaging for .NET API Reference.

1 Like

Thanks a lot, so if I understand you correctly, for:

TgaOptions / GifOptions / BmpOptions / Jpeg2000Options

There’s no direct grayscale property, and I will have to try cast to image to RasterImage, set Grayscale and then save?

If true, how do you think about registering a feature request ticket for:
TgaOptions / GifOptions / BmpOptions / Jpeg2000Options
direct grayscale boolean property, so won’t need additional rasterimage cast, like other formats?
Best.

@australian.dev.nerds , you should explore specs of different options:

  • PngOptions/JpegOptions have grayscale color modes;
  • some other formats do not support Grayscale mode as a part of specification, so indeed you should RasterImage.Grayscale() and then specify export options.
1 Like

Thanks,

yep, I wonder why JpegOptions has but Jpeg2000Options does not have .ColorType
They’re similar formats though…

@australian.dev.nerds , JPEG and JP2000 are not the same formats, but the thing is that our Jpeg2000Image currently supports only RGB colorspace (24-bpp) on save/export.

1 Like

A dcm file which is 87.5 mb and saved by Photoshop when loaded into Aspose to be saved as jpeg, will not succeed:
Aspose.Imaging.CoreExceptions.ImageSaveException
Image saving failed.
Smaller files saved by the same Photoshop will be loaded, a known issue?

Same thing happens when saving as Tga:
Aspose.Imaging.CoreExceptions.ImageSaveException
Image saving failed.

If load a dng to be saved as jpg, a black border line is painted in the left and top of result image! Also known?

Thanks :slight_smile:

@australian.dev.nerds , would you mind to share the code examples and the files you are using that raise exceptions? So we can test it out.

1 Like

Hello,
Seems if images are a little large such errors will happen, please be so kind and check these 2 error in a project which seem to be bugs:

@australian.dev.nerds , let me test your sample. You will be answered shortly!

1 Like

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

Issue ID(s): IMAGINGNET-6729,IMAGINGNET-6730

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

Hello, any idea about the above 2 issues? :slight_smile:

@australian.dev.nerds due our free support requests fix planned not earlier than end q2-q3.