gimpusers.com logo
German version English version

Not logged in

Sign up! | Lost password?

Latest discussion

  1. gimp-docs | yesterday 10:55 PM
    a new user perspective
  2. gimp-developer | yesterday 08:04 PM
    scanner support should be File->Acquire
  3. gegl-developer | yesterday 06:24 PM
    babl docs
  4. gimp-docs | yesterday 12:46 PM
    GIMP Manual
  5. gimp-user | yesterday 09:42 AM
    Bug

External news

Poll

How good are you at programming?

OMG, that is nothing for me at all!

I've been coding a little bit but I'm not very fit at it

I'm pretty good at programming and would maybe be able to write a Plug-In for GIMP

I'm very good at programming and I would theoretically be able to hack for the GIMP core

See results

Stats

gimpusers.com RSS feed

GIMP Forums » For GIMP developers

Autosave Plugin

Jump to message:

  1. Autosave Plugin — yahvuu, 07 Jul 2009 06:06 PM

As a registered user, you can subscribe forum threads in order to get notified when replies are posted. Just log in at the right top of the page if you already have an account, otherwise you can register for free.

Permalink:4A537292.7010309@gmail.com
Date:07 Jul 2009 06:06 PM
From:yahvuu
Subject:Autosave Plugin
Hi all,

periodical autosave is long standing demand (bug 138373).
While in my regard this is headed in a totally wrong direction [1],
there's nothing wrong with having a plugin that works this way.

Somewhat suprisingly, i couldn't find such a plugin, so here's some
dirty PyGIMP which at first glance seems to do the job. Perhaps someone
gets inspired to create something worth uploading to the registry.

Usage:
- start GIMP from a terminal (so the script's messages become visible)
- toolbox: File->Activate Autosave (activate only once)

Every 30 minutes the script saves backups of all opened images to a temp folder.
The backup files won't be deleted when GIMP exits, so some manual clean-up will
be required from time to time.


have fun,
peter


[1] http://bugzilla.gnome.org/show_bug.cgi?id=138373#c25


#!/usr/bin/env python


import tempfile, os
from time import *
from gimpfu import *


def autosave():
backupInterval = 30*60

backupFiles = {}
print "Autosave activated"

while 1:
sleep(backupInterval)

print ctime(time())

curImages = {}
for k in gimp.image_list():
curImages[k.ID] = k

curIDs = curImages.keys()
oldIDs = backupFiles.keys()

newIDs = [x for x in curIDs if x not in oldIDs];
delIDs = [x for x in oldIDs if x not in curIDs];

# create (empty) backup files for new images
for id in newIDs:
prefix = 'gimpbackup-ID' + str(id) + '-'
fn = tempfile.mkstemp(prefix = prefix, suffix = '.xcf')
os.close(fn[0])
backupFiles[id] = fn[1]

# remove closed images' backups
for id in delIDs:
filename = backupFiles[id]
del(backupFiles[id])
try:
os.remove(filename)
except:
print "ERROR: ", sys.exc_info()[0]

# backup images
for id, filename in backupFiles.iteritems():
img = curImages[id]
try:
print "saving " + img.name + '-' + str(id) + ' to ' + filename
pdb.gimp_xcf_save(1, img, img.active_drawable, filename, filename)
except:
print "ERROR: ", sys.exc_info()[0]




register(
"autosave",
"Autosave dirty hack",
"Periodically saves all opened images to a temp directory",
"public domain",
"public domain",
"2009",
"<Toolbox>/File/Activate Autosave",
"RGB*, GRAY*",
[],
[],
autosave)

main()
_______________________________________________
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer
↑Back to thread overview

Adobe® Photoshop® is a registered trademark of Adobe Systems, Inc. Linux is a trademark of Linus Torvalds. Ubuntu and Canonical are registered trademarks of Canonical Ltd. | Clock times are shown as CET / CEST | Imprint / Privacy policy | powered by bitfire it services | sponsored by Hirners Hotel Guide