ImageMagick Conversion

Post Reply
MattV
Newbie
Posts: 11
Joined: Wed Aug 22, 2012 4:25 pm

ImageMagick Conversion

Post 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
dkelly
TOP CONTRIBUTOR
Posts: 628
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

ImageMagick Conversion

Post 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


MattV
Newbie
Posts: 11
Joined: Wed Aug 22, 2012 4:25 pm

ImageMagick Conversion

Post 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.
dkelly
TOP CONTRIBUTOR
Posts: 628
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

ImageMagick Conversion

Post by dkelly »

I can't help with VBscript as I use Javascript exclusively for Switch development.
MattV
Newbie
Posts: 11
Joined: Wed Aug 22, 2012 4:25 pm

ImageMagick Conversion

Post by MattV »

Would be grateful for an example in JavaScript, should be able to figure it out from there.



Thanks!
dkelly
TOP CONTRIBUTOR
Posts: 628
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

ImageMagick Conversion

Post 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!");

}
Post Reply