Page 1 of 1
ImageMagick Conversion
Posted: Wed Aug 22, 2012 4:28 pm
by MattV
Hi there,
I've been attempting to write a very simple VBScript which uses ImageMagick to convert from one format into another.
Such that an JPEG arrives in a folder > Switch picks it up > converts to a PNG file. The original filename will be unknown.
I would very much appreciate any help given here, as I've achieved roughly nothing!
Thanks in advance
ImageMagick Conversion
Posted: Wed Aug 22, 2012 8:31 pm
by dkelly
You shouldn't need to write VBscript to call ImageMagick or GraphicMagick. Use the Execute Command configurator and set the properties to:
Command: convert
Arguments: "%1" "png:%3/[Job.NameProper].png"
Output: Result in folder
ImageMagick Conversion
Posted: Thu Aug 23, 2012 10:39 am
by MattV
Thanks for that, I've got that part working. But I really just wanted to get the VBScript part working for more complex tasks.
Such as one script outputting to multiple folders.
I've struggled to get it working at all, which is why I went with a basic task. Any pointers would be much appreciated.
ImageMagick Conversion
Posted: Thu Aug 23, 2012 12:24 pm
by dkelly
I can't help with VBscript as I use Javascript exclusively for Switch development.
ImageMagick Conversion
Posted: Thu Aug 23, 2012 4:56 pm
by MattV
Would be grateful for an example in JavaScript, should be able to figure it out from there.
Thanks!
ImageMagick Conversion
Posted: Thu Aug 23, 2012 10:22 pm
by dkelly
// GraphicsMagick convert script
// (c) 2012 by Apago, Inc. - All rights reserved
// Created by Dwight Kelly <
dkelly@apago.com>
// Date: 2012/08/22
//
function jobArrived( s : Switch, job : Job )
{
var outputPath = job.createPathWithExtension(".png", false);
var String args = new Array();
args[0] = "/opt/local/bin/convert";
args[1] = job.getPath();
args[2] = "png:" + outputPath;
var exitStatus = Process.execute(args);
if (exitStatus == 0) {
job.sendToSingle(outputPath);
return;
}
job.fail("convert failed!");
}