Turistforeningen / node-s3-uploader

Flexible and efficient resize, rename, and upload images to Amazon S3 disk storage. Uses the official AWS Node SDK for transfer, and ImageMagick for image processing. Support for multiple image versions targets.
https://www.npmjs.com/package/s3-uploader
MIT License
241 stars 54 forks source link

Nope Command failed: /bin/sh -c identify -format #73

Closed kikar closed 8 years ago

kikar commented 8 years ago

I'm trying to upload some photos as I receive them from a POST request, here is my code:

var multer  = require('multer');
var Upload = require('s3-uploader');
var upload = multer({ dest: 'uploads/' });
var photoRouter = require('express').Router();

// Same as Example in README
var client = new Upload('my-bucket-name', {
  aws: {
    path: 'images/',
    region: 'eu-west-1',
    accessKeyId: 'my-key-id',
    secretAccessKey: 'my-secret-acess-key',
    acl: 'public-read'
  },
  cleanup: {
    versions: true,
    original: false
  },
  original: {
    awsImageAcl: 'private'
  },
  versions: [{
    maxHeight: 1040,
    maxWidth: 1040,
    format: 'jpg',
    suffix: '-large',
    quality: 80,
    awsImageExpires: 31536000,
    awsImageMaxAge: 31536000
  },{
    maxWidth: 780,
    aspect: '3:2!h',
    suffix: '-medium'
  },{
    maxWidth: 320,
    aspect: '16:9!h',
    suffix: '-small'
  },{
    maxHeight: 100,
    aspect: '1:1',
    format: 'png',
    suffix: '-thumb1'
  },{
    maxHeight: 250,
    maxWidth: 250,
    aspect: '1:1',
    suffix: '-thumb2'
  }]
});

photoRouter.post('/', upload.array('photos', 12), postPhoto);

function postPhoto(req, res, next) {

  console.log(req.files);
  // I'm ignoring the posted files, that are correctly saved, and trying to upload the photo I have in the folder
  return client.upload('uploads/profile-picture.jpg', {}, function(err, versions, data) {
    if (err) {
      console.log('Nope', err.message);
      return res.status(400).send('KO');
    }

    console.log('Success', versions, data);
    return res.status(200).send('OK');
  });
}

And here is the error I'm getting:

Nope Command failed: /bin/sh -c identify -format "name=
size=%[size]
format=%m
colorspace=%[colorspace]
height=%[height]
width=%[width]
orientation=%[orientation]
" uploads/profile-picture.jpg
/bin/sh: identify: command not found

I'm using node 4.2.4 on OSX 10.11.2 with s3-uploader 1.1.0

anthonyringoet commented 8 years ago

@kikar Could you verify if ImageMagick is installed on your instance? https://github.com/Turistforeningen/node-s3-uploader#requirements

kikar commented 8 years ago

@anthonyringoet Nope, is that required? Cause I wont be able to install it on my server

anthonyringoet commented 8 years ago

@kikar s3-uploader module uses imagemagick in the background to generate the different image sizes. After the resize process, they are uploaded to S3. Imagemagick is a hard requirement right now.

kikar commented 8 years ago

@anthonyringoet Is ImageMagick CLI enough? Would I be fine just installing it with brew install imagemagick?

anthonyringoet commented 8 years ago

@kikar Normally that should fix it yes. Please try it and verify your imagemagick version identify --version

anthonyringoet commented 8 years ago

Did it work out for you @kikar? Feel free to open if you're still having issues.

davidfloegel commented 7 years ago

hey! sorry to re-open this but I'm running into a similar issue with some(!) images!

Error: Error: Command failed: identify -format "name=
size=%[size]
format=%m
colorspace=%[colorspace]
height=%[height]
width=%[width]
orientation=%[orientation]
" /tmp/1504179042590.png
identify: improper image header `/tmp/1504179042590.png' @ error/png.c/ReadPNGImage/4232.

For some reason some images work and some don't.. any idea?