Saving an image with no gui

I'm trying to run a program in the background that periodically checks an archive for % completion and then creates a figure of some progress bars that I made. Everything works fine when I run it through the gui, but this is part of a much larger workflow than I'm setting up and having the gui run is just not an option. I need to run it in the background, and right now I'm using the command
$MATLAB/bin/matlab -nodisplay -nosplash -nodesktop
from my mac terminal.
Now, the problem is, when I run the program in this way, when I go to save the figure, it only grabs a small 560x420 rectangle in the middle, however, from the gui it grabs the full image (I forget exactly what it is, but it's 3-4k on the long side). I really want this to save the whole image both ways, but I don't know why this is happening. Below is how I'm saving the figure, for reference.
h = figure(1);
set(h,'OuterPosition', [0, 0, 1680, 1050])
Other code for filling figures
set(h, 'PaperPositionMode', 'auto')
saveas(h,'/Users/johnsalter/Dropbox/KeplerMaster/Progressbars','png')
Any ideas?

댓글 수: 3

Jeffrey Boucher
Jeffrey Boucher 2021년 3월 17일
편집: Jeffrey Boucher 2021년 3월 17일
Hello! Ten years later, I have this exact problem, except I was already using "print" instead of "saveas". As John said, this doesn't solve the problem. Anyone have any ideas now? One difference for me is I am using linux. Also, honestly, the most likely scenario here is that I go on to investigate this myself and post an answer when I figure it out, but in case anyone who knows a lot about print and/or nodisplay mode glances at this comment before I finish, I would appreciate the time-saver
Image Analyst
Image Analyst 2021년 3월 17일
Have you tried exportgraphics() or copygraphics(), available with r2020a or later?
Jeffrey Boucher
Jeffrey Boucher 2021년 3월 17일
편집: Jeffrey Boucher 2021년 3월 17일
I have not, I will look into those, thanks! If they work, I'll let you know.

댓글을 달려면 로그인하십시오.

답변 (2개)

Quattro
Quattro 2011년 8월 17일

0 개 추천

Hi Steven,
Maybe this peace of code will help you. I used this code to save images without showing/plotting them, because I also wanted to run the script in the background or server side open remote window, though on Windows machines....
figure, imshow(<yourimage>),
set(gca, 'position', [0 0 1 1], 'visible', 'off')
% hold on % optional
% text(10,10,<'yourtext'>, <more props to set>,'');
% hold off
I = getframe(gcf);
I=frame2im(I);
fullname=sprintf('%s/%s',<yourpath>,<yourfilename>);
imwrite(I,fullname,'Quality',100);
Success,
Quattro
Oliver Woodford
Oliver Woodford 2011년 8월 17일

0 개 추천

Use print instead of saveas.

댓글 수: 1

John
John 2011년 8월 17일
it saves it as a little bigger than saveas but still not the whole image

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Printing and Saving에 대해 자세히 알아보기

태그

질문:

2011년 8월 16일

편집:

2021년 3월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by