Author Topic: Post Upload Processing  (Read 14051 times)

0 Members and 2 Guests are viewing this topic.

Offline Mike Bobbitt

  • album.pl Author
  • Administrator
  • I Spend Too Much Time Here
  • *****
  • Posts: 3381
  • Karma: +35/-2
    • Mike's Development Archive
Post Upload Processing
« on: March 01, 2003, 20:51:22 »
New in 6.2:

You can configure a command to be run after a successful upload. This feature is designed to allow you to run an additional ImageMagick command on all uploaded files, but could be used to make copies, send e-mail, etc.

Any ####OBJECT#### tags will be replaced with the full path/filename of the photo uploaded. ImageMagick output (I.E. the modified image) will be stored in a temp file, and copied over the original upload if the command was successful. If undefined, no action is taken.

An example is helpful here. The following line puts "album.pl" in the upper left corner of each picture on upload. (Note: You needs FreeType installed with ImageMagick for this to work on your system)

postupload=convert -font Courier -fill red -draw 'rotate 270 text -60,10 "album.pl"' ####OBJECT####

There are a variety of other uses for this feature as well, so be creative!

Cheers

Offline Dino

  • album.pl Donor
  • I Spend Too Much Time Here
  • *****
  • Posts: 250
  • Karma: +5/-0
  • That's actually my childhood cookie jar!
    • Dino's Bulletin Board
Re:Post Upload Processing
« Reply #1 on: March 08, 2003, 01:38:38 »
I need more data on this... what specifically are you using this for? Sounds intriguing.

"He who seeks the truth must doubt everything."Aristotle
"Extraordinary claims require extraordinary proof."Sagan

Offline Dino

  • album.pl Donor
  • I Spend Too Much Time Here
  • *****
  • Posts: 250
  • Karma: +5/-0
  • That's actually my childhood cookie jar!
    • Dino's Bulletin Board
Re:Post Upload Processing
« Reply #2 on: March 08, 2003, 01:40:31 »
Oh... duh...

You're putting a "watermark" on each picture that gets uploaded! Very clever, and VERY useful.

Need more info on freetype.

"He who seeks the truth must doubt everything."Aristotle
"Extraordinary claims require extraordinary proof."Sagan

Offline Mike Bobbitt

  • album.pl Author
  • Administrator
  • I Spend Too Much Time Here
  • *****
  • Posts: 3381
  • Karma: +35/-2
    • Mike's Development Archive
Re:Post Upload Processing
« Reply #3 on: March 08, 2003, 08:50:21 »
Freetype is here:

http://www.freetype.org/

But you don't have to use this feature for watermarking, you can use it to rotate pics, crop, add a frame, etc. Anything that ImageMagick can do. In fact, you can probably run *any* command post upload, so you could back up the "original" somewhere and just put the backup into the album.

Although it's untested, you *should* be able to process multiple commands by separating them with a semi-colon...

Offline sysop69

  • album.pl Donor
  • album.pl Tester
  • **
  • Posts: 44
  • Karma: +0/-0
Re:Post Upload Processing
« Reply #4 on: March 27, 2003, 02:46:58 »
Say Mike,
     If I wanted to send an e-mail with the address that are in my notify.txt file using the after -processing command, how would I go about doing that?  Or could you point me in the right direction?  Thanks

Offline Mike Bobbitt

  • album.pl Author
  • Administrator
  • I Spend Too Much Time Here
  • *****
  • Posts: 3381
  • Karma: +35/-2
    • Mike's Development Archive
Re:Post Upload Processing
« Reply #5 on: March 27, 2003, 10:05:57 »
Hmmm. Could be tricky...

Maybe something like:

postupload=/usr/sbin/sendmail -t `cat [path to]notify.txt`

Actually on second thought, the easiest thing to do is to write a small Perl script that takes the photo name as an argument, and mails a link to that pic to all the addresses in notify.txt. Then just have postupload call that script: postupload=sysopscript ####OBJECT####

Probably needs fine tuning, but the idea would work...

Offline sysop69

  • album.pl Donor
  • album.pl Tester
  • **
  • Posts: 44
  • Karma: +0/-0
Re:Post Upload Processing
« Reply #6 on: March 28, 2003, 01:36:45 »
I have created that script for the e-mail and now I am able to send an e-mail to all the people in my notify  list once I am done uploading.  Never again will I have to worry about sending an e-mail.  It's done automatically.  Thanks for your help and for an awesome script.  If you or anyone else wants me to send you what I have done, let me know.

Offline Mike Bobbitt

  • album.pl Author
  • Administrator
  • I Spend Too Much Time Here
  • *****
  • Posts: 3381
  • Karma: +35/-2
    • Mike's Development Archive
Re:Post Upload Processing
« Reply #7 on: March 28, 2003, 07:49:40 »
Excellent work! And yeah, please do share, I'm sure people will want to make use of your efforts!

You know, I never even thought about something like this when I added postupload. Very cool.

Offline sysop69

  • album.pl Donor
  • album.pl Tester
  • **
  • Posts: 44
  • Karma: +0/-0
Re:Post Upload Processing
« Reply #8 on: March 28, 2003, 07:58:06 »
You want me to post it here? or e-mail it to you?

Offline Mike Bobbitt

  • album.pl Author
  • Administrator
  • I Spend Too Much Time Here
  • *****
  • Posts: 3381
  • Karma: +35/-2
    • Mike's Development Archive
Re:Post Upload Processing
« Reply #9 on: March 28, 2003, 09:54:42 »
Post it here, that way it'll be saved for posterity... :)

Thanks!

Offline sysop69

  • album.pl Donor
  • album.pl Tester
  • **
  • Posts: 44
  • Karma: +0/-0
Re:Post Upload Processing
« Reply #10 on: March 28, 2003, 16:12:28 »
Here is the first file and second file.  Documentation of this file is at http://tech.irt.org/articles/js124/

Being a newbie perl programmer, I didn't have to know much to use this.  So I typed it up and it works everytime there is an upload as long as you reference it in the post proceesing part of the album.cfg file.  This is the first file.  The other two are your notify file, which holds the e-mail address.  The third file is a message.  I chose to do a third file for programming benefits.  For instance, if I change the message, I don't have to worry about going into the script and changing that and possible messing it up.  So here ya go.

********************I named this send.pl but you can name it anything, just know where you put it.

open(EMAIL, "/home/www/albums/notify.txt") or die "cannot open email: $!";
flock(EMAIL, 2) or die "cannot locl email for exclusive access: $!";
open(MESSAGE, "/home/www/albums/msg.txt") or die "cannot open message: $!";
flock(MESSAGE, 2) or die "cannot lock message exclusively: $!";
my @msgfile = <MESSAGE>;  # read it into @msgfile
close (MESSAGE) or die "cannot close message file: $!";
my @email_list = <EMAIL>;
close (EMAIL) or die "cannot close email list: $!";

foreach $address (@email_list)
{
   chomp($address);
   open (SENDMAIL, "|sendmail -t") or die "cannot open sendmail: $!";
   print SENDMAIL "To: $address\n";
   print SENDMAIL "From: Your Name <user\@yourdomain.com>\n";

   print SENDMAIL "Subject: New Pictures Have Been Uploaded!!\n\n";


   print SENDMAIL @msgfile;
}



*************************************I named this one msg.txt but again name it whatever you feel like


Hello Everyone,

   Just wanted to let everyone know that new pictures have been added to the web site.  Check them out at http://www.yoursite.com.  For your convenience, here is the link to the recent uploads page: http://www.yoursite.com/cgi-bin/album.pl?album=:recent.  We hope you all enjoy the pictures.

Love,

Your Name

Offline Mike Bobbitt

  • album.pl Author
  • Administrator
  • I Spend Too Much Time Here
  • *****
  • Posts: 3381
  • Karma: +35/-2
    • Mike's Development Archive
Re:Post Upload Processing
« Reply #11 on: March 28, 2003, 16:38:52 »
Well done!!!

 ;D

Offline sysop69

  • album.pl Donor
  • album.pl Tester
  • **
  • Posts: 44
  • Karma: +0/-0
Re:Post Upload Processing
« Reply #12 on: April 06, 2003, 11:07:07 »
Got one issue with this new script and post upload processing.  I neglected to remember that this was post upload processing for each photo, not the group of photos.  So I uploaded 66 pictures, and oops, I sent out 66 e-mails.  hahahaha.  Is there anyway to incorporate that script so if can be done after ALL photos are done uploading?  Thanks.

P.S.  It's no big deal, I can just run the script after I upload.

Offline Mike Bobbitt

  • album.pl Author
  • Administrator
  • I Spend Too Much Time Here
  • *****
  • Posts: 3381
  • Karma: +35/-2
    • Mike's Development Archive
Re:Post Upload Processing
« Reply #13 on: April 06, 2003, 13:27:17 »
Heheh. Ooops. :)

Right now it just runs after each upload, and would require code changes to run after each "batch".  I may be able to add that as a feature some time though...

Cheers

Offline Karen

  • album.pl User
  • *
  • Posts: 1
  • Karma: +0/-0
Re:Post Upload Processing
« Reply #14 on: June 27, 2003, 15:27:00 »
I wrote an email notify sub that runs after uploadPhoto();  It does not send out an email with each and every photo, but it DOES send the email twice. Any idea why I might be getting duplicate emails?