how to convert the format of images from '.jpg' to '.tif' format. Images are stored in a folder

Answers (2)

filenames = ls([path '*.jpg']);
for i=1:size(filenames ,1)
this = strtrim(filenames (i,:));
temp = imread([path this]);
this = this(1:end-4);
imwrite(temp,[path this '.tiff'],'tiff');
end

2 Comments

Using dir directly is much more efficient than parsing the output of ls, which write the results from dir to a string.
List = dir(fullfile(folder, '*.jpg'));
Name = {List.name};
jan simon plz write the exact code what should i do
folder='D:/Matlab/' ;% For example
f=dir([folder '*.jpg']);
for k=1:numel(f)
old_file=f(k).name;
new_file=strrep(old_file,'jpg','tif')
im=imread([folder old_file])
imwrite(im,[folder new_file])
end

This question is closed.

Asked:

on 23 Jul 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!