Hi,
We are using the following code to get jpeg image from dwg/dxf files and the process of loading and saving the image takes about 1 to 3 minutes to complete and it,s not acceptable for the customer.
We are using Aspose.CAD 20.1 and I can provide related AutoCad files.
Thanks for your consideration.
public static byte[ ] GetJpegImageFromAutoCadFile( Stream autoCadFileStream, bool forPrint, Size? imageSize = null )
{
var loadOptions = new Aspose.CAD.LoadOptions( );
if( forPrint )
loadOptions.DataBackgroundColor = Aspose.CAD.Color.White;
try
{
using( var cadImage = ( Aspose.CAD.FileFormats.Cad.CadImage ) Aspose.CAD.Image.Load( autoCadFileStream, loadOptions ) )
{
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions
{
AutomaticLayoutsScaling = true
};
if( imageSize != null )
{
rasterizationOptions.PageWidth = imageSize.Value.Width;
rasterizationOptions.PageHeight = imageSize.Value.Height;
}
if( forPrint )
rasterizationOptions.BackgroundColor = Aspose.CAD.Color.White;
// currently (with Aspose.CAD 20.1) saving CAD images can take a long time to complete. To improve that, after exprementing with some properties in different related objects, I could only find 'Quality' which had an effect on speed...
// ... so set the Quality to improve the speed of saving image
rasterizationOptions.Quality = new Aspose.CAD.ImageOptions.RasterizationQuality
{
Text = Aspose.CAD.ImageOptions.RasterizationQualityValue.Low,
Hatch = Aspose.CAD.ImageOptions.RasterizationQualityValue.Low,
Arc = Aspose.CAD.ImageOptions.RasterizationQualityValue.Low
};
var jpegOptions = new Aspose.CAD.ImageOptions.JpegOptions
{
VectorRasterizationOptions = rasterizationOptions
};
using( var jpegStream = new MemoryStream( ) )
{
cadImage.Save( jpegStream, jpegOptions );
return jpegStream.ToArray( );
}
}
}
catch( Exception ex )
{
if( ex is Aspose.CAD.CadExceptions.ImageLoadException ||
ex is Aspose.CAD.CadExceptions.ImageSaveException )
{
return null;
}
throw;
}
}
@user123321,
I have observed the issue shared by you and request you to please share the source file that you suspect to cause issue. Please also share the statistics achieved on your end along with machine specifications.
Thanks, I sent a message with the links and durations for you.
I don’t know exactly how much resources they had at the time of this test (it was a web server), but I know that it was CPU intensive and didn’t occupied a lot of RAM
@user123321,
I have been able to access 4 out of 5 files shared by you. Can you please check if file, “Faz_II.Setad_Farman-98.11.21.dxf” has been properly shared as I am unable to download it.
I sent new links for you.
Thanks.
@user123321,
I have tried accessing the link again and unfortunately getting the same issue again. I have tried 2 browsers. The following image appears when I try to click Download.
https://i.imgur.com/oT9umcw.png
Could you download the zipped version?
Is there any results?
@user123321,
I regret to share that I have tried 3 browsers on my end and I am unable to download file “Faz_II.Setad_Farman-98.11.21__1_.dxf”. I have followed the following link to and tried accessing from there but getting same issue over and over again on downloading. I have been able to download the other files but failing to download 22 MB file.
All of these files represents only one file: “Faz_II.Setad_Farman-98.11.21__1_.dxf” and “Faz_II.Setad_Farman-98.11.21.dxf” and “Faz_II.Setad_Farman-98.11.21.zip”. I only re-uploaded the same file, so you have more options to try downloading that particular file. So If you have the zipped version, that’s enough.
Anyway, even if you can’t access this particular file, some of the other files are more important (because they took more time for imaging process).
Please tell me the results, because we want to plan when we can resolve this for the customer.
Thanks
@user123321,
I have created an issue with ID CADNET-1068 in our issue tracking system to investigate the performance related observation shared by you for following files:
- Faz_II.Setad_Farman-98.11.21.zip (having dxf)
- 96.3.31-ghom2.dwg
- Faz_II.Setad_Farman-98.11.21.dwg
We have not been able to download the file Faz_II.Setad_Farman-98.11.21.dxf from your shared link. However, our team would like to have statistics achieved on your end in terms of memory consumption, CPU usages and Server specifications so that we may compare results in house that whether its a performance related issue or not.
Thank you
System specifiction was:
OS: Windows Server 2012 R2 x64
RAM: 32GB
CPU: Intel Xeon E3-1220 @ 3.10GHz
I don’t have access to that system now, but in another system and during this process, the CPU usage was high but RAM usage was not considerable.
@user123321,
Thank you for sharing the information. However, still we are interested in statistics achieved on your end to compare them while performing rendering on our end.