Re: imwrite png DPI
- From: Richard Quist <rquist_nospam@xxxxxxxxxxxxx>
- Date: Thu, 31 Jan 2008 13:34:10 -0500
Simon Hilsenbeck wrote:
Hello,
using imwrite i want to save a png image with 300 DPI.
imwrite(rand(100,100),'dpiTest.png', 'png', 'XResolution',
300, 'YResolution', 300);
But the resolution specification seems to be ignored. The
file is saved with 96 DPI.
imagesc(rand(100,100)); print('-f1', '-r300', '-dpng',
'dpiTest.png');
This works, but i do not want the space around pictures,
common when images are displayed as figures.
How to save an image without border as png with 300 DPI?
Thank you.
Are you able to adjust the position of the axes so it fills more of the figure before printing it?
%create my figure
figure;
imagesc(rand(100,100));
%save current axes position
axpos = get(gca, 'position');
%expand axes to fill figure window
outerpos = get(gca, 'outerposition');
insetpos = get(gca, 'tightinset');
set(gca, 'position', [insetpos(1) insetpos(2) ...
outerpos(3)-insetpos(3) outerpos(4)-insetpos(4)]);
%create output file
print('-f1', '-r300', '-dpng','dpiTestx.png');
%restore axes position
set(gca, 'position', axpos);
If you didn't want the axes at all you could set the position to be [0 0 1 1] to completely fill the interior of figure window (assuming the units are normalized, of course)
--
Richard Quist
Software Developer
The MathWorks, Inc.
.
- References:
- imwrite png DPI
- From: Simon Hilsenbeck
- imwrite png DPI
- Prev by Date: Plotting question
- Next by Date: x in place of s
- Previous by thread: imwrite png DPI
- Next by thread: Passing Values to a popup
- Index(es):
Relevant Pages
|