You are here

Automatic backup of open images

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
Rate this item!
AttachmentSize
autosave_a_3.zip26.46 KB

Thanks to 'RobA' who discussed this topic here recently, the Python plug-in 'autosave.py' attracted my attention. My work inspired by it is included below.
What I think is new here from the three existing one, that I know. It has a configuration section and the possibility to stop it, so you can restart with a new purpose (configuration) or not.

After an extraction of the zip archive in the '.../.gimp-2.x/plug-ins' directory it should appears in GIMP under the menu: "(Image)/Extensions/Plugins-Python/File/Autosave...".
Please dock the error console before running 'autosave_a'. A good idea is to have it always open.

Edit_3 [2012/06/06]: corrected a behavior bug (keeps saving after a close window) and added some improvements in the preset department.
Edit_4 [2012/07/12]: Avoiding to pass, if possible, the name 'Untitled' given to imported images in GIMP-2.8.0 to the backup file. Acting on the suggestion of 'Derelicht' with a new procedure 'noUI_autosave_a' included in the file 'autosave_a.py'.
Edit_5 [2012/07/15]: Made 'autosave_a' aware of 'noUI_autosave_a' and patch a control freak bug. The bug was the possibility of multiple instances of 'noUI_autosave_a'; a low visibility plug-in with minimal control. This complete version 0.2 which started with Edit_3.

Edit_6 [2012/12/17]: beginning of version 0.3
a) Check folder and file existence, following a small patch to avoid a crash when a backup file was remove during execution. Also 'noUIautosave_a' will alway save somewhere.
b) The old 'autosave.cfg' file is no longer used because the name of the dictionary key have been made more meaning full, sorry.
c) It should now gives a warning in the 'Error Console' if another instance of 'autosave_a' is running.
d) Some small tweaks to the user interface like using language translation to change menu placement, etc.
In the attachment 'autosave_a_3.zip'.
Edit_7 [2013/01/12]: Gives free space info after changing the folder or starting 'autosave_a'.
In the attachment 'autosave_a_3.zip'.
Edit_8 [2013/02/24]: continuation on the theme of version 0.3 : what can go wrong without intent?
a) Change in the function call to 'change dir.', so only folder can be accessed.
Also the former function was deprecated in GTK.
b) Terminating when there is no free space left.
c) More graceful automatic error terminations.
d) Debug: special characters (non ASCII) in the Windows file system work with the plug-in now;
tested on Jernej Simončič's 2.8.4 build.
In the attachment 'autosave_a_3.zip'.
Edit_9 [2013/02/28] :
Debug of the label color scheme
Debug the 'noUIautosave_a' automatic error termination.
Edit_10 [2013/10/25] :
Encounter a similar problem as was mentioned in 'Comments: plugin crashing' in 'openSUSE 12.3' which was solved by this update version. This terminate version 0.3. [2013/10/27] Sorry, included a faulty file, retry now!

Bye, Robert

Code License: 
GIMP Version: 
Scripting Engine: 

Comments

Hi Robert,
Your plugin in crashed the first time I used it!

Here is a screenshot of the error message:
http://imgur.com/vWHlmcA

This is Gimp 2.8.4 running in Ubuntu 13.04

Hope this is useful!
Really looking forward to getting this going!

Gimp:
gimp 2.8.4-1ubuntu1
gimp-data 2.8.4-1ubuntu1
gimp-data-extras 1:2.0.1-3
gimp-dcraw 1.31-1.1
gimp-dds 2.0.9-3ubuntu1
gimp-dimage-color 1.1.0-3.1ubuntu1
gimp-flegita 0.6.2-1.1ubuntu3
gimp-gap 2.6.0+dfsg-3ubuntu1
gimp-gmic 1.5.1.6+dfsg-4build1
gimp-gutenprint 5.2.9-1ubuntu1
gimp-help-common 2.6.1-1
gimp-help-en 2.6.1-1
gimp-lensfun 0.2.1-1ubuntu1
gimp-plugin-registry 5.20120621ubuntu2
gimp-resynthesizer 0.16-3
gimp-texturize 2.1-2
gtkam-gimp 0.1.18-1
libgimp2.0 2.8.4-1ubuntu1
libgimp2.0-doc 2.8.4-1ubuntu1

Python:
python2.7 2.7.4-2ubuntu3.2
python2.7-dev 2.7.4-2ubuntu3.2
python2.7-minimal 2.7.4-2ubuntu3.2
python3 3.3.1-0ubuntu1
python3-apport/raring-updates uptodate 2.9.2-0ubuntu8.3
python3-apt 0.8.8ubuntu6
python3-aptdaemon 1.0-0ubuntu9
python3-aptdaemon.gtk3widgets 1.0-0ubuntu9
python3-aptdaemon.pkcompat 1.0-0ubuntu9
python3-commandnotfound/raring-updates uptodate 0.3ubuntu7.1
python3-dbus 1.1.1-1ubuntu3
python3-defer 1.0.6-2
python3-distupgrade/raring-updates uptodate 1:0.192.13
python3-gdbm 3.3.1-0ubuntu2
python3-gi 3.8.0-2
python3-minimal 3.3.1-0ubuntu1
python3-pkg-resources 0.6.34-0ubuntu1
python3-problem-report/raring-updates uptodate 2.9.2-0ubuntu8.3
python3-software-properties 0.92.17.3
python3-uno 1:4.0.2-0ubuntu1
python3-update-manager/raring-updates uptodate 1:0.186.2
python3-xkit 0.5.0ubuntu1
python3.3 3.3.1-1ubuntu5.2
python3.3-minimal 3.3.1-1ubuntu5.2
libboost-python1.49.0 1.49.0-3.2ubuntu1
libpython-dev 2.7.4-0ubuntu1
libpython-stdlib 2.7.4-0ubuntu1
libpython2.7 2.7.4-2ubuntu3.2
libpython2.7-dev 2.7.4-2ubuntu3.2
libpython2.7-minimal 2.7.4-2ubuntu3.2
libpython2.7-stdlib 2.7.4-2ubuntu3.2
libpython3-stdlib 3.3.1-0ubuntu1
libpython3.3 3.3.1-1ubuntu5.2
libpython3.3-minimal 3.3.1-1ubuntu5.2
libpython3.3-stdlib 3.3.1-1ubuntu5.2
python 2.7.4-0ubuntu1
python-appindicator 12.10.1daily13.04.15-0ubuntu1
python-apt 0.8.8ubuntu6
python-apt-common 0.8.8ubuntu6
python-aptdaemon 1.0-0ubuntu9
python-aptdaemon.gtk3widgets 1.0-0ubuntu9
python-avahi 0.6.31-1ubuntu3
python-cairo 1.8.8-1ubuntu4
python-central 0.6.17ubuntu2
python-chardet 2.0.1-2build1
python-cups 1.9.62-0ubuntu3
python-cupshelpers 1.3.12+20130308-0ubuntu4
python-daemon 1.5.5-1ubuntu1
python-dbus 1.1.1-1ubuntu3
python-dbus-dev 1.1.1-1ubuntu3
python-debian 0.1.21+nmu2ubuntu1
python-defer 1.0.6-2
python-dev 2.7.4-0ubuntu1
python-eggtrayicon 2.25.3-12
python-gconf 2.28.1+dfsg-1build1
python-gdbm 2.7.4-0ubuntu1
python-gi 3.8.0-2
python-glade2 2.24.0-3ubuntu1
python-gnome2 2.28.1+dfsg-1build1
python-gnomekeyring 2.32.0+dfsg-2ubuntu1
python-gobject 3.8.0-2
python-gobject-2 2.28.6-11
python-gst0.10 0.10.22-3ubuntu1
python-gtk-vnc 0.5.1-1ubuntu2
python-gtk2 2.24.0-3ubuntu1
python-gtksourceview2 2.10.1-2build1
python-gtkspell 2.25.3-12
python-ibus 1.4.2-0ubuntu2
python-libuser 1:0.56.9.dfsg.1-1.2ubuntu2
python-libvirt 1.0.2-0ubuntu11.13.04.4
python-libxml2 2.9.0+dfsg1-4ubuntu4.3
python-lockfile 1:0.8-2ubuntu1
python-minimal 2.7.4-0ubuntu1
python-mpd 0.3.0-4
python-notify 0.1.1-3ubuntu1
python-pkg-resources 0.6.34-0ubuntu1
python-pycurl 7.19.0-5ubuntu8
python-pyorbit 2.24.0-6ubuntu3
python-pysqlite2 2.6.3-3
python-qt4 4.10-0ubuntu3
python-qt4-dbus 4.10-0ubuntu3
python-requests 1.1.0-1
python-sip 4.14.5-0ubuntu1
python-six 1.2.0-1
python-smbc 1.0.13-0ubuntu4
python-software-properties 0.92.17.3
python-support 1.0.15
python-tagpy 0.94.8-4
python-urlgrabber 3.9.1-4ubuntu2
python-urllib3 1.5-0ubuntu1
python-vte 1:0.28.2-5ubuntu1
python-xdg 0.25-2
python-xklavier 0.4-4

Hi rdav,
Its nice to have some news about that plug-in.
Since you have many installed Python packages my first try at a solution is to specify which 'pygtk' to import.

So open 'autosave_a.py' with an editor, change line 31 and insert the 'pygtk.require('2.0')' line after.
Like below:

29 ...
30 import gtk, shelve, pango
31 import gettext, pygtk
-> pygtk.require('2.0')
32 from gobject import timeout_add_seconds
33 ...

If this don't work, keep it (will not break anything), I will need a more specific error message then http://imgur.com/vWHlmcA .
To obtain it start GIMP in a terminal.

Hi Robert,
Thanks for the rapid reply!
The edit you suggested didn't resolve the error,

the autosave_a.py file was edited thus:
import gettext, pygtk
pygtk.require('2.0')

terminal output with unedited plugin:
$ gimp
(gimp:24806): Gimp-Widgets-CRITICAL **: gimp_device_info_set_device: assertion `(info->device == NULL && GDK_IS_DEVICE (device)) || (GDK_IS_DEVICE (info->device) && device == NULL)' failed
Traceback (most recent call last):
File "/home/rd/.gimp-2.8/plug-ins/autosave_a.py", line 171, in
shelf_fl = Save_recall()
File "/home/rd/.gimp-2.8/plug-ins/autosave_a.py", line 63, in __init__
if os.path.isfile(sys_file(self.file_shelf)): self.manage_folder_exist()
File "/home/rd/.gimp-2.8/plug-ins/autosave_a.py", line 88, in manage_folder_exist
if not os.path.exists(sys_folder):
File "/usr/lib/python2.7/genericpath.py", line 18, in exists
os.stat(path)
TypeError: coercing to Unicode: need string or buffer, NoneType found

After editing the plugin, the menu item "Plugings-Python" disappeared.
terminal output from edited plugin:
$ gimp
(gimp:24939): Gimp-Widgets-CRITICAL **: gimp_device_info_set_device: assertion `(info->device == NULL && GDK_IS_DEVICE (device)) || (GDK_IS_DEVICE (info->device) && device == NULL)' failed
Traceback (most recent call last):
File "/home/rd/.gimp-2.8/plug-ins/autosave_a.py", line 172, in
shelf_fl = Save_recall()
File "/home/rd/.gimp-2.8/plug-ins/autosave_a.py", line 64, in __init__
if os.path.isfile(sys_file(self.file_shelf)): self.manage_folder_exist()
File "/home/rd/.gimp-2.8/plug-ins/autosave_a.py", line 89, in manage_folder_exist
if not os.path.exists(sys_folder):
File "/usr/lib/python2.7/genericpath.py", line 18, in exists
os.stat(path)
TypeError: coercing to Unicode: need string or buffer, NoneType found
(gimp:24939): LibGimpBase-WARNING **: gimp: gimp_wire_read(): error

For completeness, terminal output with no plugin:
$ gimp
(gimp:24743): Gimp-Widgets-CRITICAL **: gimp_device_info_set_device: assertion `(info->device == NULL && GDK_IS_DEVICE (device)) || (GDK_IS_DEVICE (info->device) && device == NULL)' failed

cheers

Hi rdav,
Thank you, a very complete observation.
From that it seems adding the line 'if sys_folder == None: continue' after line 86 is prudent. Like below.

85 ...
86 sys_folder = sys_file(f[keyV]['dir_BU'])
-> if sys_folder == None: continue
87 if keyV[:6] == 'recall':
88 ...

Hope it goes to the next problem!
Regards

Hi rdav,
A possible explanation for the plug-in behavior is that your current folder when you called it is not local (possibly in the 'cloud').
It was constructed under the assumption of local folders only and the protection against non local one is missing!
Thanks for bringing it to my attention.

If you can change the current active folder to a local one if it was not. Then it is possible to test that explanation by deleting 'autosave1.cfg', if there, in sub-folder '.../plug-ins/autosave_a' before starting GIMP?

Regards

Hi rdav,

A nice setup, as for the GIMP devs this plug-in is not there first responsibility.

In my Linux GIMP Python console:

>>> import gtk
>>> temp = gtk.FileChooserDialog()
>>> print("the current folder: "+temp.get_current_folder())
the current folder: /home/robert

In your case, I think from your feedback, the above 'print...' line will generate a 'Traceback', which means that gtk.FileChooserDialog() is unable to comply so it return 'None'.
This gtk.FileChooserDialog() is use, in many place, by the plug-in to select the backup folder.

To ascertain that 'os.path' is not as confuse as 'gtk.FileChooserDialog()' by your file system;
please verify that "/home/rd/.gimp-2.8/plug-ins/autosave_a" folder (not file) is there and was not before using 'autosave_a.py'?

If yes, it may be worth to update the plug-in, but not sure because it seems due to a lack of support by Ubuntu-13.04 to legacy GTK2.

Regards

Hi Robert,
Gimp folder is already local, in home directory as set up with standard Linux install.
In the terminal output I shared with you has the directory, as in:

File "/home/rd/.gimp-2.8/plug-ins/autosave_a.py", line 171,

/home,/rd is the local directory and "rd" is my user name!

I don't run fancy stuff like folders on cloud, other networked machines or external hard drives. The hard drive is partitioned like thus: /, /home, swap.

Only thing really different to standard Linux install is that /home and swap are encrypted. Also as the / and /home share 125GB on a SSD harddrive on a laptop, the swap is 12GB sd-card to free up a bit of space. Linux runs this lappie pretty well, I only wish it could cool itself a lot better!

Thanks for your help and diligence in making this available and your efforts toward this are impressive in the light of not even the Gimp devs have figured it out!

cheers

Hi Robert,
Yep, solved the error dialog, still no config dialog,

Terminal output:

$ gimp
(gimp:6141): Gimp-Widgets-CRITICAL **: gimp_device_info_set_device: assertion `(info->device == NULL && GDK_IS_DEVICE (device)) || (GDK_IS_DEVICE (info->device) && device == NULL)' failed
Traceback (most recent call last):
File "/usr/lib/gimp/2.0/python/gimpfu.py", line 807, in _run
res = apply(func, params[1:])
File "/home/rd/.gimp-2.8/plug-ins/autosave_a.py", line 908, in autosave_a
co_au = Control_Autosave(img)
File "/home/rd/.gimp-2.8/plug-ins/autosave_a.py", line 452, in __init__
self.set_config()
File "/home/rd/.gimp-2.8/plug-ins/autosave_a.py", line 474, in set_config
self.label0.set_text(mess)
TypeError: Gtk.Label.set_text() argument 1 must be string, not None

cheers

I just notice this script i didn't try yet, maybe already the configuration file may be used to got what i wish:

Save a copy of the image at each change where " change" may be the application of a filter, or a stroke with a brush tool , or anything similar that modify the visible

"Save as " using the original file name as base (or asking for a name) + a postfix starting from 000001
(if the name chosen is "Cool Image", output would be Cool Image_000001.xcf,Cool Image_000002.xcf, and so on)

A similar option would make easier record speed-paintings as animations, create and record as video the evolution from WIP to polished work, for tutorial and so on

Do you think possible include a similar option ?

Hi PhotoComiX,
Looking at your two wishes:

1) 'Save a copy for each change ...':
This in my opinion will needed a new structure for the plug-in, if I interpret correctly, and this is not planned. Now the plug-in saves on a basis of regular time interval not on internal image change. Under that provision it is possible to save only open file witch have there dirty flag set (GIMP's window title starting with *) at that time by the existing configuration choice, 'All changed'. Now the dirty flag is not reset by the plug-in after such a backup.

2) '... using the original file name as base ...':
Here after naming your image "Cool Image" in GIMP and opening the plug-in: the configuration choice 'Launching one' will nearly do it (backup files: 'BU-ID1-Cool Image-1.xcf', 'BU-ID1-Cool Image-2.xcf', and so on). I use GIMP for photo retouching and no experience in speed-paintings or few in animation; so it's influence me. Perhaps the maximum of 'nr kept' is not enough, the minimum for time interval too large or the file extension choice insufficient?
For wish 2) it seems very possible.

Pages

Subscribe to Comments for "Automatic backup of open images"