7.0.0 • Published 1 month ago

imagetools-core v7.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

imagetools-core

npm (tag) standard-readme compliant codecov

A toolbox of import directives that can transform your image at compile-time. All of the image transformations are powered by sharp.

This package holds all transforms and core utility functions needed to integrate imagetools with any builtool, or to create a standalone transformation server!

Read the docs to learn more!

Table of Contents

Install

npm install imagetools-core

Usage

import { loadImage, applyTransforms, builtins, generateTransforms } from 'imagetools-core'

// loadImageFromDisk is a utility function that creates a sharp instances of the specified image
const image = loadImage('./example.jpg')

// our image configuration
const config = {
  width: '400',
  height: '300',
  format: 'webp'
}

// This function takes our config and an array of transformFactories and creates an array of transforms
// the resulting array of transforms can be cached
const { transforms, warnings } = generateTransforms(config, builtins)

// apply the transforms and transform the given image
const { image: transformedImage, metadata } = await applyTransforms(transforms, image)

transformedImage // a sharp instance of the transformed image
metadata // the image metadata produced by the transforms
import { parseURL, resolveConfigs } from 'imagetools-core'

const src = new URL('file:///example.jpg?w=300;500;700&format=webp')

// parses the url query parameters into an array of entries
const parameters = parseURL(src)

// this function handles the ArgumentList logic
// and produces an array of config objects that can be passed to generateTransforms
const configs = resolveConfigs(parameters)

Contributing

Feel free to dive in! Open an issue or submit PRs! All information to get you started hacking on imagetools is in CONTRIBUTING.md!

License

MIT © Jonas Kruckenberg.

7.0.0

1 month ago

6.0.4

4 months ago

5.1.1

6 months ago

5.1.0

7 months ago

6.0.1

6 months ago

6.0.0

6 months ago

6.0.3

5 months ago

6.0.2

5 months ago

5.0.0

7 months ago

4.0.6

7 months ago

4.1.0

7 months ago

4.0.5

9 months ago

4.0.4

10 months ago

4.0.3

12 months ago

4.0.1

1 year ago

4.0.0

1 year ago

4.0.2

1 year ago

3.3.1

1 year ago

3.3.0

1 year ago

3.2.2

2 years ago

3.2.3

2 years ago

3.2.1

2 years ago

3.2.0

2 years ago

3.1.1

2 years ago

3.1.0

2 years ago

3.0.3

2 years ago

3.0.2

2 years ago

3.0.1

2 years ago

3.0.0

2 years ago

2.8.0

3 years ago

2.7.6

3 years ago

2.3.0

3 years ago

2.2.0

3 years ago

2.5.0

3 years ago

2.3.2

3 years ago

2.3.1

3 years ago

2.7.0

3 years ago

2.6.0

3 years ago

2.3.3

3 years ago

2.7.2

3 years ago

2.7.1

3 years ago

2.1.0

3 years ago

2.7.4

3 years ago

2.7.3

3 years ago

2.7.5

3 years ago

0.1.0

3 years ago

0.1.0-next.16

3 years ago

0.1.0-next.15

3 years ago

0.1.0-next.14

3 years ago

0.1.0-next.13

3 years ago

0.1.0-next.12

3 years ago

0.1.0-next.9

3 years ago

0.1.0-next.11

3 years ago

0.1.0-next.10

3 years ago

0.1.0-next.8

3 years ago

0.1.0-next.7

3 years ago

0.1.0-next.6

3 years ago

0.1.0-next.4

3 years ago

0.1.0-next.2

3 years ago