You are not logged in.
#1 2004-07-22 03:59:48
- Guest
- Guest
Technique for batch resize/compress and upload from Windows
I was interested to see in the release anouncement for version 0.9.9 that the batch upload via zip files method had been implemented. I also needed a way to easily upload a bunch of files at once that was simple, integrated with Windows and was of such a nature that anyone familiar with Windows, but not necessarily with FTP or the web could use it. I also wanted to have a way to automatically resize and compress the images before they were uploaded.
My solution makes use of two free programs, NcFTP and ImageMagick and a simple batch file. The batch file prompts the user for the new gallery name, copies the targeted files to a temporary directory, resizes and compresses them (if necessary) and then uploads them to the website, creating the gallery directory if it doesn't already exist.
Save the batch file somewhere (I suggest in c:bin) and then create a shortcut to the batch file in your 'Documents and Settings<user id>SendTo' folder. Then, you can just select the images you want in Explorer, right click and select 'Send To -> WhateverYouNamedTheScriptShortcut'
This script is sort of specific to the way I have my domain laid out, but I hope it gives some ideas to people.
Ciao
Chad
Code:
@echo off rem ******************************************************************* rem This script will take a set of image files and publish them to rem a Singapore image gallery. Publishing involves copying the rem files to a temporary workspace, then using the ImageMagik rem convert utility to resize and compress them. After that, we rem use the ncftpput command line utility to create the new new rem sub-galery and post the images. rem rem This script relies on NcFTP and ImageMagik to get it's job done rem ImageMagik: http://www.imagemagick.org rem NcFTP: http://www.ncftp.com/ rem rem Developed by Chad Ullman rem gemors@mkulu.org rem ******************************************************************* rem ******************************************************************* rem Setup you configuration here rem ******************************************************************* rem Set this to the name of the Singapore site you're publishing to set SITE=gallery.yoursite.org rem This is the temporary working directory set TEMPDIR=c:tempsingtemp rem The FTP user you'll be conencting as set FTPUSER=user rem The FTP user password set FTPPASS=pass rem The base directory for your Singapore galleries set FTPBASEDIR=/www/yoursite/galleries/ rem ******************************************************************* rem MAIN rem ******************************************************************* rem Preamble echo You are about to publish these pictures to %SITE% echo You need to specify what gallery these pictures will be published to echo If you specify a gallery that already exists, these images will be echo added to it. If the gallery doesn't already exist, it will be created echo for you. echo . rem Get gallery name :ask echo What gallery would you like to upload these pictures to (for example, On the Beach)? set /p GALLERY= echo You have entered: %GALLERY% echo Is this correct (y/n)? set /p CHECK= if /i %CHECK% NEQ y goto ask echo OK, we will now begin publishing the pictures to %GALLERY% echo . rem Set up the temp directory rmdir /s /q %TEMPDIR% mkdir %TEMPDIR% rem Copy the files to the temp directory echo Copying pictures to the temporary working folder for %%f in (%*) do copy %%f %TEMPDIR% > NUL if errorlevel 1 goto error echo . rem Resize and compress the files echo Resizing and compressing files cd %TEMPDIR% rem The > in the resize argument tells ImageMagick to only do the resize if the width or rem height of the image is greater then the specified dimensions rem Note also that this resize preserves aspect ratios for %%f in (*.*) do convert %%f -resize "640x640>" -quality 70 %%f if errorlevel 1 goto error echo . rem FTP the files to the new folder echo Uploading pictures to gallery %GALLERY% rem The -m switch tells ncftpput to try and create the directory if it doesn't rem already exist ncftpput -u %FTPUSER% -p %FTPPASS% -m ftp.mkulu.org "%FTPBASEDIR%/%GALLERY%" *.* if errorlevel 1 goto error echo . rem And we're all done echo All done goto done rem Crappy attempt at something resembling exception handling :error echo echo Oops! echo Something's gone wrong. You might want to contact someone and let him know pause :done
#2 2004-07-25 19:15:09
- tamlyn
- Lead Developer

Re: Technique for batch resize/compress and upload from Windows
Wow! nice work
I need to set up a 'contrib' forum for stuff like this.
Offline
#3 2006-10-24 11:13:39
- stix2drums
- Member
Re: Technique for batch resize/compress and upload from Windows
The 'contrib' forum is a must have for this great script:)
Offline
#4 2010-01-26 12:02:19
- biancastratfords
- Member
Re: Technique for batch resize/compress and upload from Windows
i dont usually post in forums but i wanted to say thank you!
[url=http://www.sonicloans.net/]Payday loans[/url] , [url=http://www.sonicgates.net/]Bad credit loans[/url] and [url=http://www.flyingloans.com/]Personal loans[/url]
Offline