Skip to content

Commit

Permalink
opusmbptagで入力画像のMIMETYPEを推測する機能を追加
Browse files Browse the repository at this point in the history
  • Loading branch information
hcmiya committed May 8, 2019
1 parent 51de9c1 commit 4d2a2e9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/opusmbptag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ esac
if ! expr x"$mime" : x'[] !"#$%&'\''()*+,./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\^_`abcdefghijklmnopqrstuvwxyz{|}~-]*$' >/dev/null
then E invalid mime type string
fi
printf %s "$mime" |iconv -t us-ascii >"$tmp/mime"

description_conv_arg="-t utf-8"
case $have_description_file in
Expand Down Expand Up @@ -189,6 +188,17 @@ case $# in
*) usage ;;
esac

if [ -z "$mime" ]
then
determine="$(file - <"$tmp/binary")"
case "$determine" in
*JPEG*|*JFIF*) mime=image/jpeg ;;
*GIF*) mime=image/gif ;;
*PNG*) mime=image/png ;;
esac
fi
printf %s "$mime" |iconv -t us-ascii >"$tmp/mime"

# generate packet
{
printf METADATA_BLOCK_PICTURE=
Expand Down

0 comments on commit 4d2a2e9

Please sign in to comment.