Announce: galleryscr.pl 2.00

iainlea

Joined: 2004-09-24
Posts: 10
Posted: Tue, 2005-04-12 10:32

A perl script to output images from a Gallery or local directory structure.

Background:
I wanted to have the screensaver on my windows and unix systems use the images from my Gallery. Simply setup your screensaver to read the images from a directory and have this run with '... -m 2 -f 2 ...' and you will be all set for a random new image to be written to gallery.jpg or run with '... -m 3 ...' and a random new image will be written to a collage image named collage.jpg.

You can download it here: http://iainlea.dyndns.org/software/galleryscr/

Usage: galleryscr.pl [options] [file(s) | dir(s)]
       -a album  album from which to download images (default: all)  
       -B        convert images to black & white in -m 3 collage mode
       -C color  background color in -m 3 collage mode (default: 1)
       -d dir    directory of local gallery containing images
       -e text   exclude directories and/or images matching pattern
       -f mode   1=as-is 2=gallery.ext 3=gal%05d.ext (default: 1)
       -g url    URL of gallery (default: $gallery_location)
       -i text   include directories and/or images matching pattern
       -l        list available albums for specified gallery      
       -m mode   1=sequential  2=random  3=collage (default: 1)   
       -M file   imagemap base filename (TBI) (default: ./collage)
       -n num    output number of images and then exit
       -o dir    output images to this directory (default: .)
       -p pass   password to use to login to gallery
       -q        quiet mode (unless errors are encountered)
       -s secs   seconds to sleep before fetching next image (default: 15)
       -S size   image size in -m 3 collage mode (default: 1024x768) 
       -u user   username to use to login to gallery (default: admin)
       -z        zap all image files that were output during session
       -h        help   
       -v        verbose

Examples:
  galleryscr.pl -g http://gallery -p secret123 -m 2 -f 2 -s 30

    download images randomly every 30 secs to gallery.ext (screensaver)

  galleryscr.pl -g http://gallery -u admin -p secret123 -a mycars

    download images in sequential mode from album cars

  galleryscr.pl -d /www/gallery -m 3 -e ".*" -i "kawazaki"

    copy images from /www/gallery/*kawazaki* and create a collage image

Note: $GALLERY_[DIR|URL|USER|PASS|ALBUM|OUTDIR|LOG] variables are settable

Changelog:

- added gallerycol.sh script to download, create collage and upload it
- added -m 3 collage mode option that creates random collage of images
- added -n output number of image and then exit option
- added -z zap output file option to scrub+remove all downloaded files
- added -B convert to grayscale option with -m 3 collage mode
- added -C background color for base image with -m 3 collage mode
- added -S 1024x768 image size option with -m 3 collage mode 
- added $GALLERY_OUTDIR env variable to be able to set -o outdir option
- changed &PrintErr function to work better with -q quiet option
- fixed dumb error in recursive parsing of -d directory option 

Here is an example run that downloads images and creates a collage image:

$ galleryscr.pl -g gallery.mysite.com -u admin -p mypass -m 3

System  gallery.mysite.com
Login:  admin  [OK]
Album:  fetching list  [OK]
Check:  kids  [OK] 
Check:  xmas2003  [OK]
Check:  xmas2004  [OK]
Album:  kids - fetching images  [OK]
Album:  xmas2003 - fetching images  [OK]
Album:  xmas2004 - fetching images  [OK]
ImageAdd  http://gallery.mysite.com/albums/kids/pic1.jpg  [OK]
ImageAdd  http://gallery.mysite.com/albums/kids/pic1.sized.jpg  [IGNORED]
ImageAdd  http://gallery.mysite.com/albums/kids/pic1.thumb.jpg  [IGNORED]
ImageAdd  http://gallery.mysite.com/albums/xmas2003/tree.jpg  [OK]
ImageAdd  http://gallery.mysite.com/albums/xmas2003/tree.sized.jpg [IGNORED]
ImageAdd  http://gallery.mysite.com/albums/xmas2003/tree.thumb.jpg [IGNORED]
...
ImagePpm  /usr/bin/ppmmake 'black' 1024 768 > '/tmp/09059ppm.ppm'
ImageSrc  http://gallery.mysite.com/albums/kids/20010608_001.jpg  [OK]
ImgToPnm  | /usr/bin/djpeg > '/tmp/09059pn1.pnm'  (1200x1600)  [OK]
ImgPaste  | pnmscale -xsize 300 -ysize 400  (scale 0.25)
ImgPaste  | pnmcut 0 55 300 345  (crop 300x345 @ 0,55) (300x400 @ 701,-55)
ImgPaste  | pnmpaste - 701 0 '/tmp/09059ppm.ppm'  (300x345 @ 701,0)
ImgPaste  cjpeg -optimize -quality 85 '/tmp/09059pn2.pnm' > '/tmp/09059jpg.jpg'
ImageDst  /tmp/collage.jpg  [OK]
Sleeping  15
ImageSrc  http://gallery.mysite.com/albums/kids/20010608_031.jpg  [OK]
ImgToPnm  | /usr/bin/djpeg > '/tmp/09059pn1.pnm'  (1600x1200)  [OK]
ImgPaste  | pnmscale -xsize 400 -ysize 300  (scale 0.25)
ImgPaste  | pnmcut 0 178 400 122  (crop 400x122 @ 0,178) (400x300 @ 471,-178)
ImgPaste  | pnmpaste - 471 0 '/tmp/09059ppm.ppm'  (400x122 @ 471,0)
ImgPaste  cjpeg -optimize -quality 85 '/tmp/09059pn2.pnm' > '/tmp/09059jpg.jpg'
ImageDst  /tmp/collage.jpg  [OK]
Sleeping  15
...
   

Enjoy. Feedback and patches welcome.

Iain

AttachmentSize
collage.jpg100.8 KB