Automatic import of images from a directory using a script: Difference between revisions

From Scribus Wiki
Jump to navigation Jump to search
m (Added SCRIPTING index)
(added scribalbum.pl)
Line 42: Line 42:


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.
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.
== scribalbum.pl ==
<pre><nowiki>
#!/usr/bin/perl -w
######################################
#                                    #
#      Program scribalbum.pl        #
#      Created 2004.09.12          #
#      Last modified 2004.09.14    #
#      Gregory Pittman              #
#                                    #
######################################
print "This program will create a picture album as a Scribus .sla file from all the pictures in a directory.\n";
print "Enter the name of the directory:\t";
chomp ($folder =<STDIN>);
opendir (DIR, $folder) || die "Do you have the drive mounted?";
# First we'll eliminate anything starting with a period
@files = grep { !/^\./} readdir(DIR);
# Then sift out the image files; Scribus can show at least some PDFs
# Not having so much luck with SVGs, but at least you'll know they are there
@files = grep { ( /\Z jpeg|jpg|tif|pdf|png|gif|svg/i ) } @files ;
closedir (DIR);
$numfiles = scalar(@files);
$anzpages = int $numfiles/4;
if ($numfiles/4 gt ($anzpages)){
    ++$anzpages;
}
print "There are $numfiles pictures in this directory.\nThis will make $anzpages pages.\n";
print "What do you want to name this album? (\".sla\" will be appended)\t";
chomp ($album =<STDIN>);
$album = "$album.sla";
$utf = "<SCRIBUSUTF8 Version=\"1.2cvs\" >";
# The only variable in $document is $anzpages
$document = " <DOCUMENT MAJGRID=\"100\" ABSTSPALTEN=\"11\" PAGEWITH=\"612\" AUTOCHECK=\"0\" LANGUAGE=\"English\" DPIn2=\"\" DPgam=\"0\" HCMS=\"1\" DGAP=\"0\" ORIENTATION=\"0\" MINWORDLEN=\"3\" VTIEFSC=\"100\" DOCLANGINFO=\"\" COMMENTS=\"\" TITLE=\"\" KEYWORDS=\"\" DSIZE=\"12\" AUTOSPALTEN=\"1\" GROUPC=\"7\" DOCFORMAT=\"\" DOCDATE=\"\" BORDERTOP=\"9\" GUIDELOCK=\"0\" DIMo=\"1\" DIPr=\"0\" DPuse=\"0\" DPSo=\"0\" DOCSOURCE=\"\" FIRSTNUM=\"1\" DPbla=\"1\" VHOCHSC=\"100\" DOCTYPE=\"\" BORDERBOTTOM=\"40\" BASEGRID=\"12\" VTIEF=\"33\" DOCCONTRIB=\"\" DOCRELATION=\"\" BASEO=\"0\" DOCIDENT=\"\" PUBLISHER=\"\" ANZPAGES=\"$anzpages\" HYCOUNT=\"2\" DIMo2=\"1\" AUTHOR=\"\" UNITS=\"0\" BORDERRIGHT=\"9\" DPPr=\"\" DPMo=\"\" PAGEHEIGHT=\"792\" MINGRID=\"20\" VHOCH=\"33\" DOCCOVER=\"\" DCOL=\"1\" AUTOMATIC=\"1\" ALAYER=\"0\" DOCRIGHTS=\"\" DPIn=\"\" VKAPIT=\"75\" DFONT=\"Bitstream Vera Sans Mono Roman\" BORDERLEFT=\"9\" >";
$colorlayer = "  <COLOR RGB=\"\#000000\" CMYK=\"\#000000ff\" NAME=\"Black\" />\n  <COLOR RGB=\"\#ffffff\" CMYK=\"\#00000000\" NAME=\"White\" />\n  <LAYERS DRUCKEN=\"1\" NUMMER=\"0\" NAME=\"Background\" SICHTBAR=\"1\" LEVEL=\"0\" />";
$pdf = "  <PDF ImagePr=\"0\" BTop=\"9\" UseProfiles=\"0\" BLeft=\"9\" PrintP=\"\" RecalcPic=\"0\" ImageP=\"\" SolidP=\"\" PicRes=\"300\" Thumbnails=\"0\" CMethod=\"0\" Encrypt=\"0\" BRight=\"9\" Binding=\"0\" Articles=\"0\" InfoString=\"\" RGBMode=\"1\" PresentMode=\"0\" Permissions=\"-4\" Intent=\"1\" Compress=\"1\" Version=\"14\" Resolution=\"300\" Bookmarks=\"0\" UseProfiles2=\"0\" Quality=\"0\" UseLpi=\"0\" PassUser=\"\" BBottom=\"40\" Intent2=\"1\" PassOwner=\"\" >\n  <LPI Angle=\"45\" Frequency=\"75\" SpotFunction=\"2\" Color=\"Black\" />\n  <LPI Angle=\"105\" Frequency=\"75\" SpotFunction=\"2\" Color=\"Cyan\" />\n  <LPI Angle=\"75\" Frequency=\"75\" SpotFunction=\"2\" Color=\"Magenta\" />\n  <LPI Angle=\"90\" Frequency=\"75\" SpotFunction=\"2\" Color=\"Yellow\" />\n  </PDF>";
# This goes at the end when we're done
$docend = "  <PAGE NUM=\"0\" NAM=\"Normal\" LEFT=\"0\" NumVGuides=\"0\" HorizontalGuides=\"\" MNAM=\"\" NumHGuides=\"0\" VerticalGuides=\"\" />\n </DOCUMENT>\n</SCRIBUSUTF8>\n";
open (FILE, ">$album");
print FILE "$utf\n$document\n$colorlayer\n$pdf\n";
# Now let's build some pages
$pagecount = 0;
$image = 0;
$piccount = 0; # will use this to place each picture on the page
@xpos = qw( 16  310  16  310 ); # $xpos[$piccount] will give this value
@ypos = qw( 14  187  360  533 );# ditto for $ypos
@xpostxt = qw( 16  450  16  450 ); # $xpostxt[$piccount] label for image
@ypostxt = qw( 232  165  578  510 );# ditto for $ypostxt
    @cab = qw( 0 2 0 2 );# alternates left and right justification for image labels
foreach $file (@files) {
    if ($piccount gt 3) {
$piccount = 0;
print FILE "</PAGE>\n";
++$pagecount;
    }
    if ($piccount == 0) {
print FILE "  <PAGE NUM=\"$pagecount\" NAM=\"\" LEFT=\"0\" NumVGuides=\"0\" HorizontalGuides=\"\" MNAM=\"Normal\" NumHGuides=\"0\" VerticalGuides=\"\" >\n";
# This will print the directory name in the upper right hand corner of the page
print FILE "  <PAGEOBJECT BottomLine=\"0\" REXTRA=\"1\" ALIGN=\"2\" LANGUAGE=\"English\" NUMPO=\"16\" PLINEART=\"1\" TXTSCALE=\"100\" RightLine=\"0\" LOCALSCX=\"1\" LINESP=\"12\" ROT=\"0\" TXTSTROKE=\"Black\" WIDTH=\"195\" BACKPAGE=\"-1\" GROUPS=\"\" LOCKR=\"0\" IFONT=\"Luxi Sans Regular\" LOCALSCY=\"1\" NAMEDLST=\"\" AUTOTEXT=\"0\" FLIPPEDV=\"0\" EXTRAV=\"0\" PCOLOR=\"None\" RADRECT=\"0\" REVERS=\"0\" PRINTABLE=\"1\" RATIO=\"1\" FLIPPEDH=\"0\" COLGAP=\"0\" PCOLOR2=\"None\" NEXTITEM=\"-1\" NUMGROUP=\"0\" TransValue=\"0\" INVERS=\"0\" PLINEEND=\"0\" FRTYPE=\"0\" PTYPE=\"4\" isTableItem=\"0\" TEXTFLOW2=\"0\" SHADE2=\"100\" PWIDTH=\"1\" HEIGHT=\"25\" DASHOFF=\"0\" PFILE2=\"\" PFILE=\"\" TEXTFLOW3=\"0\" ISIZE=\"10\" PLTSHOW=\"0\" TXTSTYLE=\"0\" CLIPEDIT=\"0\" BACKITEM=\"-1\" BookNr=\"0\" TransValueS=\"0\" EMBEDDED=\"1\" PFILE3=\"\" ANNAME=\"\" SHADE=\"100\" COCOOR=\"0 0 0 0 195 0 195 0 195 0 195 0 195 25 195 25 195 25 195 25 0 25 0 25 0 25 0 25 0 0 0 0 \" BASEOF=\"0\" PICART=\"1\" COLUMNS=\"1\" LAYER=\"0\" BOOKMARK=\"0\" TopLine=\"0\" LOCK=\"0\" EPROF=\"\" BBOXX=\"0\" DASHS=\"\" IRENDER=\"0\" TEXTFLOW=\"0\" BBOXH=\"0\" TXTFILLSH=\"100\" YPOS=\"11\" ANNOTATION=\"0\" LOCALX=\"0\" GRTYP=\"0\" XPOS=\"400\" NUMCO=\"16\" POCOOR=\"0 0 0 0 195 0 195 0 195 0 195 0 195 25 195 25 195 25 195 25 0 25 0 25 0 25 0 25 0 0 0 0 \" EXTRA=\"1\" LOCALY=\"0\" NEXTPAGE=\"-1\" TABS=\"\" NUMTAB=\"0\" NUMDASH=\"0\" LeftLine=\"0\" PRFILE=\"\" TEXTRA=\"1\" SCALETYPE=\"1\" TXTFILL=\"Black\" BEXTRA=\"1\" PLINEJOIN=\"0\" TXTSTRSH=\"100\" >\n    <ITEXT CAB=\"2\" CCOLOR=\"Black\" CSIZE=\"10\" CH=\"$folder/\" CSHADE2=\"100\" CSCALE=\"100\" CSHADE=\"100\" CSTYLE=\"0\" CFONT=\"Luxi Sans Regular\" CEXTRA=\"0\" CSTROKE=\"Black\" />\n  </PAGEOBJECT>";
    }
# The individual image files
    print FILE "  <PAGEOBJECT BottomLine=\"0\" REXTRA=\"1\" ALIGN=\"0\" LANGUAGE=\"English\" NUMPO=\"16\" PLINEART=\"1\" TXTSCALE=\"100\" RightLine=\"0\" LOCALSCX=\"0.18\" LINESP=\"14.4\" ROT=\"0\" TXTSTROKE=\"Black\" WIDTH=\"288\" BACKPAGE=\"-1\" GROUPS=\"\" LOCKR=\"0\" IFONT=\"Bitstream Vera Sans Mono Roman\" LOCALSCY=\"0.18\" NAMEDLST=\"\" AUTOTEXT=\"0\" FLIPPEDV=\"0\" EXTRAV=\"0\" PCOLOR=\"White\" RADRECT=\"0\" REVERS=\"0\" PRINTABLE=\"1\" RATIO=\"1\" FLIPPEDH=\"0\" COLGAP=\"0\" PCOLOR2=\"None\" NEXTITEM=\"-1\" NUMGROUP=\"0\" TransValue=\"0\" INVERS=\"0\" PLINEEND=\"0\" FRTYPE=\"0\" PTYPE=\"2\" isTableItem=\"0\" TEXTFLOW2=\"0\" SHADE2=\"100\" PWIDTH=\"1\" HEIGHT=\"217\" DASHOFF=\"0\" PFILE2=\"\" PFILE=\"$folder/$file\" TEXTFLOW3=\"0\" ISIZE=\"12\" PLTSHOW=\"0\" TXTSTYLE=\"0\" CLIPEDIT=\"0\" BACKITEM=\"-1\" BookNr=\"0\" TransValueS=\"0\" EMBEDDED=\"1\" PFILE3=\"\" ANNAME=\"Image$image\" SHADE=\"100\" COCOOR=\"0 0 0 0 288 0 288 0 288 0 288 0 288 217 288 217 288 217 288 217 0 217 0 217 0 217 0 217 0 0 0 0 \" BASEOF=\"0\" PICART=\"1\" COLUMNS=\"1\" LAYER=\"0\" BOOKMARK=\"0\" TopLine=\"0\" LOCK=\"0\" EPROF=\"\" BBOXX=\"0\" DASHS=\"\" IRENDER=\"1\" TEXTFLOW=\"0\" BBOXH=\"1200\" TXTFILLSH=\"100\" YPOS=\"$ypos[$piccount]\" ANNOTATION=\"0\" LOCALX=\"0\" GRTYP=\"0\" XPOS=\"$xpos[$piccount]\" NUMCO=\"16\" POCOOR=\"0 0 0 0 288 0 288 0 288 0 288 0 288 217 288 217 288 217 288 217 0 217 0 217 0 217 0 217 0 0 0 0 \" EXTRA=\"1\" LOCALY=\"0\" NEXTPAGE=\"-1\" TABS=\"\" NUMTAB=\"0\" NUMDASH=\"0\" LeftLine=\"0\" PRFILE=\"\" TEXTRA=\"1\" SCALETYPE=\"0\" TXTFILL=\"Black\" BEXTRA=\"1\" PLINEJOIN=\"0\" TXTSTRSH=\"100\" />\n";
# The image file name in a text frame
    print FILE "  <PAGEOBJECT BottomLine=\"0\" REXTRA=\"1\" ALIGN=\"0\" LANGUAGE=\"English\" NUMPO=\"16\" PLINEART=\"1\" TXTSCALE=\"100\" RightLine=\"0\" LOCALSCX=\"1\" LINESP=\"12\" ROT=\"0\" TXTSTROKE=\"Black\" WIDTH=\"148\" BACKPAGE=\"-1\" GROUPS=\"\" LOCKR=\"0\" IFONT=\"Luxi Sans Regular\" LOCALSCY=\"1\" NAMEDLST=\"\" AUTOTEXT=\"0\" FLIPPEDV=\"0\" EXTRAV=\"0\" PCOLOR=\"None\" RADRECT=\"0\" REVERS=\"0\" PRINTABLE=\"1\" RATIO=\"1\" FLIPPEDH=\"0\" COLGAP=\"0\" PCOLOR2=\"None\" NEXTITEM=\"-1\" NUMGROUP=\"0\" TransValue=\"0\" INVERS=\"0\" PLINEEND=\"0\" FRTYPE=\"0\" PTYPE=\"4\" isTableItem=\"0\" TEXTFLOW2=\"0\" SHADE2=\"100\" PWIDTH=\"1\" HEIGHT=\"22\" DASHOFF=\"0\" PFILE2=\"\" PFILE=\"\" TEXTFLOW3=\"0\" ISIZE=\"10\" PLTSHOW=\"0\" TXTSTYLE=\"0\" CLIPEDIT=\"0\" BACKITEM=\"-1\" BookNr=\"0\" TransValueS=\"0\" EMBEDDED=\"1\" PFILE3=\"\" ANNAME=\"\" SHADE=\"100\" COCOOR=\"0 0 0 0 148 0 148 0 148 0 148 0 148 22 148 22 148 22 148 22 0 22 0 22 0 22 0 22 0 0 0 0 \" BASEOF=\"0\" PICART=\"1\" COLUMNS=\"1\" LAYER=\"0\" BOOKMARK=\"0\" TopLine=\"0\" LOCK=\"0\" EPROF=\"\" BBOXX=\"0\" DASHS=\"\" IRENDER=\"-279058628\" TEXTFLOW=\"0\" BBOXH=\"0\" TXTFILLSH=\"100\" YPOS=\"$ypostxt[$piccount]\" ANNOTATION=\"0\" LOCALX=\"0\" GRTYP=\"0\" XPOS=\"$xpostxt[$piccount]\" NUMCO=\"16\" POCOOR=\"0 0 0 0 148 0 148 0 148 0 148 0 148 22 148 22 148 22 148 22 0 22 0 22 0 22 0 22 0 0 0 0 \" EXTRA=\"1\" LOCALY=\"0\" NEXTPAGE=\"-1\" TABS=\"\" NUMTAB=\"0\" NUMDASH=\"0\" LeftLine=\"0\" PRFILE=\"\" TEXTRA=\"1\" SCALETYPE=\"1\" TXTFILL=\"Black\" BEXTRA=\"1\" PLINEJOIN=\"0\" TXTSTRSH=\"100\" >\n    <ITEXT CAB=\"$cab[$piccount]\" CCOLOR=\"Black\" CSIZE=\"10\" CH=\"$file\" CSHADE2=\"100\" CSCALE=\"100\" CSHADE=\"100\" CSTYLE=\"0\" CFONT=\"Luxi Sans Regular\" CEXTRA=\"0\" CSTROKE=\"Black\" />\n  </PAGEOBJECT>\n ";
    ++$piccount;
    ++$image;
}
# All the pics should be in now...finish up
print FILE "</PAGE>\n";
print FILE "$docend\n";
close (FILE);
print "All finished printing to $album\n";
</pre></nowiki></pre>

Revision as of 19:18, 28 January 2006

This article is part of the Scripts series.

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.


scribalbum.pl

<nowiki>
#!/usr/bin/perl -w
######################################
#                                    #
#       Program scribalbum.pl        #
#       Created 2004.09.12           #
#       Last modified 2004.09.14     #
#       Gregory Pittman              #
#                                    #
######################################
print "This program will create a picture album as a Scribus .sla file from all the pictures in a directory.\n";
print "Enter the name of the directory:\t";
chomp ($folder =<STDIN>);
opendir (DIR, $folder) || die "Do you have the drive mounted?";
# First we'll eliminate anything starting with a period
@files = grep { !/^\./} readdir(DIR);
# Then sift out the image files; Scribus can show at least some PDFs
# Not having so much luck with SVGs, but at least you'll know they are there
@files = grep { ( /\Z jpeg|jpg|tif|pdf|png|gif|svg/i ) } @files ;
closedir (DIR);

$numfiles = scalar(@files);
$anzpages = int $numfiles/4;
if ($numfiles/4 gt ($anzpages)){
    ++$anzpages;
}
print "There are $numfiles pictures in this directory.\nThis will make $anzpages pages.\n";
print "What do you want to name this album? (\".sla\" will be appended)\t";
chomp ($album =<STDIN>);
$album = "$album.sla";

$utf = "<SCRIBUSUTF8 Version=\"1.2cvs\" >";
# The only variable in $document is $anzpages
$document = " <DOCUMENT MAJGRID=\"100\" ABSTSPALTEN=\"11\" PAGEWITH=\"612\" AUTOCHECK=\"0\" LANGUAGE=\"English\" DPIn2=\"\" DPgam=\"0\" HCMS=\"1\" DGAP=\"0\" ORIENTATION=\"0\" MINWORDLEN=\"3\" VTIEFSC=\"100\" DOCLANGINFO=\"\" COMMENTS=\"\" TITLE=\"\" KEYWORDS=\"\" DSIZE=\"12\" AUTOSPALTEN=\"1\" GROUPC=\"7\" DOCFORMAT=\"\" DOCDATE=\"\" BORDERTOP=\"9\" GUIDELOCK=\"0\" DIMo=\"1\" DIPr=\"0\" DPuse=\"0\" DPSo=\"0\" DOCSOURCE=\"\" FIRSTNUM=\"1\" DPbla=\"1\" VHOCHSC=\"100\" DOCTYPE=\"\" BORDERBOTTOM=\"40\" BASEGRID=\"12\" VTIEF=\"33\" DOCCONTRIB=\"\" DOCRELATION=\"\" BASEO=\"0\" DOCIDENT=\"\" PUBLISHER=\"\" ANZPAGES=\"$anzpages\" HYCOUNT=\"2\" DIMo2=\"1\" AUTHOR=\"\" UNITS=\"0\" BORDERRIGHT=\"9\" DPPr=\"\" DPMo=\"\" PAGEHEIGHT=\"792\" MINGRID=\"20\" VHOCH=\"33\" DOCCOVER=\"\" DCOL=\"1\" AUTOMATIC=\"1\" ALAYER=\"0\" DOCRIGHTS=\"\" DPIn=\"\" VKAPIT=\"75\" DFONT=\"Bitstream Vera Sans Mono Roman\" BORDERLEFT=\"9\" >";

$colorlayer = "  <COLOR RGB=\"\#000000\" CMYK=\"\#000000ff\" NAME=\"Black\" />\n  <COLOR RGB=\"\#ffffff\" CMYK=\"\#00000000\" NAME=\"White\" />\n  <LAYERS DRUCKEN=\"1\" NUMMER=\"0\" NAME=\"Background\" SICHTBAR=\"1\" LEVEL=\"0\" />";

$pdf = "  <PDF ImagePr=\"0\" BTop=\"9\" UseProfiles=\"0\" BLeft=\"9\" PrintP=\"\" RecalcPic=\"0\" ImageP=\"\" SolidP=\"\" PicRes=\"300\" Thumbnails=\"0\" CMethod=\"0\" Encrypt=\"0\" BRight=\"9\" Binding=\"0\" Articles=\"0\" InfoString=\"\" RGBMode=\"1\" PresentMode=\"0\" Permissions=\"-4\" Intent=\"1\" Compress=\"1\" Version=\"14\" Resolution=\"300\" Bookmarks=\"0\" UseProfiles2=\"0\" Quality=\"0\" UseLpi=\"0\" PassUser=\"\" BBottom=\"40\" Intent2=\"1\" PassOwner=\"\" >\n   <LPI Angle=\"45\" Frequency=\"75\" SpotFunction=\"2\" Color=\"Black\" />\n   <LPI Angle=\"105\" Frequency=\"75\" SpotFunction=\"2\" Color=\"Cyan\" />\n   <LPI Angle=\"75\" Frequency=\"75\" SpotFunction=\"2\" Color=\"Magenta\" />\n   <LPI Angle=\"90\" Frequency=\"75\" SpotFunction=\"2\" Color=\"Yellow\" />\n  </PDF>";

# This goes at the end when we're done
$docend = "  <PAGE NUM=\"0\" NAM=\"Normal\" LEFT=\"0\" NumVGuides=\"0\" HorizontalGuides=\"\" MNAM=\"\" NumHGuides=\"0\" VerticalGuides=\"\" />\n </DOCUMENT>\n</SCRIBUSUTF8>\n";
open (FILE, ">$album");
print FILE "$utf\n$document\n$colorlayer\n$pdf\n";

# Now let's build some pages
$pagecount = 0;
$image = 0;
$piccount = 0; # will use this to place each picture on the page
@xpos = qw( 16  310  16  310 ); # $xpos[$piccount] will give this value
@ypos = qw( 14  187  360  533 );# ditto for $ypos
@xpostxt = qw( 16  450  16  450 ); # $xpostxt[$piccount] label for image
@ypostxt = qw( 232  165  578  510 );# ditto for $ypostxt
    @cab = qw( 0 2 0 2 );# alternates left and right justification for image labels
foreach $file (@files) {
    if ($piccount gt 3) {
	$piccount = 0;
	print FILE "</PAGE>\n";
	++$pagecount;
    }
    if ($piccount == 0) {
	print FILE "  <PAGE NUM=\"$pagecount\" NAM=\"\" LEFT=\"0\" NumVGuides=\"0\" HorizontalGuides=\"\" MNAM=\"Normal\" NumHGuides=\"0\" VerticalGuides=\"\" >\n";
# This will print the directory name in the upper right hand corner of the page
print FILE "   <PAGEOBJECT BottomLine=\"0\" REXTRA=\"1\" ALIGN=\"2\" LANGUAGE=\"English\" NUMPO=\"16\" PLINEART=\"1\" TXTSCALE=\"100\" RightLine=\"0\" LOCALSCX=\"1\" LINESP=\"12\" ROT=\"0\" TXTSTROKE=\"Black\" WIDTH=\"195\" BACKPAGE=\"-1\" GROUPS=\"\" LOCKR=\"0\" IFONT=\"Luxi Sans Regular\" LOCALSCY=\"1\" NAMEDLST=\"\" AUTOTEXT=\"0\" FLIPPEDV=\"0\" EXTRAV=\"0\" PCOLOR=\"None\" RADRECT=\"0\" REVERS=\"0\" PRINTABLE=\"1\" RATIO=\"1\" FLIPPEDH=\"0\" COLGAP=\"0\" PCOLOR2=\"None\" NEXTITEM=\"-1\" NUMGROUP=\"0\" TransValue=\"0\" INVERS=\"0\" PLINEEND=\"0\" FRTYPE=\"0\" PTYPE=\"4\" isTableItem=\"0\" TEXTFLOW2=\"0\" SHADE2=\"100\" PWIDTH=\"1\" HEIGHT=\"25\" DASHOFF=\"0\" PFILE2=\"\" PFILE=\"\" TEXTFLOW3=\"0\" ISIZE=\"10\" PLTSHOW=\"0\" TXTSTYLE=\"0\" CLIPEDIT=\"0\" BACKITEM=\"-1\" BookNr=\"0\" TransValueS=\"0\" EMBEDDED=\"1\" PFILE3=\"\" ANNAME=\"\" SHADE=\"100\" COCOOR=\"0 0 0 0 195 0 195 0 195 0 195 0 195 25 195 25 195 25 195 25 0 25 0 25 0 25 0 25 0 0 0 0 \" BASEOF=\"0\" PICART=\"1\" COLUMNS=\"1\" LAYER=\"0\" BOOKMARK=\"0\" TopLine=\"0\" LOCK=\"0\" EPROF=\"\" BBOXX=\"0\" DASHS=\"\" IRENDER=\"0\" TEXTFLOW=\"0\" BBOXH=\"0\" TXTFILLSH=\"100\" YPOS=\"11\" ANNOTATION=\"0\" LOCALX=\"0\" GRTYP=\"0\" XPOS=\"400\" NUMCO=\"16\" POCOOR=\"0 0 0 0 195 0 195 0 195 0 195 0 195 25 195 25 195 25 195 25 0 25 0 25 0 25 0 25 0 0 0 0 \" EXTRA=\"1\" LOCALY=\"0\" NEXTPAGE=\"-1\" TABS=\"\" NUMTAB=\"0\" NUMDASH=\"0\" LeftLine=\"0\" PRFILE=\"\" TEXTRA=\"1\" SCALETYPE=\"1\" TXTFILL=\"Black\" BEXTRA=\"1\" PLINEJOIN=\"0\" TXTSTRSH=\"100\" >\n    <ITEXT CAB=\"2\" CCOLOR=\"Black\" CSIZE=\"10\" CH=\"$folder/\" CSHADE2=\"100\" CSCALE=\"100\" CSHADE=\"100\" CSTYLE=\"0\" CFONT=\"Luxi Sans Regular\" CEXTRA=\"0\" CSTROKE=\"Black\" />\n   </PAGEOBJECT>";
    }
# The individual image files
    print FILE "   <PAGEOBJECT BottomLine=\"0\" REXTRA=\"1\" ALIGN=\"0\" LANGUAGE=\"English\" NUMPO=\"16\" PLINEART=\"1\" TXTSCALE=\"100\" RightLine=\"0\" LOCALSCX=\"0.18\" LINESP=\"14.4\" ROT=\"0\" TXTSTROKE=\"Black\" WIDTH=\"288\" BACKPAGE=\"-1\" GROUPS=\"\" LOCKR=\"0\" IFONT=\"Bitstream Vera Sans Mono Roman\" LOCALSCY=\"0.18\" NAMEDLST=\"\" AUTOTEXT=\"0\" FLIPPEDV=\"0\" EXTRAV=\"0\" PCOLOR=\"White\" RADRECT=\"0\" REVERS=\"0\" PRINTABLE=\"1\" RATIO=\"1\" FLIPPEDH=\"0\" COLGAP=\"0\" PCOLOR2=\"None\" NEXTITEM=\"-1\" NUMGROUP=\"0\" TransValue=\"0\" INVERS=\"0\" PLINEEND=\"0\" FRTYPE=\"0\" PTYPE=\"2\" isTableItem=\"0\" TEXTFLOW2=\"0\" SHADE2=\"100\" PWIDTH=\"1\" HEIGHT=\"217\" DASHOFF=\"0\" PFILE2=\"\" PFILE=\"$folder/$file\" TEXTFLOW3=\"0\" ISIZE=\"12\" PLTSHOW=\"0\" TXTSTYLE=\"0\" CLIPEDIT=\"0\" BACKITEM=\"-1\" BookNr=\"0\" TransValueS=\"0\" EMBEDDED=\"1\" PFILE3=\"\" ANNAME=\"Image$image\" SHADE=\"100\" COCOOR=\"0 0 0 0 288 0 288 0 288 0 288 0 288 217 288 217 288 217 288 217 0 217 0 217 0 217 0 217 0 0 0 0 \" BASEOF=\"0\" PICART=\"1\" COLUMNS=\"1\" LAYER=\"0\" BOOKMARK=\"0\" TopLine=\"0\" LOCK=\"0\" EPROF=\"\" BBOXX=\"0\" DASHS=\"\" IRENDER=\"1\" TEXTFLOW=\"0\" BBOXH=\"1200\" TXTFILLSH=\"100\" YPOS=\"$ypos[$piccount]\" ANNOTATION=\"0\" LOCALX=\"0\" GRTYP=\"0\" XPOS=\"$xpos[$piccount]\" NUMCO=\"16\" POCOOR=\"0 0 0 0 288 0 288 0 288 0 288 0 288 217 288 217 288 217 288 217 0 217 0 217 0 217 0 217 0 0 0 0 \" EXTRA=\"1\" LOCALY=\"0\" NEXTPAGE=\"-1\" TABS=\"\" NUMTAB=\"0\" NUMDASH=\"0\" LeftLine=\"0\" PRFILE=\"\" TEXTRA=\"1\" SCALETYPE=\"0\" TXTFILL=\"Black\" BEXTRA=\"1\" PLINEJOIN=\"0\" TXTSTRSH=\"100\" />\n";
# The image file name in a text frame
    print FILE "   <PAGEOBJECT BottomLine=\"0\" REXTRA=\"1\" ALIGN=\"0\" LANGUAGE=\"English\" NUMPO=\"16\" PLINEART=\"1\" TXTSCALE=\"100\" RightLine=\"0\" LOCALSCX=\"1\" LINESP=\"12\" ROT=\"0\" TXTSTROKE=\"Black\" WIDTH=\"148\" BACKPAGE=\"-1\" GROUPS=\"\" LOCKR=\"0\" IFONT=\"Luxi Sans Regular\" LOCALSCY=\"1\" NAMEDLST=\"\" AUTOTEXT=\"0\" FLIPPEDV=\"0\" EXTRAV=\"0\" PCOLOR=\"None\" RADRECT=\"0\" REVERS=\"0\" PRINTABLE=\"1\" RATIO=\"1\" FLIPPEDH=\"0\" COLGAP=\"0\" PCOLOR2=\"None\" NEXTITEM=\"-1\" NUMGROUP=\"0\" TransValue=\"0\" INVERS=\"0\" PLINEEND=\"0\" FRTYPE=\"0\" PTYPE=\"4\" isTableItem=\"0\" TEXTFLOW2=\"0\" SHADE2=\"100\" PWIDTH=\"1\" HEIGHT=\"22\" DASHOFF=\"0\" PFILE2=\"\" PFILE=\"\" TEXTFLOW3=\"0\" ISIZE=\"10\" PLTSHOW=\"0\" TXTSTYLE=\"0\" CLIPEDIT=\"0\" BACKITEM=\"-1\" BookNr=\"0\" TransValueS=\"0\" EMBEDDED=\"1\" PFILE3=\"\" ANNAME=\"\" SHADE=\"100\" COCOOR=\"0 0 0 0 148 0 148 0 148 0 148 0 148 22 148 22 148 22 148 22 0 22 0 22 0 22 0 22 0 0 0 0 \" BASEOF=\"0\" PICART=\"1\" COLUMNS=\"1\" LAYER=\"0\" BOOKMARK=\"0\" TopLine=\"0\" LOCK=\"0\" EPROF=\"\" BBOXX=\"0\" DASHS=\"\" IRENDER=\"-279058628\" TEXTFLOW=\"0\" BBOXH=\"0\" TXTFILLSH=\"100\" YPOS=\"$ypostxt[$piccount]\" ANNOTATION=\"0\" LOCALX=\"0\" GRTYP=\"0\" XPOS=\"$xpostxt[$piccount]\" NUMCO=\"16\" POCOOR=\"0 0 0 0 148 0 148 0 148 0 148 0 148 22 148 22 148 22 148 22 0 22 0 22 0 22 0 22 0 0 0 0 \" EXTRA=\"1\" LOCALY=\"0\" NEXTPAGE=\"-1\" TABS=\"\" NUMTAB=\"0\" NUMDASH=\"0\" LeftLine=\"0\" PRFILE=\"\" TEXTRA=\"1\" SCALETYPE=\"1\" TXTFILL=\"Black\" BEXTRA=\"1\" PLINEJOIN=\"0\" TXTSTRSH=\"100\" >\n    <ITEXT CAB=\"$cab[$piccount]\" CCOLOR=\"Black\" CSIZE=\"10\" CH=\"$file\" CSHADE2=\"100\" CSCALE=\"100\" CSHADE=\"100\" CSTYLE=\"0\" CFONT=\"Luxi Sans Regular\" CEXTRA=\"0\" CSTROKE=\"Black\" />\n   </PAGEOBJECT>\n ";
    ++$piccount;
    ++$image;
}
# All the pics should be in now...finish up
print FILE "</PAGE>\n";
print FILE "$docend\n";
close (FILE);
print "All finished printing to $album\n";

</nowiki>