|
The Upload-Cam Perl script is a simple Perl script I wrote for uploading a webcam image file from my PC to my web site.
I use it for uploading images for the mobile cam.
Basically, what it does is create a thumbnail from a given image and upload (ftp) the original image and the new thumbnail to my web site.
The script uses two Perl modules:
- Image::Magick (for creating the thumbnail)
- Net::FTP (for uploading the files to my web server)
If you have Perl installed Net::FTP should already be installed.
To install Image::Magick
You can find the installation instructions in the module documentation.
Now that you've installed the needed Perl modules you need to configure the script a bit.
Download Upload-Cam script
Unzip the file you downloaded, open the Perl script in a text editor, and make the following configurations:
#the host name of the ftp server
my $ftp_server="ftp.yourserver.com";
my $login="root";#your login
#the remote directory to upload the file to
my $upload_to_dir="/www";
# This is the name of the uploaded image file.
# It will be replaced every time you upload an image
# (that way you can just add something like
# <img src="http://yourserver.com/mobile_cam.jpg">
# and your web site will always show the current image)
# If you want the name of the uploaded file to be
# the same as the name of the original file then
# just leave this blank (="";)
my $new_file_name="mobile_cam.jpg";
#the size of the large side of the thumbnail we create
my $thumbnail_size='120';
# This is the optional name of the thumbnail
# that is created. If you leave it blank the thumbnail
# will have the same name as the original
# image only with a "tn_" prefix.
my $thumbnail_name="";
That's it for the configurations!
Let's see how we use the script
It's pretty simple, all you need to do is type:
perl upload_cam_image.pl PATH_TO_IMAGE_TO_UPLOAD
I'll show you a real example:
perl upload_cam_image.pl an_image.jpg
or
perl upload_cam_image.pl c:\my_image.jpg
or
perl upload_cam_image.pl "c:\A folder\an_image.jpg"
It's that easy!
If you have any questions, requests, found something unclear, or just found the Upload-Cam script useful: .
|
|