Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/mrgnw/scripts.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930#!/usr/bin/env zsh
# Function to convert SVG to PNG with varying sizessvg_to_png() { local svg_file=$1 shift # Shift to remove the SVG file from arguments
# Ensure rsvg-convert is installed if ! command -v rsvg-convert &> /dev/null; then echo "Error: rsvg-convert is not installed. Install it with 'brew install librsvg'." >&2 return 1 fi
# Loop over the sizes passed as arguments for size in "$@"; do local output_file="${svg_file:r}-${size}.png" echo "Converting $svg_file to $output_file with size ${size}x${size}..." rsvg-convert -w $size -h $size "$svg_file" -o "$output_file" done}
# Check if correct number of arguments is passedif [[ $# -lt 2 ]]; then echo "Usage: $0 <svg-file> <size1> <size2> ... <sizeN>" exit 1fi
# Call the conversion function with the provided argumentssvg_to_png "$@"