27 lines
687 B
Fish
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
|