Last active
July 1, 2025 17:21
-
-
Save Iunius118/83709c8915a1d44827aee8c07d39ee20 to your computer and use it in GitHub Desktop.
Auto save plug-in for GIMP [2.8, 2.10]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Original (by yahvuu): https://www.gimpusers.com/forums/gimp-developer/11718-autosave-plugin | |
import tempfile | |
import os | |
from time import * | |
from gimpfu import * | |
def autosave(image, layer): | |
# Backup interval in seconds (600 = 10 minutes) | |
backup_interval = 10 * 60 | |
print('Autosave activated') | |
backup_files = {} | |
while 1: | |
sleep(backup_interval) | |
print(ctime(time())) | |
cur_images = {} | |
for k in gimp.image_list(): | |
cur_images[k.ID] = k | |
cur_ids = cur_images.keys() | |
old_ids = backup_files.keys() | |
new_ids = [x for x in cur_ids if x not in old_ids] | |
del_ids = [x for x in old_ids if x not in cur_ids] | |
# create (empty) backup files for new images | |
for id in new_ids: | |
prefix = 'gimpbackup-ID' + str(id) + '-' | |
fn = tempfile.mkstemp(prefix=prefix, suffix='.xcf') | |
os.close(fn[0]) | |
backup_files[id] = fn[1] | |
# remove closed images' backups | |
for id in del_ids: | |
filename = backup_files[id] | |
del(backup_files[id]) | |
try: | |
os.remove(filename) | |
except: | |
gimp.message('ERROR: ' + sys.exc_info()[0]) | |
# backup images | |
for id, filename in backup_files.iteritems(): | |
img = cur_images[id] | |
try: | |
print('Saving ' + img.name + '-' + str(id) + ' to ' + filename) | |
pdb.gimp_xcf_save(1, img, img.active_drawable, filename, filename) | |
except: | |
gimp.message('ERROR: ' + sys.exc_info()[0]) | |
register( | |
"autosave", | |
"Autosave dirty hack", | |
"Periodically saves all opened images to a temp directory (/tmp, %temp%, etc.)", | |
"public domain", | |
"public domain", | |
"2016", | |
"<Image>/File/Activate Autosave", | |
"*", | |
[], | |
[], | |
autosave) | |
main() |
I believe this plugin also works on the latest version of GIMP 2, but it would be better to use a more improved autosave plugin (like autosave_a.py).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
is this plugin still usable for gimp V2. 10 38 on windows systems? i lost all of my work multiple times and i'm frankly tired of gimp choosing when to and when to not make backups of my unsaved work (especially after a bluescreen)