How can a change image format like .jpg to .png by using loops and with out use of 'imwrite' command

10 views (last 30 days)
In MATLAB we have a command "IMWRITE" to change the format but my problem is what's going behind, when we are using 'IMWRITE' command in the program.

Answers (2)

Stephen23
Stephen23 on 1 Apr 2017
Edited: Stephen23 on 3 Apr 2017
imwrite does not require any toolboxes (it is standard MATLAB), so why do you not want to use it?
If you want an alternative, consider Oliver Woodford and Yair Altman's highly regarded FEX submission:
  3 Comments
Image Analyst
Image Analyst on 1 Apr 2017
Then you'll have to look up the official format and use fwrite() to write out the image "manually" byte by byte yourself, that is, if you're allowed to use fopen(), fwrite(), and fclose().
Walter Roberson
Walter Roberson on 1 Apr 2017
Please post the specific requirements of the project. There is no point in our making proposals that might be rejected because you forgot to mention a restriction.
For example if the reason you cannot use imwrite is that you need generate code for an FPGA and that does not support imwrite then that would be important information because FPGA does not support file i/o at all.

Sign in to comment.


KSSV
KSSV on 1 Apr 2017
You can rename your image file .jpg to .png. doc movefile.
  8 Comments
Stephen23
Stephen23 on 1 Apr 2017
Edited: Stephen23 on 1 Apr 2017
>> X = ones(1,1,3)/2;
>> imwrite(X,'test.jpg','jpg');
>> S = imfinfo('test.jpg'); S.Format
ans =
jpg
>> movefile('test.jpg','test.png')
>> S = imfinfo('test.png'); S.Format
ans =
jpg
Changed the file extension, no change in file format.
To Anyone Else: this "answer" does not work
KSSV
KSSV on 3 Apr 2017
@ Stephen Cobeldick
I have checked renaming file within matlab and without matlab and then used iminfo, yes the format didn't change.
Your doctorate should have taught you that you can investigate things like this yourself: it would only take one minute. I was renaming image files like this earlier for web uploads, I was in misconception. Thank you for for the point.

Sign in to comment.

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!