init commit
This commit is contained in:
26
fish/functions/jpg2png.fish
Normal file
26
fish/functions/jpg2png.fish
Normal file
@@ -0,0 +1,26 @@
|
||||
function jpg2png --description "Convert a JPG image from URL to PNG format"
|
||||
if test (count $argv) -ne 2
|
||||
echo "Usage: jpg2png <source_url> <destination_path>"
|
||||
return 1
|
||||
end
|
||||
|
||||
set source $argv[1]
|
||||
set destination $argv[2]
|
||||
|
||||
set temp_jpg (mktemp --suffix=.jpg)
|
||||
|
||||
if not wget -O $temp_jpg $source 2>&1
|
||||
echo "Error: Failed to download JPG from $source"
|
||||
rm -f $temp_jpg
|
||||
return 1
|
||||
end
|
||||
|
||||
if not magick $temp_jpg $destination
|
||||
echo "Error: Failed to convert JPG to PNG"
|
||||
rm -f $temp_jpg
|
||||
return 1
|
||||
end
|
||||
|
||||
rm -f $temp_jpg
|
||||
echo "Successfully converted and saved to $destination"
|
||||
end
|
||||
Reference in New Issue
Block a user