GithubHelp home page GithubHelp logo

Comments (7)

ashwiniramesha avatar ashwiniramesha commented on July 21, 2024 1

I faced this issue. Here's what I did:

  1. Checked PC advanced settings to see if I had installed the binary properly and it showed the path in PATH env variable.
  2. restart the console after running npm install gm and then try "gm" command
  3. run "npm install" to install dependent modules

from cordova-media-generator.

rknell avatar rknell commented on July 21, 2024

Hi,

You might need to install graphicsmagick

On OSX

brew install graphicsmagick

Not sure how to do it on other OSes

from cordova-media-generator.

tarekshumaila avatar tarekshumaila commented on July 21, 2024

installed graphicsmagick with brew and still getting this error

Error writing file to disk: Error: Could not execute GraphicsMagick/ImageMagick: convert "-size" "nullxc0b76e221b45d440d4de66b6f35c42df.JPG" "-resize" "760" "public/images/uploads/c0b76e221b45d440d4de66b6f35c42df.JPG" this most likely means the gm/convert binaries can't be found

trying to do resize an uploaded image for a single image first, I am using multer with this, and it put pictures in an array regardless of how many pictures there are according to my settings, here is my code:

if(req.files.image){

  //get properties of files beings uploaded

  var profileImageName      = req.files.image[0].name;
  var profileImagePath      = req.files.image[0].path;
  var buffer                = req.files.image[0].buffer;
  console.log(buffer);
  gm(buffer, profileImageName)
        .resize(760)
        .write(profileImagePath, function(err) {
          if(err) {
            console.log('Error writing file to disk: ' + err);
          }
        });


} else {
  //set default image
  var profileImageName = 'noimage.png';
}

when I console.log(buffer), I get null. Any tips on how to access the image and resize it? I dont want to save high resolution pictures and have my users use up their mobile bandwidth when using my app/site.

Thanks!

from cordova-media-generator.

gprasanth avatar gprasanth commented on July 21, 2024

brew install did not work for me too. I had to install gm with npm to make that error go away.

npm install -g gm

from cordova-media-generator.

tarekshumaila avatar tarekshumaila commented on July 21, 2024

I still see the same error, installed it with sudo npm install -g gm

:/

from cordova-media-generator.

rknell avatar rknell commented on July 21, 2024

hi @tarekshumaila

By the same error does it still contain:

this most likely means the gm/convert binaries can't be found

I am by no means an expert on this, but after a fresh reinstall on a new machine the other day, the only thing I needed to do was install graphicsmagick using brew and it fired up. Maybe try using brew to uninstall it and reinstall it to see if that helps, and check for any errors on installation and report back?

from cordova-media-generator.

tarekshumaila avatar tarekshumaila commented on July 21, 2024

Grrr... I had --> gm = require('gm').subClass({ imageMagick: true });
when I am using graphicsmagick.. so to resolve it, I had to declare it as this.

var gm = require('gm');

In my code I had to change few things to get the picture to resize properly

if(req.files.image){

  //get properties of files beings uploaded
  var profileImageName      = req.files.image[0].name;
  var profileImagePath      = req.files.image[0].path;
  gm(profileImagePath)
    .resize(353, 257)
    .autoOrient()
    .write(profileImagePath, function (err) {
      if (!err) console.log(' hooray! ');
      else console.log(err);
    });

} else {
  //set default image
  var profileImageName = 'noimage.png';
}

-- this will handle one picture... will dig deeper in the code to get it to work for an array of pictures.

rknell - thanks for your help, it did point me to the right direction.

Cheers!

from cordova-media-generator.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.