Skip to content

Commit

Permalink
Fixed issue #46: Ghostscript crash if figure units <> pixels
Browse files Browse the repository at this point in the history
  • Loading branch information
altmany committed Mar 26, 2015
1 parent e264948 commit 973cf6e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions export_fig.m
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@
% 06/03/15: Improved image padding & cropping thanks to Oscar Hartogensis
% 26/03/15: Fixed issue #49 (bug with transparent grayscale images); fixed out-of-memory issue
% 26/03/15: Fixed issue #42: non-normalized annotations on HG1
% 26/03/15: Fixed issue #46: Ghostscript crash if figure units <> pixels

function [im, alpha] = export_fig(varargin)
try
Expand Down Expand Up @@ -280,6 +281,10 @@
set(annotationHandles,'Units','norm');
end

% Fix issue #46: Ghostscript crash if figure units <> pixels
oldFigUnits = get(fig,'Units');
set(fig,'Units','pixels');

% Set to print exactly what is there
set(fig, 'InvertHardcopy', 'off');
% Set the renderer
Expand Down Expand Up @@ -577,6 +582,8 @@
end
try set(annotationHandles(handleIdx),'Units',oldUnits); catch, end
end
% Revert figure units
set(fig,'Units',oldFigUnits);
end
catch err
% Display possible workarounds before the error message
Expand Down

0 comments on commit 973cf6e

Please sign in to comment.