-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcovert_files_to_svg.sh
More file actions
44 lines (33 loc) · 1.15 KB
/
Copy pathcovert_files_to_svg.sh
File metadata and controls
44 lines (33 loc) · 1.15 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
#!/bin/bash
# Author: [Newton-Nganga]
# Date: [08.02.2025]
# Description: Converts images to SVG using ImageMagick and Potrace
## prerequisites
# 1. Be on linux and place the file at the root of your imaages dir
# 2. install imagemagick and potrace
# 3. make the file executable
# 4. run it and enjoy
# Function to convert images to SVG
convert_to_svg() {
local file="$1"
local dir
local base_name
local extension
local new_file
# Get the directory, base name, and extension of the file
dir=$(dirname "$file")
base_name=$(basename "$file")
extension="${base_name##*.}"
base_name="${base_name%.*}"
# Define the new file name with .svg extension
new_file="${dir}/${base_name}.svg"
# Convert the image to SVG
convert "$file" "$new_file"
echo "Converted: $file -> $new_file"
}
# Export the function so it can be used by find
export -f convert_to_svg
# Find all image files (excluding .svg) and convert them
find . -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" -o -iname "*.gif" -o -iname "*.bmp" -o -iname "*.tiff" \) \
-exec bash -c 'convert_to_svg "$0"' {} \;
echo "Conversion complete!"