Last active
December 12, 2018 13:33
-
-
Save afrendeiro/b88b641a1c4dff32028b4e2e4eac3822 to your computer and use it in GitHub Desktop.
Convert SVG figures from CellPress style to Nature Publishing Group style, generate high quality raster and aggregated pdfs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Change this | |
CURRENT_DATE=20181212 | |
NUMBER_MAIN_FIGURES=5 | |
NUMBER_SUPP_FIGURES=11 | |
ROOT_DIR=/home/path/to/paper/figures | |
# Don't change this | |
cd $ROOT_DIR | |
mkdir -p cropped_unlabeled_pngs | |
# Cell Press format convertion | |
## FigureS tosupplementary Figure | |
echo "FigureS to Supplementary Figure" | |
for FIGURE in $(eval echo "{1..$NUMBER_SUPP_FIGURES}") | |
do | |
echo "Supplementary Figure: " $FIGURE | |
sed -i "s/Figure S/Supplementary Figure /g" FigureS${FIGURE}.svg | |
done | |
## lowercase to uppercase panel letters | |
echo "Uppercase panel letters" | |
A='>(\w)<' | |
B='>\L\1<' | |
for FIGURE in $(eval echo "{1..$NUMBER_MAIN_FIGURES}") | |
do | |
echo "Main Figure: " $FIGURE | |
sed -ri "s/$A/$B/g" Figure${FIGURE}.svg | |
done | |
for FIGURE in $(eval echo "{1..$NUMBER_SUPP_FIGURES}") | |
do | |
echo "Supplementary Figure: " $FIGURE | |
sed -ri "s/$A/$B/g" FigureS${FIGURE}.svg | |
done | |
# Usual stuff | |
echo "Figures in A4 format" | |
for FIGURE in $(eval echo "{1..$NUMBER_MAIN_FIGURES}") | |
do | |
echo "Main Figure: " $FIGURE | |
inkscape --export-pdf=Figure${FIGURE}.pdf Figure${FIGURE}.svg | |
done | |
for FIGURE in $(eval echo "{1..$NUMBER_SUPP_FIGURES}") | |
do | |
echo "Supplementary Figure: " $FIGURE | |
inkscape --export-pdf=FigureS${FIGURE}.pdf FigureS${FIGURE}.svg | |
done | |
pdfunite $(eval echo Figure"{1..$NUMBER_MAIN_FIGURES}".pdf) MainFigures.${CURRENT_DATE}.pdf | |
pdfunite $(eval echo FigureS"{1..$NUMBER_SUPP_FIGURES}".pdf) SupplementaryFigures.${CURRENT_DATE}.pdf | |
pdfunite MainFigures.${CURRENT_DATE}.pdf SupplementaryFigures.${CURRENT_DATE}.pdf AllFigures.${CURRENT_DATE}.pdf | |
echo "Trimmed figures" | |
for FIGURE in $(eval echo "{1..$NUMBER_MAIN_FIGURES}") | |
do | |
echo "Main Figure: " $FIGURE | |
sed "s/Figure $FIGURE//g" Figure${FIGURE}.svg > Figure${FIGURE}.trimmed.svg | |
inkscape --export-area-drawing --export-pdf=Figure${FIGURE}.trimmed.pdf --export-margin=5 Figure${FIGURE}.trimmed.svg | |
inkscape --export-area-drawing --export-png=cropped_unlabeled_pngs/Figure${FIGURE}.cropped_unlabeled.png --export-background=white --export-dpi=300 --export-margin=5 Figure${FIGURE}.trimmed.svg | |
done | |
for FIGURE in $(eval echo "{1..$NUMBER_SUPP_FIGURES}") | |
do | |
echo "Supplementary Figure: " $FIGURE | |
sed "s/Supplementary Figure $FIGURE//g" FigureS${FIGURE}.svg > FigureS${FIGURE}.trimmed.svg | |
inkscape --export-area-drawing --export-pdf=FigureS${FIGURE}.trimmed.pdf --export-margin=5 FigureS${FIGURE}.trimmed.svg | |
inkscape --export-area-drawing --export-png=cropped_unlabeled_pngs/FigureS${FIGURE}.cropped_unlabeled.png --export-background=white --export-dpi=300 --export-margin=5 FigureS${FIGURE}.trimmed.svg | |
done | |
pdfunite $(eval echo Figure"{1..$NUMBER_MAIN_FIGURES}".trimmed.pdf) MainFigures.${CURRENT_DATE}.cropped_unlabeled.pdf | |
pdfunite $(eval echo FigureS"{1..$NUMBER_SUPP_FIGURES}".trimmed.pdf) SupplementaryFigures.${CURRENT_DATE}.cropped_unlabeled.pdf | |
pdfunite MainFigures.${CURRENT_DATE}.cropped_unlabeled.pdf SupplementaryFigures.${CURRENT_DATE}.cropped_unlabeled.pdf AllFigures.${CURRENT_DATE}.cropped_unlabeled.pdf | |
rm $(eval echo Figure"{1..$NUMBER_MAIN_FIGURES}".trimmed.svg) | |
rm $(eval echo Figure"{1..$NUMBER_MAIN_FIGURES}".trimmed.pdf) | |
rm $(eval echo FigureS"{1..$NUMBER_SUPP_FIGURES}".trimmed.svg) | |
rm $(eval echo FigureS"{1..$NUMBER_SUPP_FIGURES}".trimmed.pdf) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment