lovell/sharp · error · Error
Only gaussian noise is supported at the moment
Error message
Only gaussian noise is supported at the moment
What it means
Thrown when create.noise.type is defined but is not the string 'gaussian'. Sharp's noise generator currently implements only gaussian noise, so any other type value (including typos like 'Gaussian' with wrong case, 'uniform', 'random', or a non-string) is rejected. The check is a strict inequality against 'gaussian'.
Source
Thrown at lib/input.mjs:356
inputDescriptor.createChannels = inputOptions.create.channels;
inputDescriptor.createPageHeight = 0;
if (is.defined(inputOptions.create.pageHeight)) {
if (is.integer(inputOptions.create.pageHeight) && inputOptions.create.pageHeight > 0 && inputOptions.create.pageHeight <= inputOptions.create.height) {
if (inputOptions.create.height % inputOptions.create.pageHeight !== 0) {
throw new Error(`Expected create.height ${inputOptions.create.height} to be a multiple of create.pageHeight ${inputOptions.create.pageHeight}`);
}
inputDescriptor.createPageHeight = inputOptions.create.pageHeight;
} else {
throw is.invalidParameterError('create.pageHeight', 'positive integer', inputOptions.create.pageHeight);
}
}
// Noise
if (is.defined(inputOptions.create.noise)) {
if (!is.object(inputOptions.create.noise)) {
throw new Error('Expected noise to be an object');
}
if (inputOptions.create.noise.type !== 'gaussian') {
throw new Error('Only gaussian noise is supported at the moment');
}
inputDescriptor.createNoiseType = inputOptions.create.noise.type;
if (!is.inRange(inputOptions.create.channels, 1, 4)) {
throw is.invalidParameterError('create.channels', 'number between 1 and 4', inputOptions.create.channels);
}
inputDescriptor.createNoiseMean = 128;
if (is.defined(inputOptions.create.noise.mean)) {
if (is.number(inputOptions.create.noise.mean) && is.inRange(inputOptions.create.noise.mean, 0, 10000)) {
inputDescriptor.createNoiseMean = inputOptions.create.noise.mean;
} else {
throw is.invalidParameterError('create.noise.mean', 'number between 0 and 10000', inputOptions.create.noise.mean);
}
}
inputDescriptor.createNoiseSigma = 30;
if (is.defined(inputOptions.create.noise.sigma)) {
if (is.number(inputOptions.create.noise.sigma) && is.inRange(inputOptions.create.noise.sigma, 0, 10000)) {
inputDescriptor.createNoiseSigma = inputOptions.create.noise.sigma;
} else {View on GitHub (pinned to 56676c6918)
Solutions
- Use exactly noise: { type: 'gaussian' } (lowercase).
- If you need a different distribution, generate the noise buffer yourself and pass it as raw input.
- Double-check the spelling and case against the docs.
Example fix
// before
sharp({ create: { width: 100, height: 100, channels: 3, noise: { type: 'uniform' } } })
// after
sharp({ create: { width: 100, height: 100, channels: 3, noise: { type: 'gaussian', mean: 128, sigma: 30 } } }) Defensive patterns
Strategy: validation
Validate before calling
function gaussianCreate(opts) {
if (opts.noise && opts.noise.type !== 'gaussian') {
throw new Error(`Unsupported noise type '${opts.noise.type}'; only 'gaussian' is supported`);
}
return sharp({ create: opts });
} Type guard
function isSupportedNoiseType(type) {
return type === 'gaussian';
} Prevention
- Use exactly 'gaussian' (lowercase).
- For other distributions, generate the buffer externally and pass it as raw input.
- Check the docs before assuming a distribution is supported.
When it happens
Trigger: noise: { type: 'uniform' }, noise: { type: 'Gaussian' } (capital G), noise: { type: 'random' }, or noise: { type: 0 }.
Common situations: Assuming other distributions are supported. Case-sensitivity surprises. Auto-completing or guessing the type name. Copying from a tutorial that referenced an unsupported noise kind.
Related errors
- Expected noise to be an object
- Expected valid noise or background to create a new input ima
- Expected create.height ${inputOptions.create.height} to be a
- Expected valid width, height and channels to create a new in
- Invalid input
AI-assisted analysis of lovell/sharp@56676c6918 (2026-08-13).
Data as JSON: /api/errors/fd9bb47f3b1b116d.
Report an issue: GitHub.