image.filter
Run the rest of the branch only when the input matches format. Otherwise bytes pass through unchanged.
Config
type ImageFilterConfig = {
format: 'png' | 'jpg' | 'webp' | 'gif' | 'avif' | 'tiff'; // default 'jpg'
};Example
// pipeline
{
id: 'only-png',
type: 'image.filter',
config: { format: { value: 'png' } },
}
// queue
tk.runQueue(files, 'image')
.filter({ format: 'png' })
.maxSize(1600)
.convert({ format: 'webp' });Place the filter before resize or convert on that branch.