Hello
I converted some image with transparent area but output format have change the transparent are to white be below code in java.
try (Image image = Image.load(FPath)) {
JpegOptions options = new JpegOptions();
image.save(FOUT, options);
output++;
image.close();
}catch (Exception e) {
}
so can I remains transparent back ground ?
@David_jack, Jpeg format does not support transparency. If you want to obtain image with transparency you can save it to Png format. Here is example of it:
using (var image = (RasterImage)Aspose.Imaging.Image.Load(@"someFile"))
{
image.Save(
@"result.png",
new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
}
@samer.el-khatib4aspose
I am using Java
try (Image image = Image.load(FPath)) {
JpegOptions options = new JpegOptions();
image.save(FOUT, options);
output++;
image.close();
}catch (Exception e) {
}
I checked many option like PngOptions, BmpOptions but transparent are converted in white area .
So please suggest
I sent link of Input and output file and screen shot .
And same isuue in aspose pdf while converting image to pdf by below code
Document doc = new Document();
com.aspose.pdf.Page page = doc.getPages().add();
com.aspose.pdf.Image image1 = new com.aspose.pdf.Image();
image1.setImageStream(in);
doc.save(out);
@David_jack we have checked your files. File transaprentbackground.jpg is jpg file, jpeg does not support transparency at all. So, if you try to convert it to transparent png it won’t be transparent. Your second file input.png is transparent and we succesully converted it to transparent 32bpp png. Here is code that processed it:
using (var image = (RasterImage)Aspose.Imaging.Image.Load(@"input.png"))
{
image.Save(
@"result.png",
new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
}
Here is screenshot with result file: Dropbox - File Deleted - Simplify your life
@samer.el-khatib4aspose
i am using java
using (var image = (RasterImage)Aspose.Imaging.Image.Load(@“input.png”))
{
image.Save(
@“result.png”,
new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
}
this is not valid code so please suggest in java
thanks
@David_jack
Ok. I will try it soon and write to you my results.
@David_jack
Please note, that JPEG (JFIF) does not support transparency at all.
As for Png and Bmp, I have checked this code
Image image = Image.load("input.png");
try
{
image.save("output.png", new PngOptions(){{ setColorType(PngColorType.TruecolorWithAlpha);}});
}
finally
{
image.close();
}
And it produced output.png with correct transparency (but with a bigger size).
But the code
Image image = Image.load("input.png");
try
{
image.save("output.bmp", new BmpOptions());
}
finally
{
image.close();
}
Produced the file without transparency, and this is not correct (bug). So I created an issue IMAGINGNET-5002 in our ticket system.
The issues you have found earlier (filed as IMAGINGNET-5002) have been fixed in this update. This message was posted using Bugs notification tool by samer.el-khatib4aspose