saving current figure?

Can anyone give suggestions about how to save the current figure with a specified DPI AND save it with the same dimensions it shows according to the axis. My current figure is 96 dpi and 1280 x 1024 pix and I want to save this (as a .jpg or .bmp) with the same properties. I also don't want to save the extra border around the figure (that is outside the figure handle).

"Jessica" wrote in message <jupo0m$kdk$1@newscl01ah.mathworks.com>...
> Hi,
>
> Can anyone give suggestions about how to save the current figure with a specified DPI AND save it with the same dimensions it shows according to the axis. My current figure is 96 dpi and 1280 x 1024 pix and I want to save this (as a .jpg or .bmp) with the same properties. I also don't want to save the extra border around the figure (that is outside the figure handle).
>
> Thanks

Unfortunately, the command "saveas(gcf,'test','jpg');" does not preserve the DPI and dimensions. I have found that "saveas(gca,'myfigure.eps','epsc');" works slightly better but I still have to (1) open the image in photoshop and adjust the dimensions and (2) the pixel dimensions are slightly off.
>
> "Jessica" wrote in message <jupo0m$kdk$1@newscl01ah.mathworks.com>...
> > Hi,
> >
> > Can anyone give suggestions about how to save the current figure with a specified DPI AND save it with the same dimensions it shows according to the axis. My current figure is 96 dpi and 1280 x 1024 pix and I want to save this (as a .jpg or .bmp) with the same properties. I also don't want to save the extra border around the figure (that is outside the figure handle).
> >
> > Thanks

"Jessica" wrote in message <jupo0m$kdk$1@newscl01ah.mathworks.com>...
> Hi,
>
> Can anyone give suggestions about how to save the current figure with a specified DPI AND save it with the same dimensions it shows according to the axis. My current figure is 96 dpi and 1280 x 1024 pix and I want to save this (as a .jpg or .bmp) with the same properties. I also don't want to save the extra border around the figure (that is outside the figure handle).
>
> Thanks

"Oliver Woodford" wrote in message <jurhqu$7tq$1@newscl01ah.mathworks.com>...
> "Jessica" wrote in message <jupo0m$kdk$1@newscl01ah.mathworks.com>...
> > Hi,
> >
> > Can anyone give suggestions about how to save the current figure with a specified DPI AND save it with the same dimensions it shows according to the axis. My current figure is 96 dpi and 1280 x 1024 pix and I want to save this (as a .jpg or .bmp) with the same properties. I also don't want to save the extra border around the figure (that is outside the figure handle).
> >
> > Thanks
>
> export_fig (http://www.mathworks.com/matlabcentral/fileexchange/23629-exportfig) does this if you save as png or tiff.

"Jessica" wrote in message <jurm3n$q3k$1@newscl01ah.mathworks.com>...
> "Oliver Woodford" wrote in message <jurhqu$7tq$1@newscl01ah.mathworks.com>...
> > "Jessica" wrote in message <jupo0m$kdk$1@newscl01ah.mathworks.com>...
> > > Hi,
> > >
> > > Can anyone give suggestions about how to save the current figure with a specified DPI AND save it with the same dimensions it shows according to the axis. My current figure is 96 dpi and 1280 x 1024 pix and I want to save this (as a .jpg or .bmp) with the same properties. I also don't want to save the extra border around the figure (that is outside the figure handle).
> > >
> > > Thanks
> >
> > export_fig (http://www.mathworks.com/matlabcentral/fileexchange/23629-exportfig) does this if you save as png or tiff.
>
> The figure I load is 1280 x 1024. When I save it with:
>
> export_fig test3.png -r96
>
> It outputs a figure with 96 dpi but with 684x547.
>
> When I save it with:
>
> export_fig test3.png -r96 -m2 or export_fig test3.png -r48 -m2
>
> It outputs a figure with 180 dpi and 1281 x 1025.
>
> Any suggestions for getting it to 96 dpi and 1280 x 1024?

Also, is it possible to use export_fig to save the file with a certain name:

On Thursday, July 26, 2012 2:29:15 PM UTC-4, Jessica wrote:
> Also, is it possible to use export_fig to save the file with a certain name:
>
> i=1; Filename=strcat('Picture',num2str(i),'.tiff');
>
> export_fig Filename -r96
>
> so that the file is called "Picture1" rather than "Filename"

-----------------------------------------
Use the function form
export_fig(Filename, '-r96');

"Jessica" wrote:
> > "Jessica" wrote in message <jupo0m$kdk$1@newscl01ah.mathworks.com>...
> > > Hi,
> > >
> > > Can anyone give suggestions about how to save the current figure with a specified DPI AND save it with the same dimensions it shows according to the axis. My current figure is 96 dpi and 1280 x 1024 pix and I want to save this (as a .jpg or .bmp) with the same properties. I also don't want to save the extra border around the figure (that is outside the figure handle).
> > >
> > > Thanks
> >
> > export_fig (http://www.mathworks.com/matlabcentral/fileexchange/23629-exportfig) does this if you save as png or tiff.
>
> The figure I load is 1280 x 1024. When I save it with:
>
> export_fig test3.png -r96
>
> It outputs a figure with 96 dpi but with 684x547.
>
> When I save it with:
>
> export_fig test3.png -r96 -m2 or export_fig test3.png -r48 -m2
>
> It outputs a figure with 180 dpi and 1281 x 1025.
>
> Any suggestions for getting it to 96 dpi and 1280 x 1024?

Hi Jessica

In MATLAB your figure doesn't have a dpi, only your screen does, and this is the dpi that export_fig uses. On my system the dpi is:
>> dpi = get(0, 'ScreenPixelsPerInch')

dpi =

96

So when I do:
>> figure('position', [0 0 1280 1024]);
>> plot(rand(3));
>> Filename = 'test.png';
>> export_fig(Filename, '-a1', '-nocrop');
the output is a png with a dpi of 96 and a size of 1280x1024, just as you want, and export_fig works as expected.

Given that export_fig returns an image with a dpi of 96 on your system, it must also have its dpi correctly set to 96. Therefore the only conclusion I can come to is that your figure is not 1280x1024, as you claim, but is smaller. Perhaps you are getting confused between figure size and resolution of an image in a figure - there is a big difference.

If you want to export a figure at 1280x1024 and 96dpi you need to set the figure size to 1280x1024 using:
>> set(gcf, 'Position', [0 0 1280 1024]);
before resaving the figure.

HTH,
Oliver

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.