Automatic import of images from a directory using a script

The reasons I made these scripts was, first of all, to learn some Python, but also to be able to create a picture file or album in Scribus. What I generally use this for is to organize the digital pictures I may take from some trip. One advantage of Scribus is that its native .sla files do not include image data, but only references to them, so this cataloguing file is relatively small. For some collections I will add annotations, make a PDF, and then print out an actual album.

Initially, I had created a stand-alone Perl program (scribalbum.pl) to do this outside of Scribus. It still works even though I made it according to the 1.2.x series of file formats. One advantage it has is that it is quite fast and will generate a many-paged document in a few seconds. Its disadvantage is that it rather clumsily just does a rote spitting out of a particular format, and there is a danger that it may not work with some future versions of Scribus. "Fixing" it to generate a 1.3.x format is more work than I would like. Best to load into 1.3.x Scribus then save from there.

The Python implementations have the advantage of using Scribus itself to make the document, so as long as the script works, the resulting file will be up-to-date. Another advantage is more easy modification to fit other needs.

I will add a link to the files once I learn how to upload files to the Wiki.

scribalbum.pl
I'm not going to say anything about this program. If you know something about Perl, you will see that it's not elegant, but it gets the job done. It operates on the command line.

scribalbum.py and scribalbuma4.py
These are similar Python scripts. Both create a new document and as many pages as needed. scribalbum.py places 4 staggered images on a US Letter page, allowing for annotations in the remaining white space. scribalbuma4.py places 8 images per A4 page with little remaining white space. Both versions will make a text frame in the upper left corner of each page indicating the directory the images came from, and each image has a label showing the image's filename.

Here are some features that both share:


 * When you run the script from within Scribus, you will see two Tk windows, one of which is blank, the other of which asks for the name of the directory and has a number of checkboxes. You can use a relative path, but an absolute one is more precise.


 * You may check one or as many image formats as you like. ALL images of that type will be included -- you cannot pick and choose individual images. As written, they will appear in alphanumeric order in your document, left column filled first. You could go left-right-left right down the page by changing the logic.


 * PDFs will import, but only the first page.


 * Thus far, SVGs will not import with this script. What you get is a blank frame. One of those "to do" things.


 * All images are adjusted to fit the frame size, and the frame size is the same within each script version. Adjusting the frame for individual images is a job best done in Scribus after you have made and loaded the file. These scripts are just meant to do the grunt work, let Scribus do the tweaking.


 * Once you have entered the directory, selected the image formats, then click OK. Expect some time to go by, during which Scribus frames and icons may blink in and out.


 * When the script is done, the formerly blank Tk window now says, "Now click the X in the upper right corner of this window", meaning the X in the corner of the Tk window to delete this window. This ends the script, and Scribus takes over.


 * At this point, Scribus is, in essence, loading this file for display, so you may have some considerable time (minutes) go by, depending on the number and size of the images and the speed of your processor.


 * If at this point Scribus crashes, you most likely have used up all your RAM and swap memory, and at this time there is no protection built into the script. If you're lucky, Scribus may have saved an emergency file starting with "DocumentN...", but if it's too big (the file itself may not be very large, it's the memory requirements of all the images that's the source of the problem), Scribus still won't be able to load it, since it will still bump up against the memory problem.

Additional Notes
I have yet to try this on the brand-new Windows version of Scribus. An initial issue will be making sure you have Python on your Windows machine.

If I get some specific questions, I can add notes (or others can add them) about how to modify scribalbum.py and scribalbuma4.py to fit other needs.