Random Sequence

Using Command Line PHP scripts to control ImageMagick from Platypus Droplets

Sponsored Links:

Packaging ImageMagick Droplets with Platypus

  • Download & un-zip the latest ImageMagick Mac OS X binaries.
  • Open Platypus.
  • Check ‘Is droppable’
  • Click the ‘Show advanced options’ disclosure triangle (if not already open).
  • Drop the ‘ImageMagick-6.3.5’ folder onto Platypus’ ‘Files and folders to be blundled with…’ area.
  • I used Command Line PHP for my scriping language. Below is an example script.
  • Click the ‘Create’ button.
  • Drop images on the resulting application.

Note - Using the ImageMagick.org binaries requires installing X11 from the OS X installation CD.

!/usr/bin/php -q

<?php

// For Platypus droplets $argv contains: // [0] - Absolute to the running script // [1] - Absolute path to the droplet // [2...n] - Absolute path to each dropped file

// Set ImageMagick environment variables relative to the running application $escAppPath = escapeshellcmd($argv[1]); putenv("MAGICK_HOME=$escAppPath/Contents/Resources/ImageMagick-6.3.5"); putenv("DYLD_LIBRARY_PATH=$escAppPath/Contents/Resources/ImageMagick-6.3.5/lib");

$mogrifyPath = "\"{$argv[1]}/Contents/Resources/ImageMagick/bin/mogrify\"";

// find the files dropped onto the Platypus app icon: $droppedFiles = array_slice($argv,2);

foreach ($droppedFiles as $droppedFile) { $command = "$mogrifyPath '$droppedFile' -resize '640x480>'"; exec($command); }

?>

Sponsored Links: