npm.io
0.0.5 • Published 5 years ago

@dylanvann/convert-image

Licence
MIT
Version
0.0.5
Deps
8
Size
35 kB
Vulns
3
Weekly
0
Stars
5

convert

This converts images and videos into a suitable format for FastImage.

  • We use sharp for images.
  • We use ffmpeg for videos.
  • Conversions are cached to speed things up.

This package allows you to specify multiple output formats at the same time. This can be done to speed up conversion.

Installation

yarn add fast-image-convert

Usage

import { convert } from 'fast-image-convert'

const myOutput = await convert('./my-image.mp4', {
    inputFile: 'myImage.png',
    outputFolder: 'public',
    conversions: [
        { format: 'png', width: 500, quality: 80 },
        { format: 'webp', width: 500, quality: 80 },
        { format: 'jpeg', width: 500, quality: 80 },
        { format: 'mp4', width: 500, quality: 80 },
    ],
})

const myOutput = [
    {
        output: 'public/12345.png',
        width: 500,
        height: 300,
    },
    {
        output: 'public/12345.webp',
        width: 500,
        height: 300,
    },
    {
        output: 'public/12345.jpeg',
        width: 500,
        height: 300,
    },
    {
        output: '12345',
        width: 500,
        height: 300,
    },
    {
        output: 'public/12345.mp4',
        width: 500,
        height: 300,
    },
]

Keywords