Skip to content

Commit a156e9a

Browse files
committed
Add OpenRaster (.ora) thumbnailer.
Pix can open but xviewer can't currently (gdk-pixbuf support)
1 parent 9091818 commit a156e9a

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

debian/control

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,10 @@ Architecture: all
5656
Depends: xapp-thumbnailers-common
5757
Description: Gimp thumbnailer
5858
Produces thumbnails for Gimp xcf files.
59+
60+
Package: xapp-ora-thumbnailer
61+
Architecture: all
62+
Depends: xapp-thumbnailers-common
63+
Description: OpenRaster thumbnailer
64+
Produces thumbnails for OpenRaster (.ora) files.
65+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
usr/bin/xapp-ora-thumbnailer
2+
usr/share/thumbnailers/xapp-ora-thumbnailer.thumbnailer

files/usr/bin/xapp-ora-thumbnailer

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/python3
2+
3+
import os
4+
import sys
5+
import tempfile
6+
import zipfile
7+
import gi
8+
9+
gi.require_version("XApp", "1.0")
10+
from gi.repository import XApp, GdkPixbuf
11+
12+
import XappThumbnailers
13+
t = XappThumbnailers.Thumbnailer()
14+
15+
# https://www.openraster.org/baseline/file-layout-spec.html
16+
# OpenRaster files are normal zip files, with a pre-generated thumbnail file you can extract.
17+
try:
18+
with zipfile.PyZipFile(t.args.input) as z:
19+
with tempfile.TemporaryDirectory(dir=XApp.get_tmp_dir(), prefix="xapp-ora-thumbnailer-") as tempd:
20+
z.extract("Thumbnails/thumbnail.png", path=tempd)
21+
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(os.path.join(tempd, "Thumbnails", "thumbnail.png"), t.args.size, t.args.size)
22+
pixbuf.savev(t.args.output, "png")
23+
except Exception as e:
24+
print("Could not generate thumbnail for '%s': %s" % (t.args.input, e), file=sys.stderr, flush=True)
25+
sys.exit(1)
26+
27+
sys.exit(0)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[Thumbnailer Entry]
2+
TryExec=xapp-ora-thumbnailer
3+
Exec=xapp-ora-thumbnailer -i %i -o %o -s %s
4+
MimeType=image/openraster;

0 commit comments

Comments
 (0)