In my application I need to convert all images with (.png) format to (.jpg) format. I used the imwrite
function (one of Matlab's functions):
S=imread('D-1.png');
imwrite(S,'D-1.jpg');
and I can convert just one image... I need to convert all images and save them in a new folder. Could any one please let me know how I can do that? Is there are any changes in the properties of the image after convert it to the (.jpg) format?
Please forward your valuable suggestions.
Thanks
I take the suggestion from members and I tried the following coding so I was able to convert the (
.png
) format to (.jpg
) format:What you need to do is this:
dir
, which returns a structure with a componentname
.imwrite(S,'./newfolder/D-1.jpg')
.Are there any changes to the properties of the image after conversion ? In general yes, since there are differences in the information that png and jpeg encode. The Matlab help for functions
imread
andimwrite
explain some of this. You may find that you need, or want, to modify the image that you read before writing it.This here, combined with what you have should do the trick!