2014-01-30 16:30:17 +01:00
|
|
|
set -e
|
|
|
|
read filename
|
|
|
|
|
|
|
|
if [[ "${filename}" = xdgicon:* ]]; then
|
|
|
|
# get biggest icon from hicolor theme
|
|
|
|
|
2014-02-04 00:22:26 +01:00
|
|
|
filename="${filename#*:}.png"
|
|
|
|
candidate=
|
|
|
|
for dir in /usr/share/icons/{hicolor/,}; do
|
|
|
|
candidate=$(find -L "${dir}" -type f -name "${filename}")
|
|
|
|
if [[ -n "${candidate}" ]]; then
|
|
|
|
candidate=$(echo "${candidate}" | xargs ls --sort=size | head -1)
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
[[ -n "${candidate}" ]]
|
2014-01-30 16:30:17 +01:00
|
|
|
filename="${candidate}"
|
|
|
|
|
|
|
|
elif [[ "${filename}" = "-" ]] || [[ "${filename}" = *":-" ]]; then
|
|
|
|
tmpfile="$(mktemp /tmp/qimg-XXXXXXXX)"
|
|
|
|
cat > "${tmpfile}"
|
|
|
|
if [[ "$filename" = *":-" ]]; then
|
|
|
|
tmpfile="${filename%:*}:${tmpfile}"
|
|
|
|
fi
|
|
|
|
filename="${tmpfile}"
|
|
|
|
|
|
|
|
elif ! [[ -r "${filename}" ]]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2014-02-04 00:22:26 +01:00
|
|
|
# identify in F18 (6.7) adds implicit '\n' to format,
|
|
|
|
# whereas identify in F20 (6.8) does not
|
|
|
|
identify -format '%w %h\n' "$filename" | sed -e '/^$/d'
|
2014-01-30 16:30:17 +01:00
|
|
|
convert -depth 8 "$filename" rgba:-
|
|
|
|
|
|
|
|
[[ -n "${tmpfile}" ]] && rm -f ${tmpfile} || true
|
|
|
|
|
|
|
|
# vim: ft=sh ts=4 sw=4 et
|