-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsave_as_jpeg.m
44 lines (38 loc) · 1.33 KB
/
save_as_jpeg.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
% function [] = save_as_jpeg(data_path_prefix, location, prefix, identifier, data_type, resolution, postfix, paper_position)
%
% Author: Stephanie Kemna
% Institution: University of Southern California
% Date: June 29, 2017
%
% last tested with MatlabR2018a on Ubuntu 16.04
%
function [] = save_as_jpeg(data_path_prefix, location, prefix, identifier, data_type, resolution, postfix, paper_position)
% process parameters
res_str = ['-r' num2str(resolution)];
if nargin < 8
paper_position = [0 0 20 12];
end
disp('Printing jpeg...')
% save jpeg
set(gcf,'PaperUnits','inches','PaperPosition',paper_position)
% construct filename
if ( data_path_prefix(length(data_path_prefix)) ~= '/' )
if ( exist('postfix','var') == 1 )
filenm = [data_path_prefix '_' location '_' prefix '_' identifier '_' data_type '_' postfix];
else
filenm = [data_path_prefix '_' location '_' prefix '_' identifier '_' data_type];
end
else
if ( exist('postfix','var') == 1 )
filenm = [data_path_prefix location '_' prefix '_' identifier '_' data_type '_' postfix];
else
filenm = [data_path_prefix location '_' prefix '_' identifier '_' data_type];
end
end
% choose renderer depending on whether or not it is a 3d plot
if ( strfind(identifier,'3d') > 0 )
print('-djpeg',res_str,filenm,'-zbuffer')
else
print('-djpeg',res_str,filenm,'-painters')
end
end