From 80cd8fe0cf1f68a5e8da2d4f42dcc58c639ea0a8 Mon Sep 17 00:00:00 2001 From: lxowalle Date: Wed, 25 Dec 2024 13:46:24 +0800 Subject: [PATCH] * optimize make_logo.sh --- host/make_logo.sh | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/host/make_logo.sh b/host/make_logo.sh index bb03f01e8..15880ff73 100755 --- a/host/make_logo.sh +++ b/host/make_logo.sh @@ -1,18 +1,40 @@ #!/bin/bash # Check if the correct number of arguments is provided -if [ "$#" -ne 2 ]; then - echo "Usage: $0 " +if [ "$#" -eq 2 ]; then + # Get input and output file paths + input_file="$1" + output_file="$2" + + # Use ffmpeg to convert the image to YUV420P format JPEG + ffmpeg -i "$input_file" -pix_fmt yuvj420p "$output_file" +elif [ "$#" -eq 4 ]; then + # Get input and output file paths + input_file="$1" + output_file="$2" + output_width="$3" + output_height="$4" + + # Use ffmpeg to convert the image to YUV420P format JPEG + ffmpeg -i "$input_file" -vf "scale=$output_width:$output_height" -pix_fmt yuvj420p "$output_file" +elif [ "$#" -eq 5 ]; then + # Get input and output file paths + input_file="$1" + output_file="$2" + output_width="$3" + output_height="$4" + transpose="$5" + + # Use ffmpeg to convert the image to YUV420P format JPEG + ffmpeg -i "$input_file" -vf "transpose=$transpose,scale=$output_width:$output_height" -pix_fmt yuvj420p "$output_file" +else + echo "Usage: $0 " + echo "example: $0 input.jpg logo.jpeg" + echo "example: $0 input.jpg logo.jpeg 640 480" + echo "example: $0 input.jpg logo.jpeg 640 480 3" exit 1 fi -# Get input and output file paths -input_file="$1" -output_file="$2" - -# Use ffmpeg to convert the image to YUV420P format JPEG -ffmpeg -i "$input_file" -pix_fmt yuvj420p "$output_file" - # Check if the conversion was successful if [ $? -eq 0 ]; then echo "The file has been successfully converted to YUV420P JPEG and saved to $output_file"