Created
October 24, 2024 16:06
-
-
Save isurfer21/25eb54f7d165d5232a9f32595dd0a31c to your computer and use it in GitHub Desktop.
Revisions
-
isurfer21 created this gist
Oct 24, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ #!/bin/bash # Function to print help message function print_help() { app_name=${0##*/} echo "Syntax: $app_name <input_image> <output_image>" echo " -h: Display this help message" echo "Usage: " echo " $app_name input.png output.jpg" echo " $app_name '*.png' output.jpg" } # Check if help flag is provided if [[ "$1" == "-h" ]]; then print_help exit 0 fi # Check if input file is provided if [[ $# -lt 1 ]]; then echo "Error: Input file is required." print_help exit 1 fi # Assign input and output files input_file="$1" # If output file is not provided, use input file name with output extension if [[ $# -eq 1 ]]; then output_file="${input_file%.png}.jpg" else output_file="$2" fi # Convert the image convert "$input_file" -background white -alpha remove -alpha off "$output_file" if [[ $? -ne 0 ]]; then echo "Error: Image conversion failed." fi