Herself’s Webtools

Webtools for Webmasters: Scripts, HowTos, Templates, Plugins, Widgets, Tips and Useful Information

Herself’s Webtools header image 1

Entries Tagged as 'linux'

Bulk Image Processing for websites using Image Magick

July 20th, 2007 · No Comments

You might be developing a site to show off someone’s photos. Or maybe you are building an online store and you have hundreds of images to process. Well we all love GIMP but re-sizing 500 photos for thumbnails would give anyones mouse hand a cramp if you did them one by one.

When you have lots and lots of photos to process you will want to set aside GIMP and use ImageMagick. There are binary versions available for Unix/Windows/OSX and source code versions available for those of you who prefer to compile your own. This is Open Source, free for you to use software.

Directions for installing ImageMagick (* see note for OSX at bottom of post )

Now I’m old school and often work from a command line or terminal. Those of you who would rather have a graphical interface might want to check out JMagick, a Java interface for working with ImageMagick. This is just an interface, ImageMagick will need to be properly installed first for the interface to work.

Once you have it up and running you can batch process your images.

For instance if you want to create thumbnails for 100 jpg images:
Open up a terminal window ( Command in Windows Terminal in OSX )
cd to the directory with the images
type at the command prompt and hit enter
convert *.jpg -resize 100 thumbnail%03.png

This will convert all files ending in .jpg in this directory to png files that have a width of 100 pixels and are named thumbnail000.png to thumbnail099.png.

You can convert jpgs to png to gif and any which way between them.

You can do any of the following conversions to the files:
[-adaptive-blur • -adaptive-resize • -adaptive-sharpen • -adjoin • -affine • -annotate • -antialias • -append • -authenticate • -auto-orient • -average • -backdrop • -background • -bias • -black-point-compensation • -black-threshold • -blue-primary • -blur • -border • -bordercolor • -borderwidth • -cache • -channel • -charcoal • -chop • -clip • -clip-mask • -clip-path • -clip-path • -clone • -coalesce • -colorize • -colormap • -colors • -colorspace • -combine • -comment • -compose • -composite • -compress • -contrast • -contrast-stretch • -convolve • -crop • -cycle • -debug • -deconstruct • -define • -delay • -delete • -density • -depth • -descend • despeckle • -displace • -display • -dispose • -dissolve • -distort • -dither • -draw • -edge • -emboss • -encoding • -endian • -enhance • -equalize • -evaluate • -extent • -extract • -fill • -filter • -flatten • -flip • -flop • -font • -foreground • -format • -format • -frame • -frame • -fuzz • -fx • -gamma • -gaussian-blur • -geometry • -gravity • -green-primary • -help • -iconGeometry • -iconic • -identify • -immutable • -implode • -insert • -intent • -interlace • -interpolate • -label • -lasso • -lat • -layers • -level • -limit • -linear-stretch • -linewidth • -list • -log • -loop • -magnify • -map • -map • -mask • -matte • -mattecolor • -mask • -median • -metric • -mode • -modulate • -monitor • -monochrome • -morph • -mosaic • -motion-blur • -name • -negate • -noise • -normalize • -opaque • -ordered-dither • -orient • -page • -paint • -path • -pause • -pause • -pen • -ping • -pointsize • -polaroid • -posterize • -preview • -print • -process • -profile • -quality • -quantize • -quiet • -radial-blur • -raise • -random-threshold • -recolor • -red-primary • -regard-warnings • -region • -remote • -render • -repage • -resample • -resize • -reverse • -roll { • -rotate • -sample • -sampling-factor • -scale • -scene • -scenes • -screen • -seed • -segment • -separate • -sepia-tone • -set • -shade • -shadow • -shared-memory • -sharpen • -shave • -shear • -sigmoidal-contrast • -silent • -size • -sketch • -snaps • -solarize • -splice • -spread • -stegano • -stereo • -storage-type • -strip • -stroke • -strokewidth • -support • -swap • -swirl • -text-font • -texture • -threshold • -thumbnail • -tile • -tile-offset • -tint • -title • -transform • -transparent • -transparent-color • -transpose • -transverse • -treedepth • -trim • -type • -undercolor • -unique-colors • -units • -unsharp • -update • -verbose • -version • -view • -vignette • -virtual-pixel • -visual • -watermark • -wave • -white-point • -white-threshold • -window • -window-group • -write]

There are hundreds of detailed examples here: ( ImageMagick Examples )

*Note for OSX installations:
You will need to edit your .bash_profile file. It is in your home directory, and add the following lines.

#ImageMagick Stuff
export MAGICK_HOME=”/usr/local/ImageMagick”
PATH=$PATH:$MAGICK_HOME/bin
export PATH
export DYLD_LIBRARY_PATH=”$MAGICK_HOME/lib”
# end Image Magick Stuff

Save the file, close the terminal window and open a new one to cause .bash_profile to run.

Tags: graphics · how to · linux · osx · tools

PERL script to find and replace every string in a sub directory

March 8th, 2007 · No Comments

This is a tool that enters a sub-directory and reads and changes one string to another.

I use it when I make major updates to my website or am updating links. I can have it search for the old link and replace it with the new link. (or any other piece of text you’d like to change).

It puts the altered files in the working directory and leaves the originals unchanged. It also prints to the screen the file name and line number of any changes made.

findAndReplace.pl

Tags: linux · osx · perl · tools

Change all the file names in a directory

March 7th, 2007 · No Comments

If you have a directory of files with the same substring sayjoke1.html, joke2.html, joke3.html … and you want to rename themriddle1.html, riddle2.html, riddle3.html this tool does that.

It is a PERL script, it will ask you for the old and new strings and changethe files in the directory in which the script is located.

chgfilename.pl

Tags: how to · linux · osx · perl · tools

PERL script to fetch your IP and email it to yourself

March 6th, 2007 · No Comments

I have two older scripts for grabbing your ip and emailing it to you. Getip.pl and Getip2.pl And today I put together Getip3.pl

The first script is the bare minimum needed and works on Linux. Just change it to put in your email address and run it as a cron job. 

The second script works on Windows or Linux and is more robust than the first one. Again change the email information and then run it as a cron script under Linux or in the Windows scheduler if you are running Windows. 

The third script works on OSX. Change the email to and from addresses. Install it as a cron job to have it run automatically on your computer. (MacDevCenter Cron job how to is at bottom of the page )

Tags: how to · linux · osx · perl · tools