Latest LQ Deal: Latest LQ Deals
Go Back > Blogs > linux-related notes
User Name


Just annotations of little "how to's", so I know I can find how to do something I've already done when I need to do it again, in case I don't remember anymore, which is not unlikely. Hopefully they can be useful to others, but I can't guarantee that it will work, or that it won't even make things worse.
Rate this Entry

Poor, but acceptable, work-around to the lack of image previews for XCF and ORA (maybe other formats as well)

Posted 09-18-2016 at 10:35 PM by the dsc
Updated 09-18-2016 at 11:58 PM by the dsc
Tags gimp, ora, xcf

Apparently there isn't much system-wide preview support for formats such as XCF and ORA. It used to be better at some point, at least when KDE was mostly QT4, at some point I had fancy thumbnail previews of everything. Everything! Gwenview apparently was also at some point able to preview ORA and maybe the others, but I've never seen that.

So, unfortunately I'm not a programmer or anything, so I can only look for poor man's solutions like a script that converts such files into more ordinary files whose support wasn't broken yet, like JPEG.

I've found one that does just that using GIMP, and tweaked a little bit:


cat <<EOF
(define (convert-xcf-to-jpeg filename outfile)
  (let* (
	 (image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
	 (drawable (car (gimp-image-merge-visible-layers image CLIP-TO-IMAGE)))
    (file-jpeg-save RUN-NONINTERACTIVE image drawable outfile outfile .9 0 0 0 " " 0 1 0 1)
    (gimp-image-delete image) ; ... or the memory will explode

(gimp-message-set-handler 1) ; Messages to standard output

for i in $@ ; do


  echo "(gimp-message \"$i\")"
  echo "(convert-xcf-to-jpeg \"$i\" \"${corename}_${ext}_preview.jpg\")"

echo "(gimp-quit 0)"
} | gimp -i -b -
It differs from the original in which instead of converting everything on sight on the current folder, you can give the file names individually or use something like "xcf2jpg *.ora" (even though I'm not sure it handles filenames with spaces, apparently the whole "GLOB" thing is smart enough and takes care of that correctly), and instead of just replacing the extension for the preview name it uses "_xcf_preview.jpg" (or ora, or whatever is the original file extension).

It also works with .ora at least, even though the .ora plugin is broken as of now, but it can be easily fixed by deleting three or four lines. In theory it should work with any format GIMP opens. The result isn't that good with "ora" files, though, apparently GIMP doesn't do a perfect conversion, I think ORA has a white "hidden" background layer that apparently GIMP misses, or, for whatever reason, there are lots of squarey areas filled with 100% black.

It turns out that unzip + convert will do a much better job at least for ora files. Both in CPU-loading terms and quality of the preview. ORA files already have a native preview PNG inside them -- they're just "zip" files renamed as "ora". Therefore a script would exploit something like this:

unzip -p $1 mergedimage.png | convert png:- -quality 72 ${1%.*}_ora_preview.jpg
Older .ora files don't have this preview file, though, but rather a much smaller thumbnail at "Thumbnails/thumbnail.png".
Posted in Uncategorized
Views 1904 Comments 2
« Prev     Main     Next »
Total Comments 2


  1. Old Comment
    I see you're using convert for the ORA previews, so I guess you are using GraphicsMagick? At least on Sid, GM supports XCF.

    If so, give this one a shot:

    convert -layers merge -quality 72 ${1} ${however_you_want_to_name_preview}
    would perhaps knock down your script to :

    function make_thumbnail() {
        convert_flags="-layers merge -quality 72"
        case ${1##*.} in
                # Check ORA version and proceed...?
                unzip -p ${1} mergedimage.png | convert png:- ${convert_flags} ${new_filename}
                convert ${convert_flags} ${1} ${new_filename}
    Of course you don't need to make it a function, but doesn't hurt either if you want to add it to a larger library later on.
    Posted 09-27-2016 at 09:30 AM by goumba goumba is offline
    Updated 09-27-2016 at 09:44 AM by goumba
  2. Old Comment
    Thanks. It's ImageMagick. I haven't tried GraphicsMagick that yet, but the problem with some non-GIMP XCF-to-something conversion methods is that they often won't deal correctly with transparencies, creating images with some 100% black rectangular areas, sometimes obscuring stuff that was supposed to be visible.
    Posted 09-27-2016 at 07:33 PM by the dsc the dsc is offline
    Updated 09-27-2016 at 08:16 PM by the dsc


All times are GMT -5. The time now is 10:15 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration