Skip to content

Commit 47ab1f9

Browse files
committed
(3.40) For Tiff compression, use AdobeDeflate codec (if available) instead of Deflate (issue #379); another attempt to fix issue #378 (remove unnecessary quotes from ghostscript cmdfile)
1 parent aff397d commit 47ab1f9

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

append_pdfs.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ function append_pdfs(varargin)
4242
% 29/03/20: Accept a cell-array of input files (issue #299); accept both "strings", 'chars'
4343
% 25/01/22: Improved handling of missing input files & folder with non-ASCII chars (issue #349)
4444
% 07/06/23: Fixed (hopefully) unterminated quote run-time error (issues #367, #378); fixed handling of pathnames with non-ASCII chars (issue #349); display ghostscript command upon run-time invocation error
45+
% 06/07/23: Another attempt to fix issue #378 (remove unnecessary quotes from ghostscript cmdfile)
4546
%}
4647

4748
if nargin < 2, return; end % sanity check
@@ -154,6 +155,7 @@ function prepareCmdFile(cmdfile, output, varargin)
154155
str = ['-q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress ' ...
155156
'-sOutputFile="' output '" -f ' sprintf('"%s" ',varargin{:})];
156157
str = regexprep(str, ' "?" ',' '); % remove empty strings (issues #367,#378)
158+
str = regexprep(str, '"([^ ]*)"', '$1'); % remove unnecessary quotes
157159
str = strtrim(str); % trim extra spaces
158160

159161
fh = fopen(cmdfile, 'w');

export_fig.m

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@
386386
% 23/04/23: (3.37) Fixed run-time error with old Matlab releases (issue #374); -notify console message about exported image now displays black (STDOUT) not red (STDERR)
387387
% 15/05/23: (3.38) Fixed endless recursion when using export_fig in Live Scripts (issue #375); don't warn about exportgraphics/copygraphics alternatives in deployed mode
388388
% 30/05/23: (3.39) Fixed exported bgcolor of uifigures or figures in Live Scripts (issue #377)
389+
% 06/07/23: (3.40) For Tiff compression, use AdobeDeflate codec (if available) instead of Deflate (issue #379)
389390
%}
390391

391392
if nargout
@@ -423,7 +424,7 @@
423424
[fig, options] = parse_args(nargout, fig, argNames, varargin{:});
424425

425426
% Check for newer version and exportgraphics/copygraphics compatibility
426-
currentVersion = 3.39;
427+
currentVersion = 3.40;
427428
if options.version % export_fig's version requested - return it and bail out
428429
imageData = currentVersion;
429430
return
@@ -659,6 +660,8 @@
659660

660661
% Main processing
661662
try
663+
oldWarn = warning;
664+
662665
% Export bitmap formats first
663666
if isbitmap(options)
664667
if abs(options.bb_padding) > 1
@@ -918,7 +921,13 @@
918921
t.setTag('ImageLength', size(img,1));
919922
t.setTag('ImageWidth', size(img,2));
920923
t.setTag('Photometric', Tiff.Photometric.RGB);
921-
t.setTag('Compression', Tiff.Compression.Deflate);
924+
try %issue #379 use Tiff.Compression.AdobeDeflate by default
925+
compressionMode = Tiff.Compression.AdobeDeflate;
926+
catch
927+
warning off imageio:tiffmexutils:libtiffWarning %issue #379
928+
compressionMode = Tiff.Compression.Deflate;
929+
end
930+
t.setTag('Compression', compressionMode);
922931
t.setTag('PlanarConfiguration', Tiff.PlanarConfiguration.Chunky);
923932
t.setTag('ExtraSamples', Tiff.ExtraSamples.AssociatedAlpha);
924933
t.setTag('ResolutionUnit', Tiff.ResolutionUnit.Inch);
@@ -1528,7 +1537,12 @@
15281537
if ~nargout
15291538
clear imageData alpha
15301539
end
1540+
1541+
% Revert warnings state
1542+
warning(oldWarn);
15311543
catch err
1544+
% Revert warnings state
1545+
warning(oldWarn);
15321546
% Revert figure properties in case they were changed
15331547
try set(fig,'Units',oldFigUnits, 'Position',pos, 'Color',tcol_orig); catch, end
15341548
% Display possible workarounds before the error message

0 commit comments

Comments
 (0)