Skip to content

Commit c4d68a2

Browse files
committed
Add a few notes about the Freedesktop specification
1 parent 1a6b8ff commit c4d68a2

File tree

1 file changed

+32
-20
lines changed

1 file changed

+32
-20
lines changed

misc/tools/imgprev/clifmimg

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,10 @@
6767
# Note: The exact package names providing these programs vary depending
6868
# on your OS/distribution, but ususally they have the same name as the program.
6969

70-
############################
71-
# DEFAULT OPTIONS
72-
############################
70+
#-----------------------------
71+
# 1. DEFAULT OPTIONS
72+
#-----------------------------
7373

74-
#
7574
# Set the preview image method.
7675
# Available methods: sixel, ueberzug, kitty, ansi (text mode)
7776
#
@@ -84,12 +83,26 @@ method=""
8483
# Available applications: chafa, pixterm, img2txt, viu, catimg, tiv, timg
8584
ansi_method="chafa"
8685

87-
# To generate sixel images we use chafa(1).
86+
# NOTE: To generate sixel images we use chafa(1).
8887

8988
type="$1"
9089
file="$2"
9190
file_URI="${3:-$file}"
9291

92+
# The maximum size for a thumbnail is, according to the Freedesktop specification
93+
# (https://specifications.freedesktop.org/thumbnail-spec/latest/creation.html),
94+
# 1024x1024. However, since we display thumbnails in a preview window, sometimes
95+
# using half of the screen, we need a bigger resolution.
96+
DEFAULT_SIZE="1920x1080"
97+
98+
# According to the Freedesktop specification, thumbnails should be in PNG format.
99+
# However, some of the convertions below, mostly for PDF files, generate truncated
100+
# images when converting to PNG (while quickly scrolling through the preview window).
101+
# This is why, for the time being, we stick to JPG.
102+
THUMB_FORMAT="jpg"
103+
104+
# Because of the above observations, we cannot use any of the thumbnails directories
105+
# specificied by the Freedesktop specification, but a custom one.
93106
CACHE_DIR="$CLIFM_THUMBNAILS_DIR"
94107
[ -z "$CACHE_DIR" ] && CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/clifm/thumbnails"
95108

@@ -99,14 +112,13 @@ CACHEDIRTAG_HEADER="Signature: 8a477f597d28d172789f06886806bc55
99112
# For information about cache directory tags, see:
100113
# http://www.brynosaurus.com/cachedir/"
101114

115+
# This file contains information about generated thumbnails: for the time being,
116+
# only the path to the original file (as a file URI).
102117
THUMBINFO_FILE="$CACHE_DIR/${CLIFM_THUMBINFO_FILE:-thumbnails.info}"
103118

104-
DEFAULT_SIZE="1920x1080"
105-
THUMB_FORMAT="jpg"
106-
107-
############################
108-
# SOME AUXILIARY FUNCTIONS
109-
############################
119+
#-----------------------------
120+
# 2. SOME AUXILIARY FUNCTIONS
121+
#-----------------------------
110122

111123
get_preview_method() {
112124
if [ -z "$method" ]; then
@@ -153,9 +165,9 @@ add_to_info_file() {
153165
return 0
154166
}
155167

156-
############################
157-
# DISPLAY IMAGES
158-
############################
168+
#-----------------------------
169+
# 3. DISPLAY IMAGES
170+
#-----------------------------
159171

160172
display() {
161173
[ -z "$1" ] && exit 1
@@ -215,9 +227,9 @@ display() {
215227
esac
216228
}
217229

218-
############################
219-
# THUMBNAILS GENERATION
220-
############################
230+
#-----------------------------
231+
# 4. THUMBNAILS GENERATION
232+
#-----------------------------
221233

222234
gen_audio_preview() {
223235
ffmpeg -hide_banner -i "$1" "$2" -y >/dev/null 2>&1 && \
@@ -308,9 +320,9 @@ gen_video_preview() {
308320
print_err_msg "ffmpegthumbnailer" "$?" "video"
309321
}
310322

311-
############################
312-
# MAIN
313-
############################
323+
#-----------------------------
324+
# 4. MAIN
325+
#-----------------------------
314326

315327
main() {
316328
get_preview_method

0 commit comments

Comments
 (0)