Giter VIP home page Giter VIP logo

batch-convert's Introduction

batch-convert

A small library to convert images and other files e.g. pdf from a source to a target folder in a custom format, size and name. For one source file there can be several new images by providing an array of options.

Installation

npm install batch-convert --save

Usage

var bc = require('batch-convert')
var options = [
    {
        'height': 400,
        'postfix': '_small'
    },
    {
        'height': 1200,
        'postfix': '_big'
    }
];
bc.convert("input", "output", options)

This will copy and convert all images in the folder input to the folder output by creating a small and a big version. The small version will get the postfix '_small' with a height of 400px and the big version with the postfix '_big' and 1200px height. The width will be changed depending on the ratio. By default the output format is jpg with a quality of 100.

Possible Options

{
    'height': [in pixel]                             // Image height
    'width': [in pixel]                              // Image width
    'postfix': [allowed fs characters]               // Postfix for the file name e.g. image.jpg + '_small' = image_small.jpg
    'quality': [0-100], default = 100                // The quality of the image if a compression is used
    'format': [jpg, png, gif, ..., default = 'jpg'   // The format of the image
}

Supported Formats

This library uses GraphicsMagick for conversion. Check http://www.graphicsmagick.org/formats.html to see which import and export formats are supported.

Tests

npm test

Release History

  • 0.1.0 - Initial release
  • 0.1.1 - Typos, default value for output
  • 0.1.2 - Default value for input, jsdoc
  • 0.1.3 - Update doc, fix typos

batch-convert's People

Watchers

Dominik Kaspar avatar

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.