We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose.Imaging is not working on larger Images

I want to resize the image using C#. But the Image class is not working on larger Images. So I chose to use Aspose.Imaging as it is mentioned that it supports larger files. But it shows the same exception when i try to upload larger Images.

Below is my code:

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(filePath))
{
image.Resize(300, 300);
image.Save();
}

Kindly advice me if anyone knows about Aspose.Imaging for Dotnet

Hi Sam,


Thank you for considering Aspose APIs.

I am afraid, we need more information to properly investigate your presented scenario and to assist you further in this regard. First of all, we need the problematic sample for our testing therefore please upload the sample in an archive to any free file hosting services such as Dropbox/Google Drive or your own server and provide the link here for us to download. Secondly, we need to know what exception have you faced while re-sizing the sample. Please provide the Inner Exception message along with complete stack trace for thorough investigation.

That being said, in case you are trying the scenario with any previous release of Aspose.Imaging for .NET API then we strongly recommend you to try it against the latest version 3.0.0.

Hi,

Thank you for the speedy reply. Below are the requested details

I have attached sample at https://www.dropbox.com/s/hwj3oquedzytfiv/Aspose%20Sample.rar?dl=0

Exception occurring is: Cannot allocate image in memory. Image size exceeds memory size



Stack trace for this sample attached:
at ​. (Rectangle )
at ​ .LoadRawData(Rectangle , RawDataSettings , IPartialRawDataLoader )
at ​ .LoadPartialArgb32Pixels(Rectangle , IPartialArgb32PixelLoader )
at Aspose.Imaging.RasterImage.. (Rectangle )
at .(Rectangle , , , Int32 , Int32 )
at .(Rectangle , )
at Aspose.Imaging.RasterImage.LoadPixelsInternal(Rectangle rectangle, IPartialArgb32PixelLoader pixelLoader)
at Aspose.Imaging.RasterImage.(Rectangle , Int32[] , Boolean , IPartialArgb32PixelLoader )
at Aspose.Imaging.RasterImage.(Rectangle , Boolean , IPartialArgb32PixelLoader )
at Aspose.Imaging.RasterImage.LoadPartialArgb32Pixels(Rectangle desiredRectangle, IPartialArgb32PixelLoader pixelLoader)
at .(RasterCachedImage , Int32 , Int32 , ResizeType )
at Aspose.Imaging.RasterCachedImage.Resize(Int32 newWidth, Int32 newHeight, ResizeType resizeType)
at Aspose.Imaging.Image.Resize(Int32 newWidth, Int32 newHeight)
at Aspose_Sample.WebForm1.Page_Load(Object sender, EventArgs e) in C:\Users\samazpan.d\Desktop\Aspose Sample\Aspose Sample\WebForm1.aspx.cs:line 20

Hi Sam,


Thank you for providing the sample image. We have downloaded the archive and currently evaluating the presented scenario. We will shortly get back to you with updates in this regard.

Please do not remove the download link as we may also require to pass the sample to the product team.

Thank you for taking this issue forward. Waiting for your update on this.

Hi Sam,


Thank you for your patience.

We have evaluated the presented scenario while using your provided sample project & image. We are able to replicate the OutOfMemory exception in Web Forms application, however, this problem does not arise if the application is of type Console or Windows Forms. I believe the cause is that the Web Forms applications rely on the virtual memory allocated in the Application Pool of the IIS. In case of the Console & Windows Forms applications, the process is allowed to use all the available memory.

Please note, Aspose.Imaging APIs claim to handle large images due the fact that it provides caching facility, that means; if the machine has less amount of available memory then you can direct the API to use the physical disc to store the temporary data. While enabling the caching, you can easily avoid the OutOfMemory problem, however, the caching does not seem to be working in Web Forms application therefore I have logged an investigative ticket IMAGING-34875 for the product team’s review. Please allow us some time to properly analyze the aforesaid scenario and get back to you with updates in this regard.

Thank you for your perusal Babar. Eagerly waiting for your response…

Hi Sam,


Sure, we will let you know as soon as we receive further updates from the product team. Please note, the aforesaid ticket is currently pending for analysis and is in the queue with other priority tasks therefore we will require some time for investigation after the ticket is scheduled for analysis.

In the meanwhile, I request you to please try the scenario in a console application while enabling & disabling the caching to see how API performs.

C#

Aspose.Imaging.Cache.CacheType = Aspose.Imaging.CacheType.CacheOnDiskOnly;
Aspose.Imaging.Cache.CacheFolder = @“D:\temp”;
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(filePath))
{
image.Resize(300, 300);
image.Save();
}

Hi Babar,

Thank you Barbar for this issue is in queue.

I checked both by disabling and enabling cache in console application. It shows same exception in both case at Image.Resize…

Thanks,
Sam Azpan

Hi Sam,


Thank you for trying out the scenario in console application. Could you please confirm the exception details and the amount of RAM installed on the machine where process is executing?

Hi Babar,

I have 8GB RAM.

This is an exception: Cannot allocate image in memory. Image size exceeds memory size

Exception details:
Aspose.Imaging.Exceptions.FrameworkException was unhandled
HResult=-2146233088
Message=Cannot allocate image in memory. Image size exceeds memory size
Source=Aspose.Imaging
StackTrace:
at ​. (Rectangle )
at ​ .LoadRawData(Rectangle , RawDataSettings , IPartialRawDataLoader )
at ​ .LoadPartialArgb32Pixels(Rectangle , IPartialArgb32PixelLoader )
at Aspose.Imaging.RasterImage.. (Rectangle )
at .(Rectangle , , , Int32 , Int32 )
at .(Rectangle , )
at Aspose.Imaging.RasterImage.LoadPixelsInternal(Rectangle rectangle, IPartialArgb32PixelLoader pixelLoader)
at Aspose.Imaging.RasterImage.(Rectangle , Int32[] , Boolean , IPartialArgb32PixelLoader )
at Aspose.Imaging.RasterImage.(Rectangle , Boolean , IPartialArgb32PixelLoader )
at Aspose.Imaging.RasterImage.LoadPartialArgb32Pixels(Rectangle desiredRectangle, IPartialArgb32PixelLoader pixelLoader)
at .(RasterCachedImage , Int32 , Int32 , ResizeType )
at Aspose.Imaging.RasterCachedImage.Resize(Int32 newWidth, Int32 newHeight, ResizeType resizeType)
at Aspose.Imaging.Image.Resize(Int32 newWidth, Int32 newHeight)
at AsposeCheck.Program.check() in C:\Users\samazpan.d\Desktop\Asked by Aspose\AsposeCheck\AsposeCheck\Program.cs:line 24
at AsposeCheck.Program.Main(String[] args) in C:\Users\samazpan.d\Desktop\Asked by Aspose\AsposeCheck\AsposeCheck\Program.cs:line 14
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.OutOfMemoryException
HResult=-2147024882
Message=Insufficient memory to continue the execution of the program.
InnerException:

Thank you,
Sam


Hi Sam,


Thank you for providing the exception details. We have discussed this matter with the product team and upon their confirmation a ticket with Id MAGING-34879 has been logged to investigate the matter further. Please allow us some more time for analysis, and get back to you with updates in this regard.

Hi again,


We have looked further into the matter of OutOfMemory error, and have noticed that the Aspose.Imaging APIs have poor optimization for the JPEG decoding procedure which needs to be fixed. Please note, with current implementation it does not matter whether caching is used or not, the only thing that matters is the image dimensions because the first procedure tries to decode the whole image but fails to fit the decoding intermediate data into memory therefore an exception is thrown that the decoding is not possible. We’ve tried same code with image converted to BMP format (using IrfanView) and have obtained the resized image. That means, the large image support works properly however, JPEG decoder (and probably PNG too, since they are similar) requires optimization that we will try our best to provide with next official release of Aspose.Imaging for .NET API.

Ok…Thank you.


The issues you have found earlier (filed as IMAGING-34875) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

The issues you have found earlier (filed as IMAGING-34879) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.