Skip to content

Instantly share code, notes, and snippets.

@jwt625
Created January 27, 2024 04:11
Show Gist options
  • Save jwt625/4715a5ea82e4c0d7348ad247ba1ff562 to your computer and use it in GitHub Desktop.
Save jwt625/4715a5ea82e4c0d7348ad247ba1ff562 to your computer and use it in GitHub Desktop.
convert tif to png in matlab
% Get a list of all TIF files in the current folder
tifFiles = dir('*.tif');
% Loop through each TIF file
for i = 1:length(tifFiles)
% Read the TIF file
tifFileName = tifFiles(i).name;
tifData = imread(tifFileName);
% Convert to PNG
pngFileName = strrep(tifFileName, '.tif', '.png');
imwrite(tifData, pngFileName);
% Display a message
disp(['Converted and saved: ' pngFileName]);
end
disp('Conversion complete.');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment