hello, we have a problem converting a psd file into png (psd in attachment - the problem seems to be related to image size 2000x300px)
the resultant png contains a blank border, how we can avoid this behaviour
converting to pdf do not cause this kind of issue
thank you
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(sourceFileName))
{
// Cast image object to PSD image
var psdImage = (Aspose.Imaging.FileFormats.Psd.PsdImage)image;
// Create an instance of PngOptions class
var pngOptions = new PngOptions();
pngOptions.ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.TruecolorWithAlpha;
}
sorry, my mistake
actually the problem is conversion from pdf to image
we convert PSD files to pdf and then from generated pdf to images
so the code we use is this
Aspose.Pdf.Devices.Resolution ResolutionP = new Aspose.Pdf.Devices.Resolution(m_iResolution); //120
Aspose.Pdf.Devices.PngDevice PngDeviceP = new Aspose.Pdf.Devices.PngDevice(ResolutionP); PngDeviceP.Process(((Aspose.Pdf.Document)m_oDocument).Pages[++_iPageIndex], _oOutputStream); //page index = the unique pdf page of pdf file
so the pdf generated file is without blank border but the png generated file from pdf has a blank area in the right (i attach the result png file)
Hi Valerio,
Thanks for the details. We are further investigating the issue.
Is not it feasible for you to convert PSD to image directly?
Best Regards,
we tested in some cases (and tiff/psd is one of this) we gain more speed converting from original document to pdf and then from pdf to images: for some documents we use to convert in images and in pdf, for some other like psd we use to convert to pdf and then from pdf to images having 30% average more speed as if we use the first aproach.
moreover the problem of black area happens only with this file with particular dimensions.
Hi Valerio,
Thanks for the details. We are investigating it.
Best Regards,
Hi Valerio,
Can you please also share your complete code (i.e. convert PSD to PDF and then PDF to PNG) and the PDF file generated at your end?
Best Regards,
yes sure
render pdf as image(s)
Aspose.Pdf.Devices.Resolution ResolutionP = new Aspose.Pdf.Devices.Resolution(120);
Aspose.Pdf.Devices.PngDevice PngDeviceP = new Aspose.Pdf.Devices.PngDevice(ResolutionP);
PngDeviceP.Process(((Aspose.Pdf.Document)m_oDocument).Pages[++_iPageIndex], _oOutputStream);
render doc as pdf
Aspose.Imaging.ImageOptions.PngOptions OptionsI = new Aspose.Imaging.ImageOptions.PngOptions();
OptionsI.ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.TruecolorWithAlpha;
Aspose.Imaging.ResolutionSetting oResI = new Aspose.Imaging.ResolutionSetting(Convert.ToDouble(120), Convert.ToDouble(120));
OptionsI.ResolutionSettings = oResI;
using (MemoryStream oMTempStream = new MemoryStream())
{
((Aspose.Imaging.Image)m_oDocument).Save(oMTempStream, OptionsI);
Aspose.Pdf.Document oPdf = new Aspose.Pdf.Document();
Aspose.Pdf.Page oPage = oPdf.Pages.Add();
oPage.PageInfo.Width = m_OPageSize.Width;
oPage.PageInfo.Height = m_OPageSize.Height;
oPage.PageInfo.Margin.Bottom = 0;
oPage.PageInfo.Margin.Top = 0;
oPage.PageInfo.Margin.Left = 0;
oPage.PageInfo.Margin.Right = 0;
double dResizeFactor = 0;
double dXsize = 0;
double dYsize = 0;
dResizeFactor = (((Aspose.Imaging.Image)m_oDocument).Width / m_OPageSize.Width > ((Aspose.Imaging.Image)m_oDocument).Height / m_OPageSize.Height) ? ((Aspose.Imaging.Image)m_oDocument).Width / m_OPageSize.Width : ((Aspose.Imaging.Image)m_oDocument).Height / m_OPageSize.Height;
dXsize = ((Aspose.Imaging.Image)m_oDocument).Width / dResizeFactor;
dYsize = ((Aspose.Imaging.Image)m_oDocument).Height / dResizeFactor;
if (((Aspose.Imaging.Image)m_oDocument).Width > ((Aspose.Imaging.Image)m_oDocument).Height)
{
double iW = oPage.PageInfo.Width;
double iH = oPage.PageInfo.Height;
oPage.PageInfo.Width = iH;
oPage.PageInfo.Height = iW;
if ((((Aspose.Imaging.Image)m_oDocument).Width > oPage.PageInfo.Width) && (((Aspose.Imaging.Image)m_oDocument).Height > oPage.PageInfo.Height))
{
oPage.MediaBox = new Aspose.Pdf.Rectangle(0, 0, dXsize, dYsize);
oPage.CropBox = new Aspose.Pdf.Rectangle(0, 0, dXsize, dYsize);
}
else
{
oPage.MediaBox = new Aspose.Pdf.Rectangle(0, 0, ((Aspose.Imaging.Image)m_oDocument).Width, ((Aspose.Imaging.Image)m_oDocument).Height);
oPage.CropBox = new Aspose.Pdf.Rectangle(0, 0, ((Aspose.Imaging.Image)m_oDocument).Width, ((Aspose.Imaging.Image)m_oDocument).Height);
}
}
else
{
if ((((Aspose.Imaging.Image)m_oDocument).Width > oPage.PageInfo.Width) && (((Aspose.Imaging.Image)m_oDocument).Height > oPage.PageInfo.Height))
{
oPage.MediaBox = new Aspose.Pdf.Rectangle(0, 0, dXsize, dYsize);
oPage.CropBox = new Aspose.Pdf.Rectangle(0, 0, dXsize, dYsize);
}
else
{
oPage.PageInfo.Width = ((Aspose.Imaging.Image)m_oDocument).Width;
oPage.PageInfo.Height = ((Aspose.Imaging.Image)m_oDocument).Height;
oPage.MediaBox = new Aspose.Pdf.Rectangle(0, 0, ((Aspose.Imaging.Image)m_oDocument).Width, ((Aspose.Imaging.Image)m_oDocument).Height);
oPage.CropBox = new Aspose.Pdf.Rectangle(0, 0, ((Aspose.Imaging.Image)m_oDocument).Width, ((Aspose.Imaging.Image)m_oDocument).Height);
}
}
Aspose.Pdf.Image oImage = new Aspose.Pdf.Image();
oPage.Paragraphs.Add(oImage);
oImage.ImageStream = new MemoryStream(oMTempStream.ToArray());
oPdf.Save(_oOutputStream);
} //using
Hi Valerio,
Thanks for the details. We will share the updates on this issue soon.
Best Regards,
Hi Valerio,
Yes this is the same issue we experience, the extra white space on the right side, as the sample image we share some posts ago
This seems to not to happen when converting PSD to PNG or PSD to PDF but it happens when convert PSD to PDF and then from generated PDF to PNG.
Hi Valerio,
Thanks for the additional information. I have logged an issue in our issue tracking system as PDFNEWNET-40901 to investigate the white space issue and also linked your request to it. We will keep you updated via this thread regarding the issue status.
We are sorry for the inconvenience caused.
Best Regards,
hello, any news about it?
Hi Valerio,
hi, any news about it?
thank you
Hi Valerio,
again no news?
Hi Valerio,
once again, any news about it?
such a long time is passed…
Hi Valerio,
We are sorry for this delay and inconvenience.