Created
July 18, 2020 06:42
-
-
Save lamchau/72021b4bd6fa01f95ad15724fa0d1ac7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env bash | |
if ! command -v inkscape &> /dev/null; then | |
echo "command 'inkscape' could not be found" | |
exit 1 | |
fi | |
height=$1 | |
if [[ "$height" -lt 1 ]]; then | |
echo "$height must be greater than 0" | |
exit 1 | |
fi | |
svg_file=$2 | |
if [[ ! -f "$svg_file" ]]; then | |
echo "file: $svg_file does not exist" | |
exit 1 | |
fi | |
filename=${3%%.*} | |
extension=${3#*.} | |
if [[ -z "$filename" ]]; then | |
filename=${svg_file%%.*} | |
extension="png" | |
fi | |
output_filename="$filename.txt" | |
filename_1x="$filename.$extension" | |
filename_2x="$filename@2x.$extension" | |
filename_3x="$filename@3x.$extension" | |
echo -e "$filename_1x" | tee -a "$output_filename" | |
inkscape --export-height="$((height))" "$svg_file" --export-filename="$filename_1x" 2> >(tee -a "$output_filename") | |
echo -e "\n$filename_2x" | tee -a "$output_filename" | |
inkscape --export-height="$((height * 2))" "$svg_file" --export-filename="$filename_2x" 2> >(tee -a "$output_filename") | |
echo -e "\n$filename_3x" | tee -a "$output_filename" | |
inkscape --export-height="$((height * 3))" "$svg_file" --export-filename="$filename_3x" 2> >(tee -a "$output_filename") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment