{"action":"created","issue":{"url":"https://api.github.com/repos/hacksparrow/node-easyimage/issues/97","repository_url":"https://api.github.com/repos/hacksparrow/node-easyimage","labels_url":"https://api.github.com/repos/hacksparrow/node-easyimage/issues/97/labels{/name}","comments_url":"https://api.github.com/repos/hacksparrow/node-easyimage/issues/97/comments","events_url":"https://api.github.com/repos/hacksparrow/node-easyimage/issues/97/events","html_url":"https://github.com/hacksparrow/node-easyimage/issues/97","id":295880131,"number":97,"title":"unshift error when using .execute() command","user":{"login":"alanosman","id":2914981,"avatar_url":"https://avatars3.githubusercontent.com/u/2914981?v=4","gravatar_id":"","url":"https://api.github.com/users/alanosman","html_url":"https://github.com/alanosman","followers_url":"https://api.github.com/users/alanosman/followers","following_url":"https://api.github.com/users/alanosman/following{/other_user}","gists_url":"https://api.github.com/users/alanosman/gists{/gist_id}","starred_url":"https://api.github.com/users/alanosman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alanosman/subscriptions","organizations_url":"https://api.github.com/users/alanosman/orgs","repos_url":"https://api.github.com/users/alanosman/repos","events_url":"https://api.github.com/users/alanosman/events{/privacy}","received_events_url":"https://api.github.com/users/alanosman/received_events","type":"User","site_admin":false},"labels":[{"id":441503,"url":"https://api.github.com/repos/hacksparrow/node-easyimage/labels/invalid","name":"invalid","color":"e6e6e6","default":true}],"state":"open","locked":false,"assignee":{"login":"mrkmg","id":399561,"avatar_url":"https://avatars2.githubusercontent.com/u/399561?v=4","gravatar_id":"","url":"https://api.github.com/users/mrkmg","html_url":"https://github.com/mrkmg","followers_url":"https://api.github.com/users/mrkmg/followers","following_url":"https://api.github.com/users/mrkmg/following{/other_user}","gists_url":"https://api.github.com/users/mrkmg/gists{/gist_id}","starred_url":"https://api.github.com/users/mrkmg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrkmg/subscriptions","organizations_url":"https://api.github.com/users/mrkmg/orgs","repos_url":"https://api.github.com/users/mrkmg/repos","events_url":"https://api.github.com/users/mrkmg/events{/privacy}","received_events_url":"https://api.github.com/users/mrkmg/received_events","type":"User","site_admin":false},"assignees":[{"login":"mrkmg","id":399561,"avatar_url":"https://avatars2.githubusercontent.com/u/399561?v=4","gravatar_id":"","url":"https://api.github.com/users/mrkmg","html_url":"https://github.com/mrkmg","followers_url":"https://api.github.com/users/mrkmg/followers","following_url":"https://api.github.com/users/mrkmg/following{/other_user}","gists_url":"https://api.github.com/users/mrkmg/gists{/gist_id}","starred_url":"https://api.github.com/users/mrkmg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrkmg/subscriptions","organizations_url":"https://api.github.com/users/mrkmg/orgs","repos_url":"https://api.github.com/users/mrkmg/repos","events_url":"https://api.github.com/users/mrkmg/events{/privacy}","received_events_url":"https://api.github.com/users/mrkmg/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2018-02-09T14:00:17Z","updated_at":"2018-02-10T13:54:40Z","closed_at":null,"author_association":"NONE","body":"Hello, \r\n\r\nI recently was trying to update our modules for easyimage in our nodeJS app to the latest and have hit a wall on trying to figure out where the problem lies.  We currently are using npm module version 2.1.0 in our application, which has been converting images quite well.  I was upgrading (as we do) to 3.0.1 to stay up with the latest and ran into issues when shifting from the deprecated `exec` function changing to `execute`.  \r\n\r\nAround version 2.2.1, we start to see this warning when using the .exec() function. \r\n![image](https://user-images.githubusercontent.com/2914981/36031828-12082950-0d7a-11e8-9ae4-66257804b2b3.png) but when switch to execute() function, it also fails.\r\n\r\nWhen I change the code to `execute` we see an `unshift` error.  The ends up being caught with our error handler on the returned promise that the execute function returns.  I've experimented by changing the parameters that we are passing in, thinking that something changed there, but it doesn't seem to make a difference.  \r\n\r\nCan someone give me a clue as to what I might be doing wrong or is this a bug?  I've pasted error, environment and code below. \r\n\r\nnode 7.10.1\r\n\r\n```\r\n2018-02-08T02:35:12.109Z Unhandled rejected promise: TypeError: Cannot read property 'unshift' of undefined at Object.execute  (/mnt/d/elastc-app/node_modules/easyimage/lib/execute.js:47:17) \r\n  at generateThumbnail  (/mnt/d/elastc-app/app/common/thumbnail/index.js:84:49) \r\n  at Object.generateLane  (/mnt/d/elastc-app/app/common/thumbnail/index.js:78:48)\r\n  at Object.generate_thumbnails (/mnt/d/elastc-app/app/actions/api/tasks.js:4423:60)\r\n  at /mnt/d/elastc-app/app/actions/api/tasks.js:3980:50\r\n  at _fulfilled (/mnt/d/elastc-app/node_modules/q/q.js:854:54)\r\n  at self.promiseDispatch.done (/mnt/d/elastc-app/node_modules/q/q.js:883:30)\r\n  at Promise.promise.promiseDispatch (/mnt/d/elastc-app/node_modules/q/q.js:816:13)\r\n  at /mnt/d/elastc-app/node_modules/q/q.js:624:44 at runSingle (/mnt/d/elastc-app/node_modules/q/\r\nq.js:137:13)\r\n  at flush (/mnt/d/elastc-app/node_modules/q/q.js:125:13)\r\n  at _combinedTickCallback (internal/process/next_tick.js:73:7)\r\n  at process._tickDomainCallback (internal/process/next_tick.js:128:9)\r\n```\r\n\r\nI am running Ubuntu on WSL (Windows)\r\n\r\n```\r\nLSB modules are available.\r\nDistributor ID: Ubuntu\r\nDescription:    Ubuntu 14.04.5 LTS\r\nRelease:        14.04\r\nCodename:       trusty\r\n```\r\n\r\nI have this version of ImageMagick installed\r\n```\r\nVersion: ImageMagick 7.0.7-13 Q16 x86_64 2017-12-01 http://www.imagemagick.org\r\nCopyright: © 1999-2017 ImageMagick Studio LLC\r\nLicense: http://www.imagemagick.org/script/license.php\r\nFeatures: Cipher DPC HDRI OpenMP\r\nDelegates (built-in): fontconfig freetype jbig jng jpeg lzma png tiff zlib\r\n```\r\n\r\n```\r\nconst Q         = require('q');\r\nconst appRoot   = '../..';\r\nconst easyimage = require('easyimage');\r\nconst path      = require('path');\r\nconst logger    = require(`${appRoot}/logger`);\r\n\r\nconst imageMagickParams = {\r\n    detail       : '-quality 93 -thumbnail \\\"234\\\\>\\\" -unsharp 1.5x1+0.7+0.02 -gravity Center -extent 234 -crop x182+0+0',\r\n    lane         : '-quality 93 -thumbnail \\\"231\\\\>\\\" -unsharp 1.5x1+0.7+0.02 -gravity Center -extent 231 -crop x182+0+0',\r\n    organization : '-quality 93 -thumbnail \\\"227\\\\>\\\" -unsharp 1.5x1+0.7+0.02 -gravity North -extent 227 -crop x227+0+0',\r\n    user         : '-quality 93 -thumbnail \\\"100\\\\>\\\" -unsharp 1.5x1+0.7+0.02 -gravity North -crop x100+0+0'\r\n};\r\n\r\nconst imageMagickCommand = (type, sourceFilePath) => {\r\n    const imParams            = imageMagickParams[type];\r\n    const destinationFilePath = generateDestinationFilePath(type, sourceFilePath);\r\n\r\n    const imCommand =\r\n        `convert \\\"${sourceFilePath}\\\" ${imParams} \\\"${destinationFilePath}\\\"`;\r\n\r\n    return imCommand;\r\n};\r\n\r\nconst generateDestinationFilePath = (type, sourceFilePath) => {\r\n    let destinationFilePath;\r\n\r\n    if (type === 'lane' || type === 'detail') {\r\n        var thumbFileSuffix = '_' + type;\r\n        destinationFilePath = sourceFilePath + thumbFileSuffix + path.extname(sourceFilePath);\r\n    } else {\r\n        destinationFilePath = sourceFilePath;\r\n    }\r\n\r\n    return destinationFilePath;\r\n};\r\n\r\nconst generateOrganization = srcFilePath    => generateThumbnail(srcFilePath,    'organization');\r\nconst generateProfile      = sourceFilePath => generateThumbnail(sourceFilePath, 'user');\r\nconst generateDetail       = sourceFilePath => generateThumbnail(sourceFilePath, 'detail');\r\nconst generateLane         = sourceFilePath => generateThumbnail(sourceFilePath, 'lane');\r\n\r\nconst generateThumbnail = (sourceFilePath, type) => {\r\n    const deferredGenerateThumbnail = Q.defer();\r\n    const imCommand                 = imageMagickCommand(type, sourceFilePath);\r\n    const destinationFilePath       = generateDestinationFilePath(type,sourceFilePath);\r\n    const easyImagePromise          = easyimage.execute(imCommand);\r\n\r\n    easyImagePromise\r\n        .then(() => {\r\n            const easyImageInfoPromise = easyimage.info(destinationFilePath);\r\n\r\n            easyImageInfoPromise\r\n                .then(thumbnailFile => {\r\n                    let im_filename   = thumbnailFile.name;\r\n                    let im_name_parts = thumbnailFile.name.split(' ');\r\n\r\n                    if (im_name_parts.length > 1) {\r\n                        if (im_name_parts[0] !== 'Undefined')\r\n                            logger.error('Unexpected behavior from imagemagick.info()');\r\n                        // Do this in either case\r\n                        im_filename = im_name_parts[1];\r\n                    }\r\n                    deferredGenerateThumbnail.resolve(im_filename);\r\n                },\r\n                err => {\r\n                    logger.error('Error getting info for: ' + destinationFilePath + ' Error: ' + err);\r\n                    deferredGenerateThumbnail.reject(err);\r\n                }\r\n            );\r\n        },\r\n        err => {\r\n            logger.error('Error converting ' + sourceFilePath + ' Error: ' + err);\r\n            deferredGenerateThumbnail.reject(err);\r\n        });\r\n\r\n    return deferredGenerateThumbnail.promise;\r\n};\r\n\r\nmodule.exports = {\r\n    generateOrganization,\r\n    generateDetail,\r\n    generateLane,\r\n    generateProfile\r\n};\r\n```"},"comment":{"url":"https://api.github.com/repos/hacksparrow/node-easyimage/issues/comments/364656777","html_url":"https://github.com/hacksparrow/node-easyimage/issues/97#issuecomment-364656777","issue_url":"https://api.github.com/repos/hacksparrow/node-easyimage/issues/97","id":364656777,"user":{"login":"alanosman","id":2914981,"avatar_url":"https://avatars3.githubusercontent.com/u/2914981?v=4","gravatar_id":"","url":"https://api.github.com/users/alanosman","html_url":"https://github.com/alanosman","followers_url":"https://api.github.com/users/alanosman/followers","following_url":"https://api.github.com/users/alanosman/following{/other_user}","gists_url":"https://api.github.com/users/alanosman/gists{/gist_id}","starred_url":"https://api.github.com/users/alanosman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alanosman/subscriptions","organizations_url":"https://api.github.com/users/alanosman/orgs","repos_url":"https://api.github.com/users/alanosman/repos","events_url":"https://api.github.com/users/alanosman/events{/privacy}","received_events_url":"https://api.github.com/users/alanosman/received_events","type":"User","site_admin":false},"created_at":"2018-02-10T13:54:40Z","updated_at":"2018-02-10T13:54:40Z","author_association":"NONE","body":"Hi @mrkmg, ok I finally got it working.  I had to provide each option and it's value in quotes separated by commas.  That is not intuitive and not described in any examples or obvious from your comment.  I think it would help to have a clear example so the next coder doesn't fall into the same pit of guessing like I did.\r\n\r\nThis small test script worked for me.  I hope it helps the next person.\r\n```\r\n'use strict';\r\n\r\nconst Q             = require('q');\r\nconst easyimage     = require('easyimage');\r\nconst testImageIn   = 'test-image-in2.jpg';\r\nconst testImageOut  = 'test-image-out2.jpg';\r\nconst deferredImage = Q.defer();\r\n\r\nconst easyImagePromise = easyimage.execute(\r\n    'convert',\r\n    [ testImageIn,\r\n      '-quality', '93',\r\n      '-thumbnail', '231>',\r\n      '-unsharp', '1.5x1+0.7+0.02',\r\n      '-gravity', 'North',\r\n      '-extent', '231',\r\n      '-crop', 'x182+0+0',\r\n      testImageOut ]);\r\n\r\neasyImagePromise\r\n    .then(() => {\r\n    },\r\n    err => {\r\n        console.log('Error converting ' + testImageIn + ' Error: ' + err);\r\n    });\r\n\r\nreturn deferredImage.promise;\r\n```\r\n\r\n@mrkmg What I don't really understand is why you guys implemented it this way or why even deprecate the old way in the first place.  The old way worked just fine.  It seems to me sending options should be supported better, perhaps more like an element array.  This would have been more intuitive:\r\n\r\n```\r\nconst easyImagePromise = easyimage.executue(\r\n{\r\n   action: convert,\r\n   src: testImageIn,\r\n   dst: testImageOut,\r\n   quality, 93,\r\n   thumbnail, 231>,\r\n   unsharp: 1.5x1+0.7+0.02,\r\n   gravity: North,\r\n   extent: 231,\r\n   crop: x182+0+0,\r\n});\r\n```\r\n\r\nor if mapping the options was a hassle, put all the options into a string, like `options: '-quality 93, thumnbail 234, ` etc.\r\n\r\n"}}
{"actor":{"display_login":"alanosman"}}