0.0.5 • Published 4 years ago

@dylanvann/convert-image v0.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

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,
    },
]