Search This Blog

Tuesday 5 January 2010

Use File Viking to resize your pictures

The current File Viking beta doesn't include an Action to resize pictures yet. However, if you configure the Run action, it is easy to write a script to call, for example, ImageMagick to resize pictures you drop on a File Viking basket.

The script can use environment variables so it knows which files were dropped on the basket. The variable %FV_FILE% contains the full path to the file dropped on a basket, %FV_FILE_B% contains the "title" of the file without its extension. Below is the example script.

rem Where did you install ImageMagick (www.imagemagick.org)
SET IMA=C:\Program Files\ImageMagick-6.5.8-Q16

rem Where should resized pictures be stored
SET OUTDIR=F:\Testing\Target

rem call convert, make pictures half their original size. As % is a special character in
rem batch scripts, we need to "double" them.
"%IMA%\Convert.exe" "%FV_FILE%" -resize 50%% "%OUTDIR%\%FV_FILE_B%_50percent.png"

rem call convert again, making pictures fit into a 200x200 rectangle while keeping the
rem correct aspect ratio.
"%IMA%\Convert.exe" "%FV_FILE%" -resize 200x200 "%OUTDIR%\%FV_FILE_B%_200x200.png"

And below you see 2 pictures showing how to configure the basket. First we add a Filter action (new in yesterday's beta) so only pictures are allowed for the piped Run action.

The Run action is configured to run a script called F:\testing\fv_resize.bat, this is the script shown above.

This is just a small example how you can create your own actions for File Viking. If you can imagine it, you can do it.

No comments: