Skip to content

Commit 9e8474e

Browse files
shellrc: added alias to vectorize a raster image
1 parent cc837ee commit 9e8474e

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

.oh-my-shell/shellrc/plugins/image/aliases.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ alias image_concat_vertically="convert -append "
77

88
# Usage: concat_images_horizontally in1.jpg in2.jpg in3.jpg out.jpg
99
alias image_concat_horizontally="convert +append "
10+
11+
# Vectorize a raster image
12+
# Usage: image_raster_to_vector "/path/to/input.png" "/path/to/output.svg"
13+
alias image_raster_to_vector="convert "$input_image" -threshold 50% -monochrome "$temp_pbm""
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
f_image_convert_raster_to_vector() {
2+
local input_file="$1"
3+
local output_file="$2"
4+
local pbm_file="/tmp/$RANDOM.pbm"
5+
6+
# Convert to monochrome PBM using ImageMagick
7+
magick convert "$input_file" -threshold 50% -monochrome "$pbm_file"
8+
# Convert PBM to SVG using Potrace
9+
potrace -s -o "$output_file" "$pbm_file"
10+
# Clean up the intermediate PBM file
11+
rm "$pbm_file"
12+
}

0 commit comments

Comments
 (0)