;;; This is an IDL wrapper to run all the shell commands that will ;;; reduce your huge disk space requirements and allow it to be ;;; submitted to astro-ph. The code takes all the instructions from ;;; this webpage: http://electron.mit.edu/~gsteele/pdf/ ;;; ;;; ;;; Manodeep Sinha: Jan 22: 2009 time=systime(1) arxivlimit = 15.0 ;;; arxiv limit is 15 MB quality = ' 80 ' figpattern = '/path/to/paper/fig*.eps' fignames=findfile(figpattern) nfigs = n_elements(fignames) print,' ' print,nfigs,figpattern,format='("Compressing ",I3," eps images with names that match the pattern : ",A)' print,' ' response = 'N' read,"Enter 'Y' if you want the intermediate png and jpg files to be deleted : ",response response = strupcase(response) dummy = ' ' if response eq 'Y' then begin print,' ' print,'Intermediate image files will be deleted' print,' ' endif else begin print,' ' print,'Intermediate image files will *NOT* be deleted - your directory end up with a lot of temporary images' print,' ' endelse for i=0,nfigs-1 do begin fig = strcompress(fignames[i],/remove_all) png = strcompress((strsplit(fignames[i],'.',/extract))[0]+'.png',/remove_all) jpg = strcompress((strsplit(fignames[i],'.',/extract))[0]+'.jpg',/remove_all) ;;; convert the eps image into png execstring = 'gs -r300 -dEPSCrop -dTextAlphaBits=4 -sDEVICE=png16m -sOutputFile=' + png ;; if you can not use the crop option, then check option -dEPSFitPage execstring = execstring + ' -dBATCH -dNOPAUSE ' + fig print,execstring spawn,execstring,dummy ;;; remove the original eps image execstring = 'rm ' + fig print,execstring spawn,execstring,dummy ;;; Convert the png to a jpg execstring = 'convert -quality ' + quality + strcompress(png,/remove_all) + ' ' + jpg print,execstring spawn,execstring,dummy ;;; Convert to eps execstring = 'convert ' + strcompress(jpg,/remove_all) + ' eps2:' + fig print,execstring spawn,execstring,dummy ;;; Remove temporary files if required if response eq 'Y' then begin execstring = 'rm ' + jpg + ' ' + png print,execstring spawn,execstring,dummy endif print,' ' endfor ;;; did we succeed ? execstring = 'du -c ' + figpattern spawn,execstring,diskusage mb = strcompress((strsplit(diskusage[nfigs],'total',/extract))[0],/remove_all)/1024. if mb gt arxivlimit then begin print,arxivlimit,format='("The images still take up more space than the astro-ph limit of ",F7.2," MB")' print,quality,format='("Reduce quality from ", A, " and try again")' endif print,nfigs,mb,format='(I3," eps figures now take up ",F7.1," MB of space")' print, systime(1)-time, format='("Time taken : ", F10.1, " seconds")' end