Add Borders and Copyright information in Gimp
I modified the batch processing plug-in for Gimp called PhotoLab to add a border that I liked better than the original. I also added copyright information that is written on the border. The biggest hurdle though was Gimp itself -- the built-in jpg save functions lose all the metadata, including the photo-taken timestamp that I use to sort the photos and the photo captions.
To rectify this problem, I called the executable version of exiftools from within the python script. A better way would have been to code it directly into the plug-in, but I ran out of patience for that. Hopefully the upcoming Gimp version 2.8 will fix this problem.
It is not particularly robust, but these items are essential:
*Gimp python script capability must be installed (http://www.gimpusers.com/tutorials/install-python-for-gimp-2-6-windows.html)
*exiftool.exe needs to be on your path (http://www.sno.phy.queensu.ca/~phil/exiftool/)
Credits
1. The "base" of the script was batch processing for adding borders and title information from the PhotoLab suite of Gimp tools. http://registry.gimp.org/node/157
List of changes:
Changed the "title" feature to be a copyright feature
Placed the copyright information on the border (size scales with border so it always fits).
Replaced the border with one I liked better (see #2 below)
Used exiftool to preserve metadata (see #3 below)
Note: I have not renamed the script from the PhotoLab original.
Note: The script is now limited to JPG images (mostly to preserve metadata)
2. I replaced the border with a modified version of the border implemented in the two_color_borders.py script. http://registry.gimp.org/node/24635
Changed the script so that the border overlays the edges of the current image in order to maintain the original aspect ratio. A quick code change can switch it back (I meant to make this an option, but ran out of time).
3. In order to "preserve" metadata, I used ExifTool (http://www.sno.phy.queensu.ca/~phil/exiftool/) to copy the metadata from the original JPG to the new JPG.
Note: ExifTool.exe must reside on your path.
Attachment | Size |
---|---|
photolab_addborder.py.txt | 9.96 KB |
Comments
photolab border
I get the exact same error on Gentoo Linux Gimp 2.6.10.
I'll go through the code later to see if I can find an explanation.
Gerard.
Traceback (most recent call last):
File "/usr/lib64/gimp/2.0/python/gimpfu.py", line 692, in response
dialog.res = run_script(params)
File "/usr/lib64/gimp/2.0/python/gimpfu.py", line 353, in run_script
return apply(function, params)
TypeError: python_fu_photolab_addborder() takes exactly 15 arguments (12 given)
I also tried it in batch
I also tried it in batch mode.
Input directory ~/foto's_jan
Output directory ~/photolabexperiment
I found one picture in the output directory but.........
This picture came from ~/foto's Bent!
Then it errored out.
Traceback (most recent call last):
File "/usr/lib64/gimp/2.0/python/gimpfu.py", line 692, in response
dialog.res = run_script(params)
File "/usr/lib64/gimp/2.0/python/gimpfu.py", line 353, in run_script
return apply(function, params)
File "/home/ikke/.gimp-2.6/plug-ins/photolab_addborder.py", line 262, in python_fu_photolab_addborder_batch
python_fu_photolab_addborder(filepathname, fileNum, numFiles, img, imglayer, outerBorderPct, innerBorderPct, outerBorderColor, innerBorderColor, titleColor, addCopyright, title, font, export, toDirectory);
File "/home/ikke/.gimp-2.6/plug-ins/photolab_addborder.py", line 204, in python_fu_photolab_addborder
retcode = subprocess.call(["exiftool", "-q", "-overwrite_original", "-tagsfromfile", filepathname, "-all:all", newfilepathname])
File "/usr/lib64/python2.6/subprocess.py", line 470, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib64/python2.6/subprocess.py", line 623, in __init__
errread, errwrite)
File "/usr/lib64/python2.6/subprocess.py", line 1139, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
My Linux install and python in particular is in good health.
Have been using Gentoo for over 6 years.
Unfortunately I am not a programmer so I'm unable to find what is wrong.
Gerard.
Edit 19-09-2010.
Stupid me,this will only run on Windows if at all.
Hi
If you look at line 204 in the Photolab_addborder.py code
#Copy metadata using exiftool.exe
retcode = subprocess.call(["exiftool", "-q", "-overwrite_original", "-tagsfromfile", filepathname, "-all:all", newfilepathname])
you see the problem you're experiencing on linux without "exiftool" is due to the fact we don't have exiftool that it calls.
For me it worked perfectly after adding a # in front of retcode
#Copy metadata using exiftool.exe
#retcode = subprocess.call(["exiftool", "-q", "-overwrite_original", "-tagsfromfile", filepathname, "-all:all", newfilepathname])
And you'll be good to go
:)
Thanks Alvere. It now
Thanks Alvere.
It now works.
Gerard.
Script doesnt work
I tried to use this script in Gimp 2.6.8 under Ubuntu 10.4 (64) but I ran into an error:
An error occured running python-fu-photolab-addborder
TypeError: python_fu_photolab_addborder() takes exactly 15 arguments (12 given)
Traceback (most recent call last):
File "/usr/lib/gimp/2.0/python/gimpfu.py", line 692, in response
dialog.res = run_script(params)
File "/usr/lib/gimp/2.0/python/gimpfu.py", line 353, in run_script
return apply(function, params)
TypeError: python_fu_photolab_addborder() takes exactly 15 arguments (12 given)
Pls help
Hi
Hi
If you look at line 204 in the Photolab_addborder.py code
#Copy metadata using exiftool.exe
retcode = subprocess.call(["exiftool", "-q", "-overwrite_original", "-tagsfromfile", filepathname, "-all:all", newfilepathname])
you see the problem you're experiencing on linux without "exiftool" is due to the fact we don't have exiftool that it calls.
For me it worked perfectly after adding a # in front of retcode
#Copy metadata using exiftool.exe
#retcode = subprocess.call(["exiftool", "-q", "-overwrite_original", "-tagsfromfile", filepathname, "-all:all", newfilepathname])
And you'll be good to go
:)
Well it works only in batch
Well it works only in batch mode.
In single file mode it still errors out.
I'll have more time in the weekend to experiment with it though I'm
not a python programmer.
Gerard.
To much bother.
I wanted something to add text in a border.
Found it in Filters > Decor > Photo Border.
I deleted the plugin.
Gerard.
How to add different sized border on each side?
The script is wonderful, but I am in need of three stuffs?
1) I need to specify different border size for left, right, top and bottom? How can I modify the script to achieve so?
2) I need to choose the font-size for copyright info. How is that possible? Also how to add multiline copyright info if required?
3) I want to extract exif information and print it on a specific border similar to copyright info, but multilines. Is that possible with the script?
4) Is it possible to add a hidden watermark also? If yes, what are the changes needed in the script?
I have no knowledge of python. Any help appreciated. Thanks!!