hgexport file appears to be damaged or corrupted

2 views (last 30 days)
I have a figure that I am formatting in my script which I would like to save as a jpg/bmp/png from the script, but preserve the formatting.
I defined the figure and formatting:
fig1=figure('units','normalized','outerposition',[0 0 1 1]);
then plotted several things, and tried to output:
hgexport(fig1,'Test.bmp','units','normalized','outerposition',[0 0 1 1])
The figure is created as a bmp in the working directory, but when I try to open the image I get the message "Windows Photo Viewer can't open this picture because the file appears to be damaged, corrupted, or is too large". I get the same message if trying to open the image in paint or powerpoint.
Is there some other way to save the figure as an image from the script and preserve the formatting? I have also tried saveas and print, but the formatting/size is wrong. I am on R2015b.
Thanks

Answers (1)

Walter Roberson
Walter Roberson on 6 Jul 2017
"hgexport(fig,filename) writes figure fig to the EPS file filename."
You have a EPS file named as a .bmp
  2 Comments
Josh
Josh on 6 Jul 2017
Is there a way to save my figure to an image file other than Eps and preserve the format?
Walter Roberson
Walter Roberson on 6 Jul 2017
No, not unless you count a .fig file as being an "image file". Every other image file type is static and will lose some information compared to what MATLAB knows.
If you were to indicate particular information that needed to be preserved, there is a possibility that someone might have ideas.
Did you try export_fig from the File Exchange ?

Sign in to comment.

Categories

Find more on Printing and Saving in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!