Hi,Support:
Is there any method to convert an image to given colorbit as 1bit,4bit,8bit,16bi,24bit,32bit,48bit and 64bit and so, by Aspose.Imaging.dll api?
Thanks for your help!
Hi,Support:
Is there any method to convert an image to given colorbit as 1bit,4bit,8bit,16bi,24bit,32bit,48bit and 64bit and so, by Aspose.Imaging.dll api?
Thanks for your help!
@ducaisoft , Supported bit save mode depends on image format. For example you can save to png with different bit depth
using (RasterImage image = (RasterImage)Image.Load("c:\\Users\\USER\\Downloads\\signature.png"))
{
PngOptions option2 = new PngOptions();
option2.ColorType = PngColorType.Grayscale;
option2.BitDepth = 1;
image.Save(@"c:\Users\USER\Downloads\result.png", option2);
}
The same for other formats available for saving. More you can find in reference for formats as for png example - BitDepth | Aspose.Imaging for .NET API Reference
Thanks.
However, I use a jpg image to test it, only the 8 bit parameter will result ok, and others fail.
What’s wrong?
@ducaisoft , I’ve reproduced that for JPEG it works on 8 bits parameters, I’ve prepared task IMAGINGNET-6908 for investigation is there available other bits per channel modes for JPEG and based on it we will add corresponding tasks to support in library.
Thanks for your attention for this. It should support convering to any color bit and save as any type image such as bmp/jpg/png/gif/tif.
@ducaisoft , we will investigate this, but not sure that support will be common, it will depend on format.
Hi @ducaisoft,
Let me share the following information with you.
Firstly, I would like to draw attention to the fact that
Bits Per Pixels (BPP) - this is the size of 1 pixel in bits, e.g. RGB24 - 24bits: Red channel 8bits, Green channel 8bits, Blue channel 8bits.
Bit Depth (BitDepth) - the depth of only 1 color channel, e.g. Red. Thus BitPerPixel = 24 bits means BitDepth = 8 bits per channel - Red, Green, and Blue.
That is why JpegOptions.BitsPerChannel = 8 is the same as BmpOptions.BitsPerPixel = 24 (RGB)
Next, I would like to clarify the fact that different image storage formats support only their
limited set of colorbit storage, which is due to their specification and implementation features.
Pay attention to the specifications of the formats you are interested in.
BMP
BMP contains images in RGB/RGB. Grayscale and B/W formats are essentially the images with a palette containing RGB/RGBA colors
The following BitDepth are supported
Palette 1, 2, 4, 8
RGB 16, 24
RGBA 16, 24, 32
Aspose.Imaging support reading all of these formats and writing all of them except 2-bit Palette mode.
More detailed
JPEG
JPEG stores an image in Ycck/YCbCr/RGB formats, alpha channel is not supported at all according to its specification.
Since the image is stored divided into channels, the color depth is set for the channel (e.g. Y/Cb/Cr),
Jpeg supports only 8 and 12 bits per channel for lossy (that is, it can contain only RGB24/RGB36)
Jpeg supports 2-16 bits per channel for lossless (that is, it can contain only b/w, grayscale, RGB24/RGB48)
The JPEG specification supports
8 bits per channel for Baseline (Grayscale: 8bpp, RGB: 24bpp, CMYK: 32 bpp)
8/12 bits per channel for Progressive (Grayscale: 8/12bpp, RGB: 24/36bpp, CMYK: 32/36 bpp)
2 - 16 bits per channel for Lossless / JpegLS (Grayscale: 2/48bpp, RGB: 24/48bpp, CMYK: 32/48 bpp)
The alpha channel is not supported by the JPEG standard.
Most libraries and viewers support only 8 bits per channel for JPEG.
Aspose.Imaging supports
8 bits for Grayscale/RGB/CMYK/YCbCr
and
12 bits for Grayscale export only
More detailed
PNG
BMP contains images in RGB/RGB. Grayscale and B/W formats are essentially the images with a palette containing RGB/RGBA colors
The following BitDepths are supported
Palette 1,2,4,8
Grayscale 8/16
RGB 24/48
RGBA 32/64
Aspose.Imaging does not support RGB48 and RGB64
More detailed
GIF
GIF according to the standard supports only from 2 to 256 colors (1-8 BPP) using a palette.
GIF does not support the alpha channel
GIF does not support 16/24/32/48/64 BPP
More detailed
TIFF
TIFF can store the image in many different colorspaces (RGBA/CMYK/JPEG) each of them supports different BitDepth.
Aspose.Imaging allows to save in TIFF images with the following BitDepth
B/W, Grayscale - 1-8 bits (RGB, 24bits Palette)
RGB - 24/48 BPP (3 channels: R,G,B per 8 bits)
RGBA - 32/64 BPP (4 channels: A,R,G,B per 8 bits)
To summarize, the following conclusions can be drawn
Is there any method to convert an image to given colorbit as 1bit,4bit,8bit,16bi,24bit,32bit,48bit and 64bit and so, by Aspose.Imaging.dll api?
Yes, Aspose.Imaging can read images with 1-bit, 4-bit,8-bit,16-bit,24-bit, and 32-bit per pixel, for DICOM, TIFF 48/64bits.
Next, Aspose.Imaging can export the uploaded image to bmp/jpg/png/gif/tif formats, taking into account the specification of these formats, which can lead to conversion to other color fields and with a different number of bits per channel.
Thanks for your attention for this. It should support converting to any color bit and save as any type image such as bmp/jpg/png/gif/tif.
Aspose.Imaging provides all the possibilities to convert from format to format, however, BPP/BitDepth may differ due to the
requirements of the format to which the export is performed.
For each export format, there is a special class Options e.g. BmpOptions, GifOptions, etc.
Which is inherited from ImageOptionsBase. These configuration classes allow you to manage the export and get the most desired result in the end.
We admit that preparing ImageOptions for export can be a difficult task for those who know a little about
image storage formats, so we plan to implement an ImageOptionsFactory that will allow to set all the necessary settings in a single form, in understandable terms.