2014-05-21 198 views
0

我正嘗試使用InDesign Server使用通過表單傳入InDesign腳本的變量創建服務順序。Spawn ENOENT錯誤 - NodeJS

但我不斷收到以下錯誤:

/Users/rickybarnett/Desktop/curries-indesign/oos-w2p.dev/oos-curries/routes/oos.js:422 
    if(err) throw err; 

^Error: spawn ENOENT 
    at errnoException (child_process.js:988:11) 
    at Process.ChildProcess._handle.onexit (child_process.js:779:34) 
    21 May 20:27:57 - [nodemon] app crashed - waiting for file changes before starting... 

我已經安裝了所有的依賴關係,並使用NPM安裝缺失模塊也進行檢查。

此錯誤僅發生在我的路線之一:

// ROUTES FOR FIRST PAGE ************************************************************************************** 

/* GET load the first page for user editing */ 
router.get('/first-page', function(req, res) { 

// get the pages json input list 
var json = req.session.template.page_one_setup; 
var form = JSON.parse(json); 

TrimColours.getDropdownItems(function(results) { 
    res.render('oos/first-page', {trimColours: results, form: form, templateColor: req.session.templateColor}); 
}); 

}); 

router.post('/first-page-indesign', function(req, res){ 

// get the templates json input list 
var json = req.session.template.page_one_setup; 
var form = JSON.parse(json); 

var body = req.body; 
var trimColourId = body.trim_colour_id; 

//perform validation 
req.checkBody('name', 'Please provide a name').notEmpty(); 
req.checkBody('trim_colour_id', 'Please select the trim colour').notEmpty(); 

var errors = req.validationErrors(); 

if(errors) { 
    res.send({errors: errors}); 
    return; 
} 

TrimColours.getTrimColourValueById(trimColourId, function(result) { 
    //store the value of trim colour in session 
    req.session.trimColour = result.colour_value; 
    req.session.templateColor = body.colorpicker; 

    // prepare the base arguments required by the script 
    var args = [ 
     {name: 'applicationPath', value: settings.PROJECT_DIR }, 
     {name: 'colour', value: req.session.colourValue}, 
     {name: 'trimColour', value: result.colour_value}, 
     {name: 'templateName', value: req.session.template_file}, 
     {name: 'pageNumber', value: "1" }, 
     {name: 'pageColor', value: body.colorpicker}, 
    ]; 

    var inputs = ""; 

    // loop over the form json string to set up the args array to be sent to the indesign script 
    // and to create the inputs array to be passed into the the script so the script can resolve the 
    // arguments and assign them to correct page items 
    for (var i = 0; i < form.length; i++) { 
     args.push({name: form[i].input_name, value: body[form[i].input_name] }); 
     inputs += form[i].input_name + ","; 
    }; 

    args.push({name: 'inputs', value: inputs.substring(0, inputs.length - 1)}); 

    //Call the indesign server 
    runScript(args, body, function(result) { 

     req.session.userFile = result.fileName 

     //get unique image path returned from indesign script 
     var imagePath = "/oos-preview-image/" + result.image; 
     res.send(imagePath); 
    }); 
}); 
}); 

442線在這裏載: 「如果(ERR)拋出走錯了路。」

//function responsible for cropping an image and sending back the path 
router.get('/crop-image', function(req, res) { 
var url_parts = url.parse(req.url, true); 
var query = url_parts.query; 

var coords = query.coords.split(','); 

//split the image name by "." 
var croppedImageName = query.image.split('.')[0]; 

var extensionName = Math.round(new Date().getTime()/1000); 

//loop over the coordinates and change them into an int 
for (var i = 0; i < coords.length; i++) { 
    coords[i] = +coords[i]; 
}; 

//create a new cropped image and pass back the name 
gm(settings.PROJECT_DIR +'/public/user-images/' + query.image) 
.crop(coords[0], coords[1], coords[2], coords[3]) 
.write(settings.PROJECT_DIR +'/public/user-images/' + croppedImageName + "_croped_" + extensionName + ".png", function(err){ 
    if(err) throw err; 

    res.send(croppedImageName + "_croped_"+ extensionName +".png"); 
}); 

}); 
+0

這將有助於知道您的路線文件中的哪一行是422。 – punund

+0

我編輯了包含第422行和周圍代碼的問題。 – user3662307

回答

1

您是否在使用ImageMagick?


var gm = require("gm"); 
var im = gm.subClass({imageMagick: true}); 
im("path/image.png") 
    .crop(10,10,10,10) 
    .write("path/imagecropped.png", function(err){ 
     if(err){throw err;} 
    }); 
+0

不,我正在使用graphicsmagick,它安裝在我的電腦上 – user3662307

0

出於某種原因,故宮沒有安裝正確實:graphicsmagick,通過安裝固定的首頁此然後通過它來安裝graphicsmagick。