Skip to main content

Thumbnail

Generate a smaller preview image from an image, video, or document.

File-first

thumbnail() requires both width and height. The fit option (max / crop / scale) controls how the source is fitted to those dimensions. Omitting either is rejected with a GislConfigError before any upload — there is no wasted round trip.

const result = await client
.file('./photo.jpg')
.thumbnail({ width: 200, height: 200 })
.run({ maxWait: '5m' });

console.log(result.url);

Chaining

Thumbnail the output of a prior step in the same workflow — for example, compress first, then thumbnail the compressed result:

import { OptimizeFor } from '@giveitsmaller/sdk';

const result = await client
.file('./photo.jpg')
.compress(OptimizeFor.Size)
.thumbnail({ width: 200, height: 200 })
.run({ maxWait: '5m' });

See also