You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been a long time user of ImageSharp for all my imaging needs, so when I started a recent project using satellite imagery and drone footage, I once again came back to this library.
The images I'm working with are large geographical TIFF images, also known as orthomosaics. They can be stitched together from numerous other images, and as a result can become quite large (some of our current images are north of 1.5GB).
I'd like to use ImageSharp to transform, transcode and "tile" these images into smaller images, but when I attempt to load one of these images, I get the following exception:
Unhandled exception. SixLabors.ImageSharp.InvalidImageContentException: Cannot decode image. Failed to allocate buffers for possibly degenerate dimensions: 0x0.
---> SixLabors.ImageSharp.Memory.InvalidMemoryOperationException: Attempted to allocate a buffer of negative length=-227135488.
at SixLabors.ImageSharp.Memory.InvalidMemoryOperationException.ThrowNegativeAllocationException(Int64 length)
at SixLabors.ImageSharp.Memory.UniformUnmanagedMemoryPoolMemoryAllocator.Allocate[T](Int32 length, AllocationOptions options)
Debugging this, I can see the following number of bytes being allocated every time:
62424
15606
15606
262144
-227135488
Which I assume is four metadata allocations, followed by an allocation for the actual (overflowed size) image data.
Given that the TIFF I'm trying to load is 740MB, I fail to see why it would need to allocate over 2.14GB of memory to process the image. Other libraries such as GDAL are perfectly fine loading these images in an instant, but don't offer the image manipulation I need.
Is this a limitation with ImageSharp specifically? Is there something I'm doing wrong and is there a way to use these images with ImageSharp?
I've explored making my own fork of ImageSharp and replacing the allocation with just flat direct allocations as I'd be running this from a command line so the heap would never be long-lived, but it seemed like a non-trivial modification so I'd like to make sure there aren't any more sensible approaches.
Can provide sample files if needed.
The text was updated successfully, but these errors were encountered:
ImageSharp v3.1.6
Discussed in #2870
Originally posted by aevitas January 27, 2025
Hi,
I've been a long time user of ImageSharp for all my imaging needs, so when I started a recent project using satellite imagery and drone footage, I once again came back to this library.
The images I'm working with are large geographical TIFF images, also known as orthomosaics. They can be stitched together from numerous other images, and as a result can become quite large (some of our current images are north of 1.5GB).
I'd like to use ImageSharp to transform, transcode and "tile" these images into smaller images, but when I attempt to load one of these images, I get the following exception:
Debugging this, I can see the following number of bytes being allocated every time:
Which I assume is four metadata allocations, followed by an allocation for the actual (overflowed size) image data.
Given that the TIFF I'm trying to load is 740MB, I fail to see why it would need to allocate over 2.14GB of memory to process the image. Other libraries such as GDAL are perfectly fine loading these images in an instant, but don't offer the image manipulation I need.
Is this a limitation with ImageSharp specifically? Is there something I'm doing wrong and is there a way to use these images with ImageSharp?
I've explored making my own fork of ImageSharp and replacing the allocation with just flat direct allocations as I'd be running this from a command line so the heap would never be long-lived, but it seemed like a non-trivial modification so I'd like to make sure there aren't any more sensible approaches.
Can provide sample files if needed.
The text was updated successfully, but these errors were encountered: