Socket
Socket
Sign inDemoInstall

imagemin-avif

Package Overview
Dependencies
2
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

imagemin-avif

> Avif [imagemin](https://github.com/imagemin/imagemin) plugin. Uses [sharp](https://github.com/lovell/sharp).


Version published
Weekly downloads
1.5K
increased by72.81%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

imagemin-avif

Avif imagemin plugin. Uses sharp.

Usage

const imagemin = require('imagemin');
const imageminAvif = require('imagemin-avif');

(async () => {
  await imagemin(['images/*.{jpg,png}'], {
    destination: 'build/images',
    plugins: [
      imageminAvif({quality: 50})
    ]
  });
})();

How to use with Gulp

import gulp from "gulp";
import imagemin from "gulp-imagemin";
import avif from "imagemin-avif";
import gulpIf from "gulp-if";
import rename from "gulp-rename";

import config from "./gulpconfig";

// your code here

function buildImagesAvif(images, force) {
  const isForce = typeof force !== "undefined" ? force : false;
  return gulp
    .src(images, { base: config.path.src.img })
    .pipe(gulpIf(!isForce, changed(config.path.dst.img)))
    .pipe(imagemin([avif({ quality: 50 })]))
    .pipe(rename((path) => (path.extname += ".avif")))
    .pipe(gulp.dest(config.path.dst.img));
}

const imagesAvif = () => {
  return buildImagesAvif(`${config.path.src.img}**/*.*`);
};

export {
    imagesAvif,
    // your other tasks here
};

API

imageminAvif(options?)

options

Type: object

quality

Type: number
Default: 90

Set quality factor between 0 and 100.

lossless

Type: booleand
Default: false

Use lossless compression mode.

speed

Type: number
Default: 5

CPU effort vs file size, between 0 (slowest/smallest) and 8 (fastest/largest).

chromaSubsampling

Type: number
Default: 4:2:0

Set to 4:4:4 to prevent chroma subsampling (requires libvips v8.11.0) otherwise defaults to 4:2:0 chroma subsampling.

Keywords

FAQs

Last updated on 24 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc