diff options
Diffstat (limited to 'apply_album_art.sh')
| -rwxr-xr-x | apply_album_art.sh | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/apply_album_art.sh b/apply_album_art.sh index eb13ce6..8ee6d51 100755 --- a/apply_album_art.sh +++ b/apply_album_art.sh @@ -21,17 +21,26 @@ find "$input_dir" -type d | while read -r dir; do [[ -z "$image" ]] && continue echo "Processing folder: $dir" echo "Using image: $image" - temp_cover="$(mktemp --suffix=.jpg)" + + ext_lower="${image##*.}" + ext_lower="${ext_lower,,}" + if [[ "$ext_lower" == "png" ]]; then + mimetype="image/png" + suffix=".png" + else + mimetype="image/jpeg" + suffix=".jpg" + fi + + temp_cover="$(mktemp --suffix=${suffix})" ffmpeg -y -i "$image" \ -vf "scale=500:500:force_original_aspect_ratio=decrease,pad=500:500:(ow-iw)/2:(oh-ih)/2" \ "$temp_cover" >/dev/null 2>&1 find "$dir" -maxdepth 1 -type f -iname "*.flac" | while read -r flac; do echo "Tagging: $flac" - metaflac \ - --remove-tag=METADATA_BLOCK_PICTURE \ - --import-picture-from="$temp_cover" \ - "$flac" + metaflac --remove --block-type=PICTURE "$flac" + metaflac --import-picture-from="3|${mimetype}|||$temp_cover" "$flac" done rm -f "$temp_cover" |
