4.9 KiB
format
An Object containing nested boolean values representing the available input and output formats/methods.
Examples
console.log(sharp.format);
Returns Object
interpolators
An Object containing the available interpolators and their proper values
Type: string
nearest
Nearest neighbour interpolation. Suitable for image enlargement only.
bilinear
Bilinear interpolation. Faster than bicubic but with less smooth results.
bicubic
Bicubic interpolation (the default).
locallyBoundedBicubic
LBB interpolation. Prevents some "acutance" but typically reduces performance by a factor of 2.
nohalo
Nohalo interpolation. Prevents acutance but typically reduces performance by a factor of 3.
vertexSplitQuadraticBasisSpline
VSQBS interpolation. Prevents "staircasing" when enlarging.
versions
An Object containing the version numbers of libvips and its dependencies.
Examples
console.log(sharp.versions);
cache
Gets or, when options are provided, sets the limits of libvips' operation cache. Existing entries in the cache will be trimmed after any change in limits. This method always returns cache statistics, useful for determining how much working memory is required for a particular task.
Parameters
options
(Object | boolean) Object with the following attributes, or boolean where true uses default cache settings and false removes all caching (optional, defaulttrue
)
Examples
const stats = sharp.cache();
sharp.cache( { items: 200 } );
sharp.cache( { files: 0 } );
sharp.cache(false);
Returns Object
concurrency
Gets or, when a concurrency is provided, sets the number of threads libvips' should create to process each image.
The default value is the number of CPU cores,
except when using glibc-based Linux without jemalloc,
where the default is 1
to help reduce memory fragmentation.
A value of 0
will reset this to the number of CPU cores.
The maximum number of images that can be processed in parallel
is limited by libuv's UV_THREADPOOL_SIZE
environment variable.
This method always returns the current concurrency.
Parameters
concurrency
number?
Examples
const threads = sharp.concurrency(); // 4
sharp.concurrency(2); // 2
sharp.concurrency(0); // 4
Returns number concurrency
queue
An EventEmitter that emits a change
event when a task is either:
- queued, waiting for libuv to provide a worker thread
- complete
Examples
sharp.queue.on('change', function(queueLength) {
console.log('Queue contains ' + queueLength + ' task(s)');
});
counters
Provides access to internal task counters.
- queue is the number of tasks this module has queued waiting for libuv to provide a worker thread from its pool.
- process is the number of resize tasks currently being processed.
Examples
const counters = sharp.counters(); // { queue: 2, process: 4 }
Returns Object
simd
Get and set use of SIMD vector unit instructions. Requires libvips to have been compiled with liborc support.
Improves the performance of resize
, blur
and sharpen
operations
by taking advantage of the SIMD vector unit of the CPU, e.g. Intel SSE and ARM NEON.
Parameters
simd
boolean (optional, defaulttrue
)
Examples
const simd = sharp.simd();
// simd is `true` if the runtime use of liborc is currently enabled
const simd = sharp.simd(false);
// prevent libvips from using liborc at runtime
Returns boolean