How to find and utilize a "built-in method % static method or namespace function"
Show older comments
I have a piece of code that uses the MEX file tifflib.mexw64. Up through R2024a, this file could be found at $matlabroot\toolbox\matlab\matlab_images\tiff\private\tifflib.mexw64.
However, beginning in R2024b, this file no longer ships with MATLAB, which causes my code to fail.
I think I have identified the source of the issue by examining the built-in class Tiff.m, which also utilizes tifflib.mexw64. In the 2024a version, this mex file is accessed using the command tifflib(<args>). But in the 2025a version, the call is to matlab.internal.imagesci.tifflib(<args>). I tried to determine where the function resides by typing
which("matlab.internal.imagesci.tifflib")
on the command line in R2025a. The output is
"tifflib is a built-in method % static method or namespace function"
I don't understand this output. Does it mean that tifflib.mex no longer exists as a stand-alone file and is now bundled into the matlab code itself, somehow?
My main goal is to continue to use tifflib functions without modifying my code. I could, of course, change all of my tifflib calls to point to matlab.internal.imagesci.tifflib(<args>), but I suspect that would break backwards compatibility. The easiest solution might be to copy the tifflib that ships with R2025a (if I can locate it) to a /private folder where my code can access it. But I'm open to other approaches as well. Thanks for any alternative suggestions on how to deal with this.
1 Comment
Steven Lord
39 minutes ago
I caution you that your approach (both using the old private function and using the internal function) may be fragile. The documentation describes the internal namespace:
MathWorks® reserves the use of namespaces named internal. Code contained in namespaces named internal is intended for MathWorks use only, and use of this code is discouraged. This code is not guaranteed to work in a consistent manner from one release to the next. Any of these functions and classes can be removed from the MATLAB software in any subsequent release without notice.
For private functions, because they generally can only be used by code in their parent folder, they may not have as much error checking (depending on the code in the parent folder to pass in the correct inputs) as a non-private function. And because they are intended mostly as utilities for the files in their parent folder, they too could change or be removed without notice (as the MEX-file you were using was.)
If there are operations you want to perform on tiff files that the Tiff class does not support, I recommend you send your use cases (what operations you want to perform that Tiff and other tiff-related functions in MATLAB do not support and how you use those operations in your workflow) to Technical Support and ask them to enter that information into the enhancement request database for consideration for inclusion as a documented function in a future release.
Answers (1)
Stephen23
about 1 hour ago
Yes, your interpretation is correct. The output:
tifflib is a built-in method % static method or namespace function
means that tifflib has been compiled directly into MATLAB's core engine (a native shared library, likely part of the imagesci infrastructure). It no longer exists as a discrete .mexw64 file on disk that you can locate, copy, or redistribute. This is a deliberate architectural change by TMW.
So your instinct to "find and copy the MEX file" won't work: there's nothing to copy.
Best Solution: A Shim tifflib.m in a private Folder
The cleanest approach that requires zero changes to your existing code is to create a shim function named tifflib.m and place it in a private subfolder adjacent to your code. MATLAB's function resolution always checks private folders first, so your existing tifflib(...) calls will transparently be intercepted and forwarded.
1. Create the folder structure:
%your_project/
% your_code.m
% private/
% tifflib.m ← create this
2. Create private/tifflib.m (untested):
function varargout = tifflib(varargin)
% Compatibility shim: redirects legacy tifflib() calls to the new
% internal namespace introduced in R2024b.
try
[varargout{1:nargout}] = matlab.internal.imagesci.tifflib(varargin{:});
catch
[varargout{1:nargout}] = tifflib(varargin{:});
end
end
Categories
Find more on ThingSpeak 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!