Autosave Plugin

ForumsFor GIMP developers (read-only) ► Autosave Plugin

Sent: 2009-07-07 18:06:42 UTC (over 2 years ago)

From: yahvuu

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",
"/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

Welcome!


Lost password?

Not a member? Sign up!

Random tutorials | Latest tutorials

  1. Cool glowing text Cool glowing text 40
  2. Smelting text / Creating blood text Smelting text / Creating blood text 37
  3. Crazy Ions Crazy Ions 4
  4. "Solar winds" graphics effect "Solar winds" graphics effect 7

Latest comments

A facebook page, could be great too! (about 14 hours ago in GIMP gets closer to the community with Google+!)

bah just use 2.7.4 (or 2.7.5 on Windows) (about 17 hours ago in Last stable 2.6 release: 2.6.12 has arrived)

Hmm, would prefer Diaspora, I don't use G+ myself, but I guess it h... (about 17 hours ago in GIMP gets closer to the community with Google+!)

Poll

Is GIMP an adequate application for you to create printed graphics like flyers, advertisments etc?

View results

Latest forum activities

Your Ad Here

facts & numbers

gimpusers.com RSS feed

48 identi.ca followers
745 Twitter followers

powered by bitfire it services