|
carol.gimp.orggimp2Python:Blurbed Gallery |
|
This script is a little more picky about what it needs than the Simple Gallery plug-in. This script needs an additional file for each image. It produces an html file for the image that contains text for that image. (An example of the new image file:notvalidxhtml.html.) It displays all of the images from the blurbs in one simple gallery page. |
Prepare to use the script.This script reads files that end in .blurb in one directory. It reads the sequence, the location of the original image and a text from the .blurb file and uses this information to compose a gallery. It saves the original image in three sizes, and names it after the directory the file is located in and the original image name. It saves html for each image named after the name of the .blurb file and links these individual pages with each other using the sequence to build a navigation. That is a lot of information. Lets look at a blurb file instead. |
| webdav.blurb |
|---|
|
File Edit Search Preferences |
4 /photos/WebUtility/2004-11-img_0023.xcf I can not remember the reason I thought this image would be good for web dav pages.... |
|
The blurb name, "webdav.blurb" is reduced to "webdav" and used to name the
html and make titles on the gallery page. The number 4 is the sequence that the image is listed
in. In this scruffy little script, if the sequence numbers are not in order things can be over
written or even ignored, maybe. The script uses this number to set up a navigation on the themed
gallery pages. The next line is the location of the image on the users computer. It uses the
image name and the location to make a unique file name.
I have packaged up a simple example collection of four images and blurb files. If you
would like to see the blurbed gallery script run without getting a bunch of images together yourself. Each of the four blurbs point to an image within
the directory you have unpacked. You might need to prefix the urls in the blurb files with the
location of this directory. For instance, |
Install the scriptTo install the blurbed gallery script download it to someplace you can find with the commandline on your computer. |
carol@treva:~$ gimptool --install-bin gallery-blurbed.py /usr/bin/install -c -d /home/carol/.gimp-2.3/plug-ins /usr/bin/install -c gallery-blurbed.py /home/carol/.gimp-2.3/plug-ins/gallery-blurbed.py carol@treva:~$ |
|
Or if you don't have a gimptool, don't worry. The gimptool is actually performing a very very simple task at this point. You, the human, can do this in two steps. Find out where your gimp is keeping its files in your home directory. I am using gimp-2.3 from cvs so my files are located /home/carol/.gimp-2.3/plug-ins/. |
carol@treva:~$ cp gallery-blurbed.py /home/carol/.gimp-2.3/plug-ins/ carol@treva:~$ chmod a+x /home/carol/.gimp-2.3/plug-ins/gallery-blurbed.py carol@treva:~$ |
|
Once it is installed, it should lodge itself into your <Toolbox> -->Xtns -->Python-Fu and calls itself BlurbedGallery. Restart gimp and see if it is there. There is only one reason I can think of that the script would not install, that would be if you did not have the gimp python module installed on your computer. So far, python and gimp do not work together on Windows and on gnu/linux, it needs a special message sent to the configuration script to tell it to build. Perhaps your distribution ships it separately, perhaps you did not enable python when you built yours. I am trying to put information about that on my python and gimp page |
Launch the Plug-inFind the plug-in at <Toolbox> -->Xtns -->Python-Fu -->GalleryBlurbed it will pop up a large dialog. |
|
|
Fill in the information it asks for. Try to avoid spaces in either the author name or the gallery class. It would probably work fine, but there are problems with them often enough that I still avoid making file names with spaces. I did not write the script to handle this. This plug-in is going to duplicate the original and scale that down twice and write web pages to display them. So when picking the place the pages should land, you need to have a directory location that can handle this many images as you have xcfs and also be viewable with your browser. I suggest to save the images to some directory name in /tmp/ until you are happy with the results. Use the little file selector button and show the plug-in a place to write all of these files to. It names the images with a unique name that the script determines from the location of the image on your computer. After all of the image files have been flattened and saved in 3 different sizes, the python portions of this plug-in spews some html and saves it with the newly created images. It does this very quietly. If you have a directory with a gazillion xcfs in it, it might take a few moments. To see your new gallery page show your browser to BlurbClass.html. I check this plug-in spew with Mozilla, the pages were written to look good enough in it. |
A More Complicated ExampleThe simple gallery example from earlier does not show off the way this plug-in works, as it is working with images found in one single directory. This is not a necessary condition for the plug-in. I download all of the images from my camera and put them always in the same place. The blurb files I use point to this permanent location and I try to write the scripts so that produced images will have unique names based on this location. I archived a more complicated example of images and blurbs to demonstrate how this script handles the different file locations. The same edit to the prefix of the url will need to be performed. |
Edit the scriptremove debugging spewI added a lot of debugging spew in the course of making this work for this web page. You can remove it yourself. All it does is print useful information into the console and it has no effect on the files you are writing or the images you are touching. Remove line 209 and lines 282-286 from the script. |
| gallery-blurbed.py |
|---|
|
File Edit Search Preferences |
209 print 'imagefile = ' + imagefile 210 211 image = pdb.gimp_file_load(imagefile, imagefile) 212 image.flatten() 213 calc_dims(image, info, screen_side, thumb_side) 214 277 278 imageident,ext = os.path.splitext(image_file) 279 directoryident,image_ident = os.path.split(imageident) 280 other,directory_ident = os.path.split(directoryident) 281 image_name = directory_ident + '-' + image_ident 282 print 'blurb_name = ' + blurb_name 283 print 'image_file = ' + image_file 284 print 'directory_ident = ' + directory_ident 285 print 'image_ident = ' + image_ident 286 print 'image_name = ' + image_name 287 288 blurb = {} 289 blurb['blurb_name'] = blurb_name 290 blurb['sequence'] = sequence 291 blurb['image_file'] = image_file 292 blurb['image_name'] = image_name 293 blurb['text'] = text 294 |
image commentThis comment does more than the simple gallery comment did. It writes the author name and the blurb name into the image. It also contains a typo. Edit the file and put a space in front of the m in 'made by ' in line 215. |
| gallery-blurbed.py |
|---|
|
File Edit Search Preferences |
211 image = pdb.gimp_file_load(imagefile, imagefile) 212 image.flatten() 213 calc_dims(image, info, screen_side, thumb_side) 214 215 comment_text = blurbname + 'made by ' + yourname + ' and TheGIMP!' 216 comment = "%s\nSource: %s" % (comment_text, imagename) 217 218 original_image = os.path.join(page_location, imagename + '-original.jpg') 219 info['original_image'] = original_image 220 save_jpeg(image, original_image, comment) |
|
Another way to edit the comment is to change the way the script handles comments. In my scripting resources section, there is a sub-routine that will read a text file and add it to a jpeg comment. |
Edit the templatesThe template portion of the script is fairly easy and quite flexible. Templates are marked with three quotation marks in a row, at the beginning and the ending of the template ("""). the page styleThese templates use the same styles as the simple gallery did. |
the htmlMostly, this is the same html from the simple gallery, with the addition of a text and navigation.
The |
| filenotfound.blurb |
|---|
|
File Edit Search Preferences |
2 /photos/WebUtility/2003-06/img_0326.xcf The page you have tried to access is not available at that location. </p><p> This image is getting a little old. |
|
Another interesting way to enhance the blurb and template interaction would be to rewrite the html so that the text and the description falls in the second table element. That way, a blurb and new table elements and even rows could be added to the image page via carefully applied html from the blurb. |
|
|
|