blob: 7f7a9a4c1d1533c0ad3d47cebdba1c3ca3a91a76 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
pragma Singleton
import Quickshell
import Quickshell.Io
import Qt.labs.platform
Singleton {
id: root
readonly property string thumbDir: `${StandardPaths.standardLocations(StandardPaths.GenericCacheLocation)[0]}/caelestia/thumbnails`.slice(7)
function go(sha: string, path: string, width: int, height: int): string {
if (!sha || !path || !width || !height)
return "";
const thumbPath = `${thumbDir}/${sha}@${width}x${height}-exact.png`;
thumbProc.path = path;
thumbProc.thumbPath = thumbPath;
thumbProc.width = width;
thumbProc.height = height;
thumbProc.startDetached();
return thumbPath;
}
Process {
id: thumbProc
property string path
property string thumbPath
property int width
property int height
command: ["fish", "-c", `
if ! test -f ${thumbPath}
set -l size (identify -ping -format '%w\n%h' ${path})
if test $size[1] -gt ${width} -o $size[2] -gt ${height}
magick ${path} -thumbnail ${width}x${height}^ -background none -gravity center -extent ${width}x${height} -unsharp 0x.5 ${thumbPath}
end
end
`]
}
}
|