Skip to content

Commit

Permalink
thumbnailer: add HVIF support and optimize mimetype detection
Browse files Browse the repository at this point in the history
  • Loading branch information
augiedoggie committed Apr 24, 2024
1 parent 640e9d5 commit e37f614
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions TestCommands/thumbnailer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
## POSTSCRIPT requires the ghostscript_gpl and graphicsmagick packages
## SVG requires the librsvg package
## VIDEO requres the ffmpegthumbnailer and graphicsmagick packages
## HVIF requires no extra packages
##


Expand All @@ -21,15 +22,20 @@ for ((i = 1; i <= $#; i++)); do
continue
fi

mimeset "${!i}"
mimeType=`catattr -d BEOS:TYPE "${!i}" 2>/dev/null`

mimeType=`catattr -d BEOS:TYPE "${!i}"`
## Tracker should have already set the mimetype but try again in case we're not being run from TrackRunner
if test -z "$mimeType";then
mimeset "${!i}"
mimeType=`catattr -d BEOS:TYPE "${!i}" 2>/dev/null`
fi

thumbnailFile="${!i%.*}Thumbnail_$$.png"

needsResize=true

case "$mimeType" in
## use ,, to lowercase the mimetype
case "${mimeType,,}" in
application/pdf)
pdftoppm -singlefile -png -f 1 -l 1 -scale-to 128 "${!i}" "${thumbnailFile%.png}"
;;
Expand All @@ -45,14 +51,19 @@ for ((i = 1; i <= $#; i++)); do
needsResize=false
rsvg-convert -a -w 128 -h 128 -o "$thumbnailFile" "${!i}"
;;
application/x-vnd.haiku-icon)
needsResize=false
addattr -f "${!i}" -t icon BEOS:ICON "${!i}"
continue
;;
# text/*)
# needsResize=false
# pygmentize -g -f png -O line_numbers=false -o "$thumbnailFile" "${!i}"
# #gm convert "$thumbnailFile" -crop '160x160' -resize 128x128 -background white -gravity NorthWest -extent 128x128 "$thumbnailFile"
# gm convert "$thumbnailFile" -crop '160x160' -thumbnail 128x128 -background white -gravity NorthWest -extent 128x128 "$thumbnailFile"
# ;;
*)
echo "Skipping unknown mimetype($mimeType) for ${!i}"
echo "Skipping unknown mimetype(${mimeType,,}) for ${!i}"
continue
;;
esac
Expand Down

0 comments on commit e37f614

Please sign in to comment.