Trim whitespace from SVG file

Trim the whitespace from a SVG file by setting the viewBox equal to the bounding box.
82 Downloads
Aktualisiert 19. Okt 2018

Lizenz anzeigen

Trim the whitespace from a SVG file by setting the viewBox equal to the bounding box.
Requires ImageMagick installed to obtain the bounding box.

Example:
x = 0:pi/100:2*pi;
figure;subplot(2,1,1);plot(x,sin(x));ylabel('Sine');
subplot(2,1,2);plot(x,cos(x));ylabel('Cosine');
saveas(gcf,'test.svg'); %For instance insert this file into Word, and there is whitespace around the plot.
trimSVGFile('test.svg');
%Now insert this file into Word, and there is no whitespace.

Zitieren als

Ivar Eskerud Smith (2024). Trim whitespace from SVG file (https://www.mathworks.com/matlabcentral/fileexchange/69152-trim-whitespace-from-svg-file), MATLAB Central File Exchange. Abgerufen .

Inspired by: https://se.mathworks.com/matlabcentral/fileexchange/49617-svg_fix_viewbox-in_name-varargin

Kompatibilität der MATLAB-Version
Erstellt mit R2015a
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Veröffentlicht Versionshinweise
1.0.0