Skip to content

Commit 97f9eb0

Browse files
author
Harsh Purwar
committed
Minor modifications in write_image()
1 parent 20e9bef commit 97f9eb0

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

plotly/export_fig2/write_image.m

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,33 @@
22

33
% Function to write plotly figures to a supported image format, which are the following: "png", "jpg", "jpeg", "webp", "svg", "pdf", "eps", "json"
44

5-
debug=1;
5+
debug=0;
66
if nargin < 2
7-
imageFormat='png';
7+
imageFormat="png";
88
filename='figure.png';
99
height=500;
1010
width=800;
1111
scale=1;
12+
elseif nargin < 3
13+
filename=['figure.',char(imageFormat)];
14+
height=500;
15+
width=800;
16+
scale=1;
17+
elseif nargin < 4
18+
height=500;
19+
width=800;
20+
scale=1;
21+
elseif nargin < 5
22+
width=800;
23+
scale=1;
24+
elseif nargin < 6
25+
scale=1;
1226
end
1327

28+
if strcmpi(imageFormat,'jpg')
29+
imageFormat = "jpeg";
30+
end
31+
1432
wd=fileparts(fileparts(mfilename('fullpath')));
1533
output=[];
1634

@@ -48,7 +66,7 @@
4866
q.data.layout = pfObj.layout;
4967
q.data.layout = rmfield(q.data.layout,'height');
5068
q.data.layout = rmfield(q.data.layout,'width');
51-
q.format = imageFormat;
69+
q.format = string(imageFormat);
5270
q.height = height;
5371
q.scale = scale;
5472
q.width = width;
@@ -87,7 +105,7 @@
87105
else
88106
out=unicode2native(output.result,'UTF-8');
89107
out=base64decode(out);
90-
f=fopen(filename,'wb');
108+
f=fopen(char(filename),'wb');
91109
fwrite(f,out);
92110
fclose(f);
93111
end

0 commit comments

Comments
 (0)