Files
dotfiles/fish/functions/jpg2png.fish
2026-06-11 19:39:54 +05:30

27 lines
687 B
Fish

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