-
Notifications
You must be signed in to change notification settings - Fork 1
/
png-to-svg.sh
42 lines (34 loc) · 813 Bytes
/
png-to-svg.sh
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
#!/bin/bash
# Script to convert PNG files to SVG format using ImageMagick
# Check if ImageMagick is installed
if ! command -v convert &> /dev/null
then
echo "ImageMagick is not installed. Please install it first."
exit
fi
# Check if input file is specified
if [ -z "$1" ]
then
echo "Usage: ./png-to-svg.sh input_file.png"
exit
fi
# Check if input file exists
if [ ! -f "$1" ]
then
echo "File $1 does not exist."
exit
fi
# Get input file name and extension
filename=$(basename -- "$1")
extension="${filename##*.}"
# Check if input file is a PNG image
if [ "$extension" != "png" ]
then
echo "File $1 is not a PNG image."
exit
fi
# Set output file name and extension
output="${filename%.*}.svg"
# Convert PNG to SVG
convert "$1" "$output"
echo "File $1 converted to $output."