twolfson / grunt-spritesmith

Grunt task for converting a set of images into a spritesheet and corresponding CSS variables
MIT License
1.14k stars 92 forks source link

the spritesmith engine 'gm' could not be loaded. #25

Closed meterscao closed 11 years ago

meterscao commented 11 years ago

Hi,when I run the grunt-spritesmith , I got a warning message read "Warning: Sorry, the spritesmith engine 'gm' could not be loaded. Please be sure you have installed it properly on your machine. Use --force to continue."

I am sure that I have installed PhantomJS and GM : image

image

And this is my local grunt plugins:

image

The code of Gruntfile.js is copied from the usage in the Readme.md.

I don't know what could cause this issue. Could you help me and have a look?

Thank you ;-)

twolfson commented 11 years ago

The gm engine relies on graphics-magick to be installed. If you are not specifying gm as your engine, spritesmith should automatically use phantomjs or node-canvas instead if possible.

Please refer to the README for more specifications on the gm requirements.

meterscao commented 11 years ago

// OPTIONAL: Specify engine (auto, canvas, gm) 'engine': 'gm', I have specified the gm as the engine

twolfson commented 11 years ago

Okie doke, then you will need to install graphics-magick as instructed in my previous comment. Please refer to the README as also specified. Let me know if you have any troubles.

meterscao commented 11 years ago

Oh sorry , I pasted the wrong picture. GM has been installed...

image

twolfson commented 11 years ago

Graphics magick can change a lot between versions (even 1.3.18 and 1.3.17), can you please install 1.3.17?

Also, if you have installed this after those node_modules were installed, spritesmith saw that you were missing graphics-magick and did not install its engine for gm. To remedy that, delete the node_modules directory and run npm install once more.

twolfson commented 11 years ago

Sorry, I have to go to sleep so please don't think I am ignoring you if you respond. I should reply within the next 24 hours if you comment.

meterscao commented 11 years ago

Thanks a lot ~ Good night? It is 16:52 in China. I am checking.

meterscao commented 11 years ago

Hi good morning;)

I have installed GM 1.3.17, and it runs good.

But I just got another problem: I want to combine images from slice/ to sprite/.

When the slice/ directory was empty ,it would be great with Done,without error and an empty sprite.png will be created in sprite/. But if the slice/ directory contains any image ,it would be wrong ,and says Fatal error: spawn ENOENT.

I tested it in Windows.

twolfson commented 11 years ago

Glad to hear it works =)

This sounds like a problem with the gm engine and your machine. Can you clone twolfson/gmsmith, run npm install, run npm test, and copy/paste the results?

meterscao commented 11 years ago

Okay~, I installed the gmsmith image

And test it

image

twolfson commented 11 years ago

Ah, this looks like an issue to the one in #17. Unfortunately, I couldn't get it patched since the reporter lacked knowledge of node and I didn't have a non-English version of Windows.

I am going to check in on other issues that have collected today and get back to you on this. I believe it will be a lot of patching utf8 to utf16 but not 100% certain.

twolfson commented 11 years ago

Alright, took care of the others. Back to looking into this.

twolfson commented 11 years ago

Good news, my Windows VM seems to be having troubles as well.

twolfson commented 11 years ago

Okay, I hope this is not just an issue with the test suite ordering. Can you checkout gmsmith on 0.1.3, re-install its node_modules, and run npm test?

I have discovered that the test suite is now breaking as of 0.2.0 for Windows due to some imagemagick support.

meterscao commented 11 years ago

Ok,I have re-installed the 0.1.3 but it run error.

image

twolfson commented 11 years ago

Well that's not good. I am going to patch up this bug so I have a stable point to help you further.

meterscao commented 11 years ago

Thanks a lot . You are very kind.

twolfson commented 11 years ago

Alright, I decided to take the short path and disable the imagemagick test for now. The patch became a rabbit hole of tedious updates. Looking into utf16 support now.

twolfson commented 11 years ago

Looks like I was imagining utf16 existing. But it also is not in my code base. Can you translate the error message to English for me?

meterscao commented 11 years ago

Er, it means 'doubleshot' is not a command.

twolfson commented 11 years ago

Ah, I think that is being caused by the way you are testing it. Can you install its devDependencies? This is why I was saying to clone the repo and run npm install inside of it.

twolfson commented 11 years ago

To explain further, doubleshot is the testing framework gmsmith uses but it is not a normal dependency, it is marked as under devDependencies. This is so you don't have to download it if you are going to use the module without the need to test it.

meterscao commented 11 years ago

I run npm install inside of the directory ,and run npm test :

image

twolfson commented 11 years ago

Great! Can you do the same on 0.2.1? That is the patched version that doesn't run imagemagick tests.

twolfson commented 11 years ago

It will also be the one used by grunt-spritesmith.

meterscao commented 11 years ago

image

twolfson commented 11 years ago

That doesn't make much sense, I disabled the imagemagick test but the other 2 tests are passing which is good.

twolfson commented 11 years ago

I would ask you to re-install node_modules but I don't think that will change anything. I think it is time to move up to spritesmith. Can you clone that repo, run npm install, and npm test?

meterscao commented 11 years ago

I download your spritesmith source code ,and run npm install and `npm test. The result is : image

twolfson commented 11 years ago

Great! That looks good too. The reason those tests are failing is:

Onwards to grunt-spritesmith, please clone, npm install, and npm test.

meterscao commented 11 years ago

I hope this would not waste you too much time.

meterscao commented 11 years ago

I got an alert: image

twolfson commented 11 years ago

No worries; it is worth it to save you a lot of time with spritesheets. Bonus points if we discover bugs.

twolfson commented 11 years ago

Ah, I think I might be executing it weird. Could you go into src-test and run grunt by hand?

meterscao commented 11 years ago

I run grunt in the src-test and it gives me the same alert~

twolfson commented 11 years ago

If that still fails, what version of grunt or grunt-cli do you have globally installed?

meterscao commented 11 years ago

image

twolfson commented 11 years ago

Okay, can you delete the grunt.js file in src-test and re-run grunt?

meterscao commented 11 years ago

The same error alert ;(

meterscao commented 11 years ago

image

twolfson commented 11 years ago

Alright, I am going to attempt to reproduce.

twolfson commented 11 years ago

Okay, I could not reproduce in full but I did run into an issue with what I told you to do. Can you git reset --hard (reset changes we made), git fetch, git checkout bug/inspect.windows, and run grunt inside of src-test?

meterscao commented 11 years ago

sorry, I do not use git for getting the source code , I just downloaded the release...

meterscao commented 11 years ago

Could I delete the folder and do this again?

twolfson commented 11 years ago

Unfortunately, I have made updates in a different branch which is changed via git checkout. You can make the same changes though. They were:

Then, run grunt inside of src-test.

meterscao commented 11 years ago

It looks great= = image

twolfson commented 11 years ago

Okay... can you go back to your project, re-install node_modules, and try running grunt again?

meterscao commented 11 years ago

I run npm install in my project folder, and I got this

image

And then I run grunt , I got this

image

This is my Gruntfile.js

  module.exports = function(grunt) {
     grunt.initConfig({
         pkg:grunt.file.readJSON("package.json"),
         'sprite': {
           'all': {
             // Sprite files to read in
             'src': ['public/slice/*.png'],

             // Location to output spritesheet
          'destImg': 'public/sprite/sprite.png',

          // Stylus with variables under sprite names
          'destCSS': 'public/css/sprite_positions.styl',

          // OPTIONAL: Manual override for imgPath specified in CSS
          'imgPath': '../sprite/sprite.png',

          // OPTIONAL: Specify algorithm (top-down, left-right, diagonal [\ format],
              // alt-diagonal [/ format], binary-tree [best packing])
          'algorithm': 'alt-diagonal',

          // OPTIONAL: Specify padding between images
          'padding': 2,

          // OPTIONAL: Specify engine (auto, canvas, gm)
          'engine': 'gm',

          // OPTIONAL: Specify CSS format (inferred from destCSS' extension by default)
              // (stylus, scss, sass, less, json, css)
          'cssFormat': 'css',

          // OPTIONAL: Specify settings for engine
          'engineOpts': {
            'imagemagick': true
          },

          // OPTIONAL: Specify img options
          'imgOpts': {
             // Format of the image (inferred from destImg' extension by default) (jpg, png)
             'format': 'png',

             // Quality of image (gm only)
             'quality': 90
          },

          // OPTIONAL: Specify css options
          'cssOpts': {
            // Some templates allow for skipping of function declarations
            'functions': false
          }
        }
      }
  });
  grunt.loadNpmTasks('grunt-spritesmith');

  grunt.registerTask('default', ['sprite']);

}

The package.json is this

    {
        "name": "ui-framework",
        "version": "0.1.0",
        "pkgName":"ui",
        "devDependencies": {
            "grunt":"*",
            "grunt-spritesmith":"*" 
        }
    }
twolfson commented 11 years ago

You have

 'engineOpts': {
  'imagemagick': true
}

in your config. You only should put that in if you want to use imagemagick over graphics-magick. Since you have graphics-magick installed, if you remove that, then you will be back to running.

A lot of the options you have entered are unnecessary (hence them being marked as OPTIONAL). Please read the description for each and consider if you need/don't need it.

meterscao commented 11 years ago

It works! It is my fault, I should have read the description more carefully. I just copy the code as the default sample code- - Thanks for helping, thank you very much.