-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexport-logos.sh
More file actions
executable file
·116 lines (96 loc) · 3.66 KB
/
export-logos.sh
File metadata and controls
executable file
·116 lines (96 loc) · 3.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash
# Export logos script for openproblems-bio
# This script exports logos in various formats using Inkscape
# Main design file
MAIN_FILE="openproblems-logos.inkscape.svg"
# Subdirectories containing logos
LOGO_DIRS=("banner" "icon" "rectangle" "square" "sticker")
# Output sizes for PNGs (widths in pixels)
SIZES=(32 64 128 256 512 1024 2048 4096 8192)
# Color codes for output
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Export with Inkscape and report status
export_with_inkscape() {
local description="$1"
local output_file=""
shift
# Extract the output filename from --export-filename argument
for arg in "$@"; do
if [[ "$arg" == --export-filename=* ]]; then
output_file="${arg#--export-filename=}"
break
fi
done
echo " → $description"
if inkscape "$@" 2>/dev/null; then
echo " ✓ Created: $output_file"
else
echo " ✗ Failed to create: $output_file"
fi
}
echo "Exporting logos..."
echo "=================="
# Check if inkscape is installed
if ! command -v inkscape &> /dev/null; then
echo "Error: inkscape is not installed or not in PATH"
exit 1
fi
# Export SVGs from the main design file
echo -e "\n${BLUE}Exporting SVGs from main design file...${NC}"
# Define page-to-logo mapping
# NOTE: This should be updated if the page order is changed in the design file
declare -A PAGE_MAP=(
[1]="icon/openproblems-icon.svg"
[2]="icon/openproblems-icon_all_black.svg"
[3]="icon/openproblems-icon_all_white.svg"
[4]="banner/openproblems-banner.svg"
[5]="banner/openproblems-banner_white.svg"
[6]="banner/openproblems-banner_all_black.svg"
[7]="banner/openproblems-banner_all_white.svg"
[8]="rectangle/openproblems-rectangle.svg"
[9]="rectangle/openproblems-rectangle_white.svg"
[10]="rectangle/openproblems-rectangle_all_black.svg"
[11]="rectangle/openproblems-rectangle_all_white.svg"
[12]="square/openproblems-square.svg"
[13]="square/openproblems-square_white.svg"
[14]="square/openproblems-square_all_black.svg"
[15]="square/openproblems-square_all_white.svg"
[16]="sticker/openproblems-sticker.svg"
)
if [ -f "$MAIN_FILE" ]; then
for page in {1..16}; do
output_file="${PAGE_MAP[$page]}"
echo -e "${GREEN}Exporting page $page → $output_file${NC}"
export_with_inkscape "SVG" --export-page="$page" --export-area-page --export-filename="$output_file" "$MAIN_FILE"
done
else
echo "Err: main design file $MAIN_FILE not found"
exit 1
fi
# Convert SVGs to other formats
echo -e "\n${BLUE}Converting SVGs to multiple formats...${NC}"
# Process each directory
for dir in "${LOGO_DIRS[@]}"; do
if [ ! -d "$dir" ]; then
echo "Warning: Directory '$dir' not found, skipping..."
continue
fi
echo -e "\n${BLUE}Processing directory: $dir${NC}"
# Find all SVG files in the directory
while IFS= read -r -d '' svg_file; do
base_name=$(basename "$svg_file" .svg)
echo
echo -e "${GREEN}Converting: $base_name${NC}"
# Create PDF
export_with_inkscape "PDF" "$svg_file" --export-type=pdf --export-filename="$dir/${base_name}.pdf"
# Create PNGs in different sizes
for width in "${SIZES[@]}"; do
export_with_inkscape "PNG ${width}px" "$svg_file" --export-type=png --export-filename="$dir/${base_name}-${width}px.png" --export-width="$width"
done
done < <(find "$dir" -maxdepth 1 -name "*.svg" -type f -print0)
done
echo -e "\n================================"
echo "Export process complete!"
echo "Exported files are located in each logo format directory"