Commit 043b64da68d47718fd96e64d04d710a46592526a

OpenRaster thumbnailer and mime stuff

(hacky, manual installation only for now)
  
1<?xml version="1.0" encoding="UTF-8"?>
2<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
3 <!-- EXPERIMENTAL hack - this file should probably not be distributed by mypaint in the future -->
4 <mime-type type="image/openraster">
5 <comment>OpenRaster Image</comment>
6 <comment xml:lang="de">OpenRaster Bild</comment>
7 <magic priority="100">
8 <match type="string" value="mimetypeimage/openraster" offset="30"/>
9 </magic>
10 <glob pattern="*.ora" />
11 </mime-type>
12</mime-info>
  
1#!/usr/bin/env python
2#
3# Installation hack for nautilus (adapt the path as needed):
4#
5# gconftool-2 --set /desktop/gnome/thumbnailers/image@openraster/command -t string "/usr/local/share/mypaint/desktop/openraster_thumbnailer.py %i %o %s"
6# gconftool-2 --set /desktop/gnome/thumbnailers/image@openraster/enable -t boolean "True"
7#
8# mkdir -p ~/.local/share/mime/packages
9# cp mime/mypaint.xml ~/.local/share/mime/packages/
10# update-mime-database ~/.local/share/mime
11#
12# ... and enjoy .ora thumbnails :-)
13#
14# References:
15# http://library.gnome.org/devel/integration-guide/stable/thumbnailer.html.en
16# http://create.freedesktop.org/wiki/OpenRaster/File_Layout_Specification
17
18
19import sys, zipfile
20import Image
21import StringIO
22
23if len(sys.argv) != 4:
24 sys.exit('Usage: '+sys.argv[0]+' <Input> <Output> <Size>')
25
26thumbnail = zipfile.ZipFile(sys.argv[1]).read('Thumbnails/thumbnail.png')
27
28im = Image.open(StringIO.StringIO(thumbnail))
29im.thumbnail( (int(sys.argv[3]), int(sys.argv[3])) )
30
31im.save(sys.argv[2], 'png')