fix make_logo script error

This commit is contained in:
Neucrack
2024-11-26 10:28:05 +08:00
parent 3042208f78
commit 441888b5bf

View File

@@ -1,48 +1,22 @@
#!/bin/sh
#!/bin/bash
usage() {
echo "usage: $0 input output"
echo "output image must be logo.jpeg"
exit 1
}
src=${1}
dst=${2}
rm -rf ${dst}
if [ -z ${dst} ]
then
usage
# Check if the correct number of arguments is provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <input file path> <output file path>"
exit 1
fi
if [ ! -e ${src} ]
then
usage
# 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"
else
echo "Conversion failed. Please check the input file path and ensure ffmpeg is installed."
exit 1
fi
get_picture_w() {
convert "${1}" -print "%w" /dev/null
}
get_picture_h() {
convert "${1}" -print "%h" /dev/null
}
W=$(get_picture_w ${src})
H=$(get_picture_h ${src})
echo "picture w : ${W}"
echo "picture h : ${H}"
picturetoyuv420p() {
ffmpeg -i ${1} -pix_fmt yuv420p ${2}
}
yuv420ptopicture() {
ffmpeg -pix_fmt yuv420p -s ${3}x${4} -i ${1} ${2}
}
picturetoyuv420p $src $dst
yuv420ptopicture $src $dst $W $H