write_hex_to_file()
{
local number="$1"
- local output="$2"
local hex_number=
hex_number=$(printf "%08x" "$number")
for i in {0..6..2}; do
- printf "%b" "\x${hex_number:$i:2}" >> "$output"
+ printf "%b" "\x${hex_number:$i:2}"
done
}
filesize=$(wc --bytes "$input")
filesize=${filesize/ */}
- # picture typ (jpg)
- write_hex_to_file "3" "$output"
- # mime type (image/jpeg)
- write_hex_to_file "10" "$output"
- printf "%s" "image/jpeg" >> "$output"
- # description length (zero)
- write_hex_to_file "0" "$output"
- # width (zero)
- write_hex_to_file "0" "$output"
- # heigth (zero)
- write_hex_to_file "0" "$output"
- # color depth (zero)
- write_hex_to_file "0" "$output"
- # color count (zero)
- write_hex_to_file "0" "$output"
- # file size
- write_hex_to_file "$filesize" "$output"
- cat "$input" >> "$output"
+ {
+ # picture typ (jpg)
+ write_hex_to_file "3"
+ # mime type (image/jpeg)
+ write_hex_to_file "10"
+ printf "%s" "image/jpeg"
+ # description length (zero)
+ write_hex_to_file "0"
+ # width (zero)
+ write_hex_to_file "0"
+ # heigth (zero)
+ write_hex_to_file "0"
+ # color depth (zero)
+ write_hex_to_file "0"
+ # color count (zero)
+ write_hex_to_file "0"
+ # file size
+ write_hex_to_file "$filesize"
+ cat "$input"
+ } > "$output"
}
convert_flac_to_ogg()