diff --git a/append_pdfs.m b/append_pdfs.m index cd1b1b6..ced0b42 100644 --- a/append_pdfs.m +++ b/append_pdfs.m @@ -42,6 +42,7 @@ function append_pdfs(varargin) % 29/03/20: Accept a cell-array of input files (issue #299); accept both "strings", 'chars' % 25/01/22: Improved handling of missing input files & folder with non-ASCII chars (issue #349) % 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 +% 06/07/23: Another attempt to fix issue #378 (remove unnecessary quotes from ghostscript cmdfile) %} if nargin < 2, return; end % sanity check @@ -154,6 +155,7 @@ function prepareCmdFile(cmdfile, output, varargin) str = ['-q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress ' ... '-sOutputFile="' output '" -f ' sprintf('"%s" ',varargin{:})]; str = regexprep(str, ' "?" ',' '); % remove empty strings (issues #367,#378) + str = regexprep(str, '"([^ ]*)"', '$1'); % remove unnecessary quotes str = strtrim(str); % trim extra spaces fh = fopen(cmdfile, 'w'); diff --git a/export_fig.m b/export_fig.m index f2855d7..c16374c 100644 --- a/export_fig.m +++ b/export_fig.m @@ -386,6 +386,7 @@ % 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) % 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 % 30/05/23: (3.39) Fixed exported bgcolor of uifigures or figures in Live Scripts (issue #377) +% 06/07/23: (3.40) For Tiff compression, use AdobeDeflate codec (if available) instead of Deflate (issue #379) %} if nargout @@ -423,7 +424,7 @@ [fig, options] = parse_args(nargout, fig, argNames, varargin{:}); % Check for newer version and exportgraphics/copygraphics compatibility - currentVersion = 3.39; + currentVersion = 3.40; if options.version % export_fig's version requested - return it and bail out imageData = currentVersion; return @@ -659,6 +660,8 @@ % Main processing try + oldWarn = warning; + % Export bitmap formats first if isbitmap(options) if abs(options.bb_padding) > 1 @@ -918,7 +921,13 @@ t.setTag('ImageLength', size(img,1)); t.setTag('ImageWidth', size(img,2)); t.setTag('Photometric', Tiff.Photometric.RGB); - t.setTag('Compression', Tiff.Compression.Deflate); + try %issue #379 use Tiff.Compression.AdobeDeflate by default + compressionMode = Tiff.Compression.AdobeDeflate; + catch + warning off imageio:tiffmexutils:libtiffWarning %issue #379 + compressionMode = Tiff.Compression.Deflate; + end + t.setTag('Compression', compressionMode); t.setTag('PlanarConfiguration', Tiff.PlanarConfiguration.Chunky); t.setTag('ExtraSamples', Tiff.ExtraSamples.AssociatedAlpha); t.setTag('ResolutionUnit', Tiff.ResolutionUnit.Inch); @@ -1528,7 +1537,12 @@ if ~nargout clear imageData alpha end + + % Revert warnings state + warning(oldWarn); catch err + % Revert warnings state + warning(oldWarn); % Revert figure properties in case they were changed try set(fig,'Units',oldFigUnits, 'Position',pos, 'Color',tcol_orig); catch, end % Display possible workarounds before the error message