Why do I get an error when I am writing large "TIFF" files using "imwrite" ?
6 views (last 30 days)
Show older comments
MathWorks Support Team
on 6 Jul 2023
Answered: MathWorks Support Team
on 10 Jul 2023
While attempting to use the "imwrite" function to save large images, I encountered an error message stating:
Error using imwrite>validateSizes (line 557)
Images must contain fewer than 2^32 - 1 bytes of data.
Error in imwrite (line 71)
validateSizes(data);
Size of the images that I am using to write is ~9GB. Is there an alternative to "imwrite" interface for writing big TIFF files?
Accepted Answer
MathWorks Support Team
on 17 Apr 2024
The "imwrite" interface for TIFF format has a limitation where it can only handle writing files up to 4GB (2^32-1) in size. To handle larger files, it is advisable to opt for the more modern "BigTIFF" format for writing files.
Steve Eddins elaborated on this topic in a blog post found at
In the blog post, Steve Eddins provides an explanation of the benefits of "BigTIFF" and offers a practical workflow example of how to use it with MATLAB. It is important to take note of the 'w8' mode when creating the Tiff object to effectively handle "BigTIFF" files.
imdata = imread('example.tif');
% 'w' will create a classic TIFF file
% 'w8' will create a BigTIFF file
% This option is the only differentiator when writing to these two formats.
bt = Tiff('myfile.tif','w8');
0 Comments
More Answers (0)
See Also
Categories
Find more on Image Data in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!