fig2figs

PURPOSE ^

LUKE - batch convert *.fig files into eps, pdf, jpg, emf and png format

SYNOPSIS ^

function [nfile] = fig2figs(fileformat,workdir,option,value)

DESCRIPTION ^

LUKE - batch convert *.fig files into eps, pdf, jpg, emf and png format

 Batch convert *.fig files into eps, pdf, jpg, emf and png format.
 Use advexpfig.m private function (see MatLab central)

 Input:

   - fileformat: 'eps', 'pdf', 'jpg', 'emf' and 'png'. If '*', all are used. It can be also 'epspdf' or anycombination of the keys words like eps, pdf, ... [string]
   - dirnit: working directory [string]
   - option: figure option (see matlab documentation)
   - value: figure option value (see matlab documentation)

 Output: 

   - nfile: number of figure files processed [1,1]

 by Y.Peysson CEA-DRFC <yves.peysson@cea.fr> and Joan Decker MIT-RLE
 (jodecker@mit.edu)

warning off

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [nfile] = fig2figs(fileformat,workdir,option,value)
0002 %LUKE - batch convert *.fig files into eps, pdf, jpg, emf and png format
0003 %
0004 % Batch convert *.fig files into eps, pdf, jpg, emf and png format.
0005 % Use advexpfig.m private function (see MatLab central)
0006 %
0007 % Input:
0008 %
0009 %   - fileformat: 'eps', 'pdf', 'jpg', 'emf' and 'png'. If '*', all are used. It can be also 'epspdf' or anycombination of the keys words like eps, pdf, ... [string]
0010 %   - dirnit: working directory [string]
0011 %   - option: figure option (see matlab documentation)
0012 %   - value: figure option value (see matlab documentation)
0013 %
0014 % Output:
0015 %
0016 %   - nfile: number of figure files processed [1,1]
0017 %
0018 % by Y.Peysson CEA-DRFC <yves.peysson@cea.fr> and Joan Decker MIT-RLE
0019 % (jodecker@mit.edu)
0020 %
0021 %warning off
0022 %
0023 if nargin == 0,
0024     fileformat = '*';
0025     workdir = pwd;
0026 end
0027 if nargin == 1,
0028     workdir = pwd;
0029 end
0030 if nargin == 3,
0031     error('Wrong number of input arguments in fig2figs.m');
0032 end
0033 %
0034 close all
0035 %
0036 filelist = dir('*.fig');
0037 %
0038 if strcmp(fileformat,'*'),fileformat = 'eps pdf jpg emf png';end
0039 %
0040 for ifile = 1:length(filelist),
0041     %
0042     open(filelist(ifile).name)
0043     %
0044     if strfind(fileformat,'eps'),
0045         if exist('option') == 1 & exist('value') == ifile,
0046             advexpfig(ifile,strtok(fullfile(workdir,filelist(ifile).name),'.'),'-depsc',option,value);
0047         else
0048             advexpfig(ifile,strtok(fullfile(workdir,filelist(ifile).name),'.'),'-depsc');
0049         end
0050     end
0051     %
0052     if strfind(fileformat,'pdf'),
0053         if exist('option') == 1 & exist('value') == 1,
0054             advexpfig(ifile,strtok(fullfile(workdir,filelist(ifile).name),'.'),'-dpdf ',option,value);   
0055         else
0056             advexpfig(ifile,strtok(fullfile(workdir,filelist(ifile).name),'.'),'-dpdf ');   
0057         end
0058     end
0059     %
0060     if strfind(fileformat,'jpg'),
0061         if exist('option') == 1 & exist('value') == 1,
0062             advexpfig(ifile,strtok(fullfile(workdir,filelist(ifile).name),'.'),'-djpeg ',option,value);   
0063         else
0064             advexpfig(ifile,strtok(fullfile(workdir,filelist(ifile).name),'.'),'-djpeg ');   
0065         end
0066     end
0067     %
0068     if strfind(fileformat,'emf'),
0069         if exist('option') == 1 & exist('value') == 1,
0070             if ~strfind(computer,'WIN'),
0071                 advexpfig(ifile,strtok(fullfile(workdir,filelist(ifile).name),'.'),'-demf',option,value);
0072             end
0073         else
0074             if ~strfind(computer,'WIN'),
0075                 advexpfig(ifile,strtok(fullfile(workdir,filelist(ifile).name),'.'),'-demf');
0076             end
0077         end
0078     end
0079     %
0080     if strfind(fileformat,'png'),
0081         if exist('option') == 1 & exist('value') == 1,
0082             advexpfig(ifile,strtok(fullfile(workdir,filelist(ifile).name),'.'),'-dpng',option,value);   
0083         else
0084             advexpfig(ifile,strtok(fullfile(workdir,filelist(ifile).name),'.'),'-dpng');   
0085         end
0086     end
0087 end     
0088 %
0089 nfile = length(filelist);
0090 %
0091 close all
0092 %
0093

Community support and wiki are available on Redmine. Last update: 18-Apr-2019.