npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

gulp-retinate

v1.1.2

Published

Automated retina down-scaling from @2x and @4x

Readme

gulp-retinate

npm version build status

Effortlessly scale and optimize images for retina and non-retina screens with this powerful Gulp plugin.

Automate the generation of multiple image resolutions (1x, 2x, 4x) for responsive web design, eliminating manual image duplication and ensuring pixel-perfect rendering across all devices.

Why gulp-retinate?

  • Lightning-fast — Built on Sharp for superior performance
  • Lightweight — Fewer dependencies than alternatives like GraphicsMagick
  • Developer-friendly — Simple configuration with sensible defaults
  • Flexible — Customize flags, placement, and scaling behavior
  • Production-ready — Battle-tested with comprehensive test coverage

Related Projects: posthtml-retinate — HTML processing for retina images

Installation

npm install gulp gulp-retinate

Quick Start

Create a simple Gulp task to transform your images:

const gulp = require("gulp");
const retinate = require("gulp-retinate");

gulp.task("images", function () {
  return gulp
    .src("./src/**/*.{png,jpg,jpeg}")
    .pipe(retinate())
    .on("error", (e) => console.log(e.message))
    .pipe(gulp.dest("./dest/"));
});

That's it! Your [email protected] becomes [email protected] and image.png in the output.

Usage with Custom Options

For advanced image handling, configure the plugin to match your workflow:

const gulp = require("gulp");
const retinate = require("gulp-retinate");

const retinateOptions = {
  inputFlags: { 1: "@1x", 2: "@2x", 4: "@4x" },
  inputPlace: "endsWith",
  outputFlags: { 1: "", 2: "@2x", 4: "@4x" },
  outputPlace: "append",
  rounding: "ceil",
  scaleUp: false,
};

gulp.task("images", function () {
  return gulp
    .src("./src/**/*.{png,jpg,jpeg}")
    .pipe(retinate(retinateOptions))
    .on("error", (e) => console.log(e.message))
    .pipe(gulp.dest("./dest/"));
});

Configuration

All options are optional and come with sensible defaults. Customize them to match your image naming conventions.

inputFlags

Specifies how to identify different resolution versions in your source files.

| Property | Details | | ----------- | ---------------------------------- | | Type | Object<number, string> | | Default | { 1: '@1x', 2: '@2x', 4: '@4x' } | | Since | 1.0.0 | | Example | { 1: '', 2: '@2x', 4: '@4x' } |

The key is the output resolution (1, 2, or 4), and the value is the flag to detect in source filenames. For example, [email protected] or image-2x.png.

inputPlace

Determines where the input flag appears in your source filenames.

| Property | Details | | ----------- | ------------------------------ | | Type | string | | Default | 'endsWith' | | Options | 'startsWith' | 'endsWith' | | Since | 1.0.0 |

Examples:

outputFlags

Specifies the flags to add to destination filenames after scaling.

| Property | Details | | ----------- | ------------------------------- | | Type | Object<number, string> | | Default | { 1: '', 2: '@2x', 4: '@4x' } | | Since | 1.0.0 |

Similar to inputFlags. The key is the target resolution, and the value is what gets added to the output filename.

outputPlace

Determines where the output flag appears in destination filenames.

| Property | Details | | ----------- | ------------------------- | | Type | string | | Default | 'append' | | Options | 'prepend' | 'append' | | Since | 1.0.0 |

Examples:

rounding

Controls how fractional pixel dimensions are handled during scaling.

| Property | Details | | ----------- | --------------------- | | Type | string | | Default | 'ceil' | | Options | 'ceil' | 'floor' | | Since | 1.0.0 |

When scaling creates fractional dimensions, this option determines rounding behavior.

Example: A 35x35px image at @2x scaled to 1x resolution:

  • 'ceil': Rounds to 18x18px (✓ slightly larger, safer)
  • 'floor': Rounds to 17x17px (slightly smaller)

scaleUp

Whether to generate larger resolutions when only smaller source images exist.

| Property | Details | | ----------- | --------- | | Type | boolean | | Default | false | | Since | 1.0.0 |

If you only have [email protected], enabling this will generate [email protected] and [email protected] (upscaled).

Example: With scaleUp: true, a single [email protected] produces:

[email protected] (original)
[email protected] (upscaled 2x)
[email protected] (upscaled 4x)

Examples

Default Configuration

Source file: [email protected] (800x600px)

gulp
  .src("./src/**/*.{png,jpg,jpeg}")
  .pipe(retinate()) // Uses defaults
  .pipe(gulp.dest("./dest/"));

Output:

  • hero.png (400x300px) — Standard resolution
  • [email protected] (800x600px) — Retina resolution

Custom Naming Convention

If your sources use dashes instead of @:

gulp
  .src("./src/**/*.{png,jpg,jpeg}")
  .pipe(
    retinate({
      inputFlags: { 1: "-1x", 2: "-2x", 4: "-4x" },
      outputFlags: { 1: "", 2: "-2x", 4: "-4x" },
    }),
  )
  .pipe(gulp.dest("./dest/"));

Source: banner-2x.png → Output: banner.png, banner-2x.png

Related Projects

  • posthtml-retinate — Process HTML files with retina image attributes
  • gulp-retinize — Original inspiration for this project
  • Sharp — The powerful image processing library powering gulp-retinate