singapore: the smallest big galery
home » forum » Lounge » Technique for batch resize/compress and upload from Windows

You are not logged in.

  • Index
  •  » Lounge
  •  » Technique for batch resize/compress and upload from Windows

#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 smile

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 2011-03-21 08:54:17

Re: Technique for batch resize/compress and upload from Windows

thank you so much for rhis post man i was wondering where would i get the info

Offline

 

#5 2012-10-12 07:09:43

steward15
Member

Re: Technique for batch resize/compress and upload from Windows

This script is sort of specific to the way I have my domain laid out, but I hope it gives some ideas to people.


"StewarD"

Offline

 

#6 2012-11-16 07:15:32

koly2h
Member

Re: Technique for batch resize/compress and upload from Windows

Iím impressed, I must say. Really rarely can i encounter a blog thatís the two educative and entertaining, and without a doubt, you have hit the nail over the head. Your idea is actually outstanding; the issue is a factor that not enough people are generally speaking intelligently about. I am very happy that stumbled across this around my search for something relating to this.

Offline

 

#7 2013-02-07 20:12:58

johnbostonn
Member

Re: Technique for batch resize/compress and upload from Windows

While Macs don't come with a specific image editing application, you can use both iPhoto and Preview to perform some basic tasks. Preview is very useful for quickly cropping, resizing and compressing images. A typical need is to open an image, crop it to a certain area, resize it, and then save it out as a compressed file suitable for email or Web display.

John Boston
http://ashfordrealestatecoloradosprings.com

Offline

 

#8 2013-02-15 11:16:08

andecolink
Member

Re: Technique for batch resize/compress and upload from Windows

Desktop search and Net search are from the opposite ends of the search spectrum. This is the program everyone needs.

Ande colink
get youtube views

Last edited by andecolink (2013-02-15 11:16:20)

Offline

 
  • Index
  •  » Lounge
  •  » Technique for batch resize/compress and upload from Windows