1.0.3 • Published 3 years ago
@skg-global/sharp_client v1.0.3
Install
$ yarn add @skg-global/sharp_client
Client integration
You can be used to generate URLs for images.
import { createClient } from '@skg-global/sharp_client';
const client = createClient('http://example.com/base', 'sample-bucket');
const originalImageUrl = 'demo.png';
const options = {
resize: { width: 200, fit: 'cover' },
};
const fooUrl = client.url(originalImageUrl, options);
--> http://example.com/base/eyJidWNrZXQiOiJzYW1wbGUtYnVja2V0Iiwia2V5IjoiZGVtby5qcGVnIiwiZWRpdHMiOnsicmVzaXplIjp7IndpZHRoIjoyMDAsImZpdCI6ImNvdmVyIn19fQ==
Currently the following transformations can be applied to images:
Client option name | Query param name | Description |
---|---|---|
resize.width | ||
resize.height | ||
toFormat | Output image format. Valid values: every valid sharp output format string, i.e. jpeg , gif , webp . | |
rotate | Rotate the output image by either an explicit angle or auto-orient based on the EXIF sharp cropping feature. | |
flip | Flip the image about the vertical Y axis sharp flip feature. | |
flop | Flop the image about the vertical X axis sharp flop feature. | |
smartCrop | (optional, object) activates the smart cropping feature for an original image (Amazon Rekognition) |