GithubHelp home page GithubHelp logo

rknell / cordova-media-generator Goto Github PK

View Code? Open in Web Editor NEW
28.0 5.0 20.0 58 KB

CLI Utility that generates Cordova / Phonegap image assets required for app store submission, icons, and splash screens.

License: Apache License 2.0

JavaScript 100.00%

cordova-media-generator's Introduction

cordova-media-generator

CLI Utility that generates Cordova / Phonegap image assets required for app store submission, icons, and splash screens.

It requires your logo to have a solid background colour but does not distort or lose any image content so everything is at the maximum size without loss.

New in v0.4.0

  • Removed screenshot generator - just didn't work
  • Completely overhauled the old version, removed a bunch of legacy commands and simplified updating new images.
  • Make Cordova iOS4 compatible.
  • Now using the config.xml to do all configuration and creating the exact same file format as referenced in http://cordova.apache.org/docs/en/latest/config_ref/images.html

For a full copy/paste set for your config.xml see instructions.xml in the root of the source.

Usage:

You need to have graphicsMagick installed before you can generate any assets (with homebrew installed on OSX):

$ brew install gm

with NodeJS installed:

$ npm install -g cordova-media-generator

Once installed, cd to the root of your Cordova application and run:

$ mediagen init

If you have created a mediagen-config.json file (see below), you can just run:

$ mediagen

This will overwrite all logos and splash screen images in the <projectdir>/platforms directory with the correct sizes and in the correct location for Cordova (As at 3.5)

The recommended image or logo size is 2000px x 2000px. Its not a problem if the logo isn't square.

It also creates a <projectdir>/Media directory that has images for the Apple and Android stores such as an app icon.

Custom Assets

You can create additional custom images if you need to submit to alternative app stores or have other needs that we haven't thought of yet.

Simply go to your project directory and run

$ mediagen init

It will create an example file called mediagen-config.json which you can now edit. Add as many or few files as you need to the array.

Note: The default path for files is the <projectdir>/platforms directory, you might need to use ../ as in the example below

###Example mediagen-config.json

{
    "icon": {"filename":"icon.png","background":"fff"},
    "splash": {"filename":"splash.png","background":"fff"},
    "customImages": [
        {"width": 120, "height": 120, "path": "../Media/custom", "filename":"outputFilename.png", "source":{"filename":"image.png","background":"fff"}}
    ],
    "screenshots": [
        {"url":"http://www.google.com", "name":"homepage"}
    ]
}

##Config The config variables are below:

  • icon: icon image
    • filename: path to source filename
    • background: solid colour in hex
  • splash: splash image
    • filename: path to source filename
    • background: solid colour in hex
  • custom images: an array of custom image objects for additional media if desired
    • width: the width of the image in pixels
    • height: the height of the image in pixels
    • path: the directory to save the output
    • filename: the output file name with extension
    • source: the source file, same definition as an icon or splash above
      • filename: path to source filename
      • background: solid colour in hex
  • screenshots: An array of screenshot objects
    • url: url to your local development server
    • name: name of the page for easy reference later on

##Changelog v0.4.0 - Removed support for PhantomJS screenshots - they just weren't up to scratch. - Added support for Cordova 4 and moved to config.xml file setup instead of just replacing images in their place v0.3.6 - Added support for icon-60@3x, 667h Portrait, 736h Landscape, 736h Portrait v0.3.5 - Fix crash if no screenshots are specified

cordova-media-generator's People

Contributors

christiaanscheermeijer avatar cyprusglobe avatar glebovsky avatar rknell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cordova-media-generator's Issues

GM Error on running mediagen

Installed mediagen by running npm install -g mediagen

I get this error when I run mediagen in my phonegap project folder.

GM Error [Error: Could not execute GraphicsMagick/ImageMagick: gm "identify" "-ping" 
"-format" "%wx%h" "file.png" this most likely means the gm/convert binaries can't be 
found]

Even though I have identify and convert binaries installed, I went ahead and installed GM module with npm install -g gm, but still this error won't go away.

Execution requires phantomjs, add to prerequisites?

Hi!

I was getting a (usual) strange error from node, with a lot of details like spawn EACCESS when trying to generate set of icons for the app. I had both GM and imagemagick, so that was not the case.

The stack suggested that it was about the Phantom, so once I've installed it, things gone better.

Probably worth adding that to the readme.md just in case? Or make it optional?

Cheers,
Alex.

iOS images generated in wrong folder since update

Images are created in platforms/ios/NAME/Resources/icons and platforms/ios/NAME/Resources/spash.

New XCode needs images in platforms/ios/NAME/Images.xcassets/AppIcon.appiconset and platforms/ios/NAME/Images.xcassets/LaunchImage.launchimage

Also some image sizes are not needed anymore (icon-40@3x, icon-60) but other sizes are needed now (icon-83.5@2x).

crash when ios not present

C:\cb\td\win8\shell\86bea9f8-d2af-457b-8a54-c017ae1b8364>mediagen
Error getting iOS path { [Error: ENOENT, readdir 'C:\cb\td\win8\shell\86bea9f8-d2af-457b-8a54-c017ae1b8364\platforms\ios']
  errno: 34,
  code: 'ENOENT',
  path: 'C:\\cb\\td\\win8\\shell\\86bea9f8-d2af-457b-8a54-c017ae1b8364\\platforms\\ios' }
------------------------------
   cordova-media-generator
------------------------------
Generating 85 images so you don't have to
------------------------------
Args: fff icon.png [email protected] ios/undefined/Resources/icons
Args: fff icon.png icon-40.png ios/undefined/Resources/icons
Args: fff icon.png [email protected] ios/undefined/Resources/icons
Args: fff icon.png icon-50.png ios/undefined/Resources/icons
Args: fff icon.png [email protected] ios/undefined/Resources/icons
Args: fff icon.png icon-60.png ios/undefined/Resources/icons
Args: fff icon.png icon-72.png ios/undefined/Resources/icons
Args: fff icon.png [email protected] ios/undefined/Resources/icons
Args: fff icon.png icon-76.png ios/undefined/Resources/icons
Args: fff icon.png [email protected] ios/undefined/Resources/icons
Args: fff icon.png icon-small.png ios/undefined/Resources/icons
Args: fff icon.png [email protected] ios/undefined/Resources/icons
Args: fff icon.png icon.png ios/undefined/Resources/icons
Args: fff icon.png [email protected] ios/undefined/Resources/icons
Args: fff splash.png Default-568h@2x~iphone.png ios/undefined/Resources/splash
Args: fff splash.png Default-Landscape@2x~ipad.png ios/undefined/Resources/splash
Args: fff splash.png Default-Landscape~ipad.png ios/undefined/Resources/splash
Args: fff splash.png Default-Portrait@2x~ipad.png ios/undefined/Resources/splash
Args: fff splash.png Default-Portrait~ipad.png ios/undefined/Resources/splash
Args: fff splash.png Default@2x~iphone.png ios/undefined/Resources/splash
Args: fff splash.png Default~iphone.png ios/undefined/Resources/splash
Args: fff icon.png icon.png android/res/drawable
Args: fff icon.png icon.png android/res/drawable-hdpi
Args: fff splash.png screen.png android/res/drawable-land-hdpi
Args: fff splash.png screen.png android/res/drawable-land-ldpi
Args: fff splash.png screen.png android/res/drawable-land-mdpi
Args: fff splash.png screen.png android/res/drawable-land-xhdpi
Args: fff icon.png icon.png android/res/drawable-ldpi
Args: fff icon.png icon.png android/res/drawable-mdpi

failed at install time

Here is what i see in my terminal:
$ npm install -g cordova-media-generator
npm WARN deprecated [email protected]: v1 is no longer maintained, please upgrade to v2.0+ as soon possible.
npm WARN deprecated [email protected]: use cross-spawn or cross-spawn-async instead.
/usr/local/bin/mediagen -> /usr/local/lib/node_modules/cordova-media-generator/media-gen.js

[email protected] install /usr/local/lib/node_modules/cordova-media-generator/node_modules/dnode/node_modules/weak
node-gyp rebuild

CXX(target) Release/obj.target/weakref/src/weakref.o
SOLINK_MODULE(target) Release/weakref.node

[email protected] install /usr/local/lib/node_modules/cordova-media-generator/node_modules/weak
node-gyp rebuild

CXX(target) Release/obj.target/weakref/src/weakref.o
In file included from ../src/weakref.cc:19:
In file included from ../node_modules/nan/nan.h:74:
In file included from ../node_modules/nan/nan_new.h:181:
../node_modules/nan/nan_implementation_12_inl.h:172:66: error: too many arguments to function call, expected at most 2, have 4
return v8::Signature::New(v8::Isolate::GetCurrent(), receiver, argc, argv);
~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~
/Users/rogovm/.node-gyp/6.2.2/include/node/v8.h:4798:3: note: 'New' declared here
static Local New(
^
In file included from ../src/weakref.cc:19:
../node_modules/nan/nan.h:165:25: error: redefinition of '_NanEnsureLocal'
NAN_INLINE v8::Local _NanEnsureLocal(v8::Local val) {
^
../node_modules/nan/nan.h:160:25: note: previous definition is here
NAN_INLINE v8::Local _NanEnsureLocal(v8::Handle val) {
^
../node_modules/nan/nan.h:253:12: error: no matching function for call to '_NanEnsureLocal'
return NanEscapeScope(NanNew(v8::Undefined(v8::Isolate::GetCurrent())));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:239:43: note: expanded from macro 'NanEscapeScope'

define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))

                                      ^~~~~~~~~~~~~~~

../node_modules/nan/nan.h:165:25: note: candidate template ignored: substitution failure [with T = v8::Primitive]
NAN_INLINE v8::Local _NanEnsureLocal(v8::Local val) {
^
../node_modules/nan/nan.h:258:12: error: no matching function for call to '_NanEnsureLocal'
return NanEscapeScope(NanNew(v8::Null(v8::Isolate::GetCurrent())));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:239:43: note: expanded from macro 'NanEscapeScope'

define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))

                                      ^~~~~~~~~~~~~~~

../node_modules/nan/nan.h:165:25: note: candidate template ignored: substitution failure [with T = v8::Primitive]
NAN_INLINE v8::Local _NanEnsureLocal(v8::Local val) {
^
../node_modules/nan/nan.h:263:12: error: no matching function for call to '_NanEnsureLocal'
return NanEscapeScope(NanNew(v8::True(v8::Isolate::GetCurrent())));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:239:43: note: expanded from macro 'NanEscapeScope'

define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))

                                      ^~~~~~~~~~~~~~~

../node_modules/nan/nan.h:165:25: note: candidate template ignored: substitution failure [with T = v8::Boolean]
NAN_INLINE v8::Local _NanEnsureLocal(v8::Local val) {
^
../node_modules/nan/nan.h:268:12: error: no matching function for call to '_NanEnsureLocal'
return NanEscapeScope(NanNew(v8::False(v8::Isolate::GetCurrent())));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:239:43: note: expanded from macro 'NanEscapeScope'

define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))

                                      ^~~~~~~~~~~~~~~

../node_modules/nan/nan.h:165:25: note: candidate template ignored: substitution failure [with T = v8::Boolean]
NAN_INLINE v8::Local _NanEnsureLocal(v8::Local val) {
^
../node_modules/nan/nan.h:312:20: error: no type named 'GCEpilogueCallback' in 'v8::Isolate'
v8::Isolate::GCEpilogueCallback callback
~~~~~~~~~~~~~^
../node_modules/nan/nan.h:318:20: error: no type named 'GCEpilogueCallback' in 'v8::Isolate'
v8::Isolate::GCEpilogueCallback callback) {
~~~~~~~~~~~~~^
../node_modules/nan/nan.h:323:20: error: no type named 'GCPrologueCallback' in 'v8::Isolate'
v8::Isolate::GCPrologueCallback callback
~~~~~~~~~~~~~^
../node_modules/nan/nan.h:329:20: error: no type named 'GCPrologueCallback' in 'v8::Isolate'
v8::Isolate::GCPrologueCallback callback) {
~~~~~~~~~~~~~^
../node_modules/nan/nan.h:500:13: error: no member named 'smalloc' in namespace 'node'
, node::smalloc::FreeCallback callback
~~~~~~^
../node_modules/nan/nan.h:511:12: error: no matching function for call to 'New'
return node::Buffer::New(v8::Isolate::GetCurrent(), data, size);
^~~~~~~~~~~~~~~~~
/Users/rogovm/.node-gyp/6.2.2/include/node/node_buffer.h:46:40: note: candidate function not viable: 2nd argument ('const char ')
would lose const qualifier
NODE_EXTERN v8::MaybeLocalv8::Object New(v8::Isolate
isolate,
^
/Users/rogovm/.node-gyp/6.2.2/include/node/node_buffer.h:34:40: note: candidate function not viable: no known conversion from
'const char ' to 'v8::Localv8::String' for 2nd argument
NODE_EXTERN v8::MaybeLocalv8::Object New(v8::Isolate
isolate,
^
/Users/rogovm/.node-gyp/6.2.2/include/node/node_buffer.h:31:40: note: candidate function not viable: requires 2 arguments, but 3 were
provided
NODE_EXTERN v8::MaybeLocalv8::Object New(v8::Isolate* isolate, size_t length);
^
/Users/rogovm/.node-gyp/6.2.2/include/node/node_buffer.h:39:40: note: candidate function not viable: requires 5 arguments, but 3 were
provided
NODE_EXTERN v8::MaybeLocalv8::Object New(v8::Isolate* isolate,
^
In file included from ../src/weakref.cc:19:
../node_modules/nan/nan.h:515:12: error: no viable conversion from returned value of type 'v8::MaybeLocalv8::Object' to function
return type 'v8::Localv8::Object'
return node::Buffer::New(v8::Isolate::GetCurrent(), size);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/rogovm/.node-gyp/6.2.2/include/node/v8.h:216:7: note: candidate constructor (the implicit copy constructor) not viable: no
known conversion from 'v8::MaybeLocalv8::Object' to 'const v8::Localv8::Object &' for 1st argument
class Local {
^
/Users/rogovm/.node-gyp/6.2.2/include/node/v8.h:216:7: note: candidate constructor (the implicit move constructor) not viable: no
known conversion from 'v8::MaybeLocalv8::Object' to 'v8::Localv8::Object &&' for 1st argument
/Users/rogovm/.node-gyp/6.2.2/include/node/v8.h:220:13: note: candidate template ignored: could not match 'Local' against 'MaybeLocal'
V8_INLINE Local(Local that)
^
In file included from ../src/weakref.cc:19:
../node_modules/nan/nan.h:522:26: error: no member named 'Use' in namespace 'node::Buffer'
return node::Buffer::Use(v8::Isolate::GetCurrent(), data, size);
~~~~~~~~~~~~~~^
../node_modules/nan/nan.h:1339:12: error: no matching function for call to '_NanEnsureLocal'
return NanEscapeScope(NanNew(handle)->Get(kCallbackIndex)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:239:43: note: expanded from macro 'NanEscapeScope'

define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))

                                      ^~~~~~~~~~~~~~~

../node_modules/nan/nan.h:165:25: note: candidate template ignored: substitution failure [with T = v8::Function]
NAN_INLINE v8::Local _NanEnsureLocal(v8::Local val) {
^
../node_modules/nan/nan.h:1354:12: error: no matching function for call to '_NanEnsureLocal'
return NanEscapeScope(node::MakeCallback(
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:239:43: note: expanded from macro 'NanEscapeScope'

define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))

                                      ^~~~~~~~~~~~~~~

../node_modules/nan/nan.h:165:25: note: candidate template ignored: substitution failure [with T = v8::Value]
NAN_INLINE v8::Local _NanEnsureLocal(v8::Local val) {
^
../node_modules/nan/nan.h:1427:12: error: no matching function for call to '_NanEnsureLocal'
return NanEscapeScope(handle->Get(NanNew(key)).Asv8::Object());
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:239:43: note: expanded from macro 'NanEscapeScope'

define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))

                                      ^~~~~~~~~~~~~~~

../node_modules/nan/nan.h:165:25: note: candidate template ignored: substitution failure [with T = v8::Object]
NAN_INLINE v8::Local _NanEnsureLocal(v8::Local val) {
^
17 errors generated.
make: *** [Release/obj.target/weakref/src/weakref.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
gyp ERR! System Darwin 15.4.0
gyp ERR! command "/usr/local/Cellar/node/5.7.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/cordova-media-generator/node_modules/weak
gyp ERR! node -v v6.2.2
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
/usr/local/lib
└── (empty)

npm ERR! Darwin 15.4.0
npm ERR! argv "/usr/local/Cellar/node/5.7.0/bin/node" "/usr/local/bin/npm" "install" "-g" "cordova-media-generator"
npm ERR! node v6.2.2
npm ERR! npm v3.9.5
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the weak package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs weak
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls weak
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /Users/rogovm/Projects/reverse/npm-debug.log
npm ERR! code 1

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.