s3img
is a CLI tool based on Node.JS. Its original purpose is to convert and process images using ImageMagick and to
upload those images to Amazon S3. The intention behind this is to provide different image resultions (thumbnails, preview, fullscale, etc.)
for online shop systems.
The configuration file includes various options.
{
"s3": {
"keyid" : "your-key-id",
"secret" : "your-key-secret",
"bucket" : "bucket name",
"region" : "your region"
},
"cache" : 315360000,
"acl" : "public-read",
"extension" : ".jpg",
"threads" : 1,
"convertbin" : "convert",
"resizecmd" : "%convertbin% %input% -trim -geometry %dimensions% -gravity center -background %bgcolor% -extent %dimensions% %output%",
"sizes": {
"thumb" : [64, 50, "%convertbin% %input% -thumbnail %dimensions%^ -gravity center -extent %dimensions% %output%"],
"preview" : [165, 165],
"full" : [370, 370],
"lightbox" : [1000, 1000]
},
"dir" : "./",
"source" : "./src",
"magick": [
"command1 %output%"
]
}
- The
s3
object containse the access information for Amazon S3. convertbin
is the ImageMagick binary used for the convertion processresizecmd
specifies the default resize command. The following replacement options exist:input
: The input file pathoutput
: The output file pathsource
: The source directorytarget
: The target directoryconvertbin
: The convert commandbgcolor
: The background fill color. If not specified, the color of the first pixel will be used.dimensions
: The dimensions
sizes
specifies an object consisting of the target with and height. An optional third parameter can be used to specify a customresizecmd
source
points to the source directorytarget
points to the target directorymagic
is an array consisting of addtional commands that will be executed after the convertion operation. You can use the same variables as inresizecmd
s3img [OPTIONS]
CLI Options:
Parameter | Type | Description |
---|---|---|
help | boolean | Show help |
config | string | Configuration file (Type "s3img --config --help" for more) |
keyid | string | S3 key ID |
secret | string | S3 key secret |
bucket | string | S3 bucket ID |
region | string | S3 region (see https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region) |
dir | string | The image directory |
source | string | The source directory for the original images |
upload | bool/string | Push images to S3 |
convert | bool/string | Convert images |
overwrite | bool | Overwrite existing images (default: skip) |
threads | number | Number of parallel AWS threads (default: 1) |
Convert all images:
s3img -c ./config.json --convert
Convert a specific image set:
s3img -c ./config.json --convert=thumb
Upload all images:
s3img -c ./config.json --upload
Upload a specific image set:
s3img -c ./config.json --upload=thumb
Node.js with NPM (Tested with Node Version 0.10.22)
- request: ~2.27.0
- nopt: ~2.1.2
- aws-sdk: ~2.0
- mime: ~1.2
- underscore: ~1.6.0
- dateformat: ~1.0
This work is licensed under the GNU Lesser General Public License (LGPL). You may also get a copy of the GNU Lesser General Public License from https://www.gnu.org/licenses/lgpl.txt.