Save a .fig image to a .jpg image while maintaining size and resolution
Show older comments
I report the code I am using.
open_fig = openfig('figure_fig.fig');
filename = 'figure_jpg.jpg';
saveas(open_fig, filename);
open_jpg = imread('figure_jpg.jpg');
figure();
image(open_jpg);
I do not understand why the .jpg figure I am going to show does not keep the same size as the .fig figure (449x512x3 uint 8). The .jpg figure has, with this code, the dimensions 704x870x3 uint 8 quite different from those of the .fig figure.

I tried using the imresize command but it did not bring any results.
B = imresize(open_jpg,[449 870]);
figure();
image(B);
2 Comments
Jan
on 29 Oct 2022
Do you want to save the contents of the figure or of the axes?
JPEGs do not store a resolution, but a certain number of pixels.
Alberto Acri
on 29 Oct 2022
Edited: Alberto Acri
on 29 Oct 2022
Accepted Answer
More Answers (0)
Categories
Find more on Printing and Saving 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!