Console tool for batch generation of images using ImageMagick.
For now, this is a "private" project, e.g. it is very specific to my needs and is not targeted towards general use. You can still do whatever you want with it if you find it useful.
I, personally, am going to use this tool to generate template / theme covers and thumbnails, thus those will be the built-in bundles you'll find. You can always make your own bundles.
- PHP 5.5 or later with the
php
command globally available in the console. - ImageMagick installed and properly configured.
- The
convert
command globally available in the console.
Using NPM
npm install --save TonyBogdanov/imager
Using Bower
bower install --save TonyBogdanov/imager
To install the tool manually simply download build/imager.phar
.
Open your favourite console and run the following:
php imager.phar init
This will start an interactive wizard which will help you create a imager.json
file with information on
what operations to perform.
Once you have the file you'll be able to call:
php imager.phar generate path/to/imager.json
or simply
php imager.phar generate
from the same directory.
Keep in mind that any relative paths you set in the imager.json
file will be relative to the directory from which
you run the generate
command, NOT to the directory where the imager.json
file is located.
As a recommendation you should always run the commands in the directory of imager.json
or use absolute paths.
Say you've installed Imager to your project as a NPM dependency. Now you can simply add:
"image": "cd build/imager & imager generate -vv"
to your package.json
file to automate the image generation even further.
Now you will have a NPM script called image
, which you can run via:
npm run image
When run, the console will cd
to the build/imager
directory and execute the imager generate -vv
command.
In this example we assume you have a imager.json
file in build/imager
.
As far as imager
is concerned, build/imager
will also be the current working directory.
The path we cd
into must be relative to where your package.json
file is located. NodeJS makes it easier by always
running from the directory of your package.json
, which means you can run npm run image
even from a sub-directory.