GithubHelp home page GithubHelp logo

dkaoster / rollup-plugin-generate-image-sizes Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 1.0 457 KB

Automatically generate multiple sizes of images using rollup.

License: MIT License

JavaScript 100.00%
rollup image resize

rollup-plugin-generate-image-sizes's Introduction

rollup-plugin-generate-image-sizes

Useful for when you want to automatically resize images for use in a srcset / other responsive web design implementations.

Installation

npm i -D rollup-plugin-generate-image-sizes

Usage

// rollup.config.js
import { generateImageSizes } from 'rollup-plugin-generate-image-sizes';

export default {
  plugins: [
    generateImageSizes({
      dir: 'static',
      size: [1400, 1024, 640, 320],
      hook: 'renderStart',
      quality: 65,
      inputFormat: ['jpg', 'jpeg', 'png'],
      outputFormat: ['jpg'],
      forceUpscale: false,
      skipExisting: true,
      maxParallel: 4,
      outputManifest: 'static/images-manifest.json'
    })
  ]
}

Note: All output files are named in the pattern <original-filename>@<size>w.<file-extension>. The plugin looks for the @ symbol to determine which files have already been converted, which means that all files with the @ will be ignored. Files with # are also ignored.

Configuration

dir (required | string or [string]) the string or array of strings specifying the directory where the images we want to resize are.

size (default: [1400, 1024, 640, 320] | int or [int]) An integer or array of integers specifying the width in pixels of our output image.

hook (default: renderStart) the rollup hook that this plugin should use.

quality (default: 65 | int): The quality of output images, for image formats that have output quality controls.

inputFormat (default: ['jpg', 'jpeg', 'png'] | string or [string]): The file extensions of the images we care about. Must be a format supported by jimp, or match, which matches the input format of the image.

outputFormat (default: 'jpg' | string or [string]): The file extensions of the images we want to output. Must be a format supported by jimp or match, which is used to match the input format.

forceUpscale (default: false | boolean): If the source image is larger, do we want to forcibly generate a scaled up version or whether we should just ignore it.

skipExisting (default: true | boolean): whether we should skip existing images that have already been resized. a false value means that images will be regenerated and overwritten every single time this script is run.

maxParallel (default: 4 | int): the max number of parallel images that can be processed concurrently.

outputManifest (default: null | string): the file to output a json containing all the images this plugin generated.

License

MIT

rollup-plugin-generate-image-sizes's People

Contributors

dependabot[bot] avatar dkaoster avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

262media

rollup-plugin-generate-image-sizes's Issues

Add support for larger files

I had an issue with generating a file that was 12mb (others under 12mb worked fine). Kept getting this error:

maxMemoryUsageInMB limit exceeded by at least ${exceededAmount}MB

Is it possible to support larger size images as an option? Only way to circumvent this is to heavily either scale down the original image or to reduce the quality too low..

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.