🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

imagemin-avif

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

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).

0.1.6
latest
Source
npm
Version published
Weekly downloads
3.8K
62.73%
Maintainers
1
Weekly downloads
 
Created
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

gulp

FAQs

Package 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