diff --git a/binding.gyp b/binding.gyp index 07cd4865..326dcb60 100644 --- a/binding.gyp +++ b/binding.gyp @@ -95,7 +95,7 @@ 'src/sharp.cc' ], 'include_dirs': [ - '= 90 chroma is never subsampled (optional, default `'4:2:0'`) + - `options.chromaSubsampling` **[string][2]** set to '4:4:4' to prevent chroma subsampling otherwise defaults to '4:2:0' chroma subsampling (optional, default `'4:2:0'`) - `options.optimiseCoding` **[boolean][7]** optimise Huffman coding tables (optional, default `true`) - `options.optimizeCoding` **[boolean][7]** alternative spelling of optimiseCoding (optional, default `true`) - `options.trellisQuantisation` **[boolean][7]** apply trellis quantisation, requires libvips compiled with support for mozjpeg (optional, default `false`) @@ -254,7 +254,7 @@ Use these TIFF options for output image. - `options.tileHeight` **[boolean][7]** vertical tile size (optional, default `256`) - `options.xres` **[number][9]** horizontal resolution in pixels/mm (optional, default `1.0`) - `options.yres` **[number][9]** vertical resolution in pixels/mm (optional, default `1.0`) - - `options.squash` **[boolean][7]** squash 8-bit images down to 1 bit (optional, default `false`) + - `options.bitdepth` **[boolean][7]** reduce bitdepth to 1, 2 or 4 bit (optional, default `8`) ### Examples @@ -263,7 +263,7 @@ Use these TIFF options for output image. sharp('input.svg') .tiff({ compression: 'lzw', - squash: true + bitdepth: 1 }) .toFile('1-bpp-output.tiff') .then(info => { ... }); diff --git a/docs/changelog.md b/docs/changelog.md index c7ef02fd..37503ab3 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,12 +2,16 @@ ## v0.26 - *zoom* -Requires libvips v8.9.2 +Requires libvips v8.10.0 ### v0.26.0 - TBD * Prebuilt libvips binaries are now statically-linked and Brotli-compressed, requiring Node.js 10.16.0+. +* TIFF output `squash` is replaced by `bitdepth` to reduce to 1, 2 or 4 bit. + +* JPEG output `quality` >= 90 no longer automatically sets `chromaSubsampling` to `4:4:4`. + ## v0.25 - *yield* Requires libvips v8.9.1 diff --git a/docs/search-index.json b/docs/search-index.json index d256cdbb..3c9dd339 100644 --- a/docs/search-index.json +++ b/docs/search-index.json @@ -1 +1 @@ -[{"t":"Prerequisites","d":"Node.js v10","k":"prerequisites node","l":"/install#prerequisites"},{"t":"Prebuilt binaries","d":"Ready-compiled sharp and libvips binaries are provided for use with Node.js v10 on the most common platforms macOS x64 10.13 Linux x64 glibc","k":"prebuilt binaries ready compiled sharp libvips binaries provided node most common platforms macos linux glibc","l":"/install#prebuilt-binaries"},{"t":"Common problems","d":"The architecture and platform of Node.js used for npm install must be the same as the architecture and platform of Node.js used at runtime.","k":"common problems architecture platform node used npm install must same architecture platform node used runtime","l":"/install#common-problems"},{"t":"Custom libvips","d":"To use a custom, globally-installed version of libvips instead of the provided binaries, make sure it is at least the version listed under c","k":"custom libvips custom globally installed version libvips instead provided binaries make sure least version listed under","l":"/install#custom-libvips"},{"t":"Building from source","d":"This module will be compiled from source at npm install time when a globally-installed libvips is detected set the SHARP_IGNORE_GLOBAL_LIBVI","k":"building source module compiled source npm install time globally installed libvips detected sharpignoregloballibvi","l":"/install#building-from-source"},{"t":"Custom prebuilt binaries","d":"This is an advanced approach that most people will not require. To install the prebuilt sharp binaries from a custom URL, set the sharp_bina","k":"custom prebuilt binaries advanced approach most people require install prebuilt sharp binaries custom url sharpbina","l":"/install#custom-prebuilt-binaries"},{"t":"Chinese mirror","d":"Alibaba provide a mirror site based in China containing binaries for both sharp and libvips. To use this either set the following configurat","k":"chinese mirror alibaba provide mirror site based china containing binaries both sharp libvips following configurat","l":"/install#chinese-mirror"},{"t":"FreeBSD","d":"The vips package must be installed before npm install is run. sh pkg install -y pkgconf vips sh cd /usr/ports/graphics/vips/ make install cl","k":"freebsd vips package must installed before npm install run pkg install pkgconf vips usr ports graphics vips make install","l":"/install#freebsd"},{"t":"Heroku","d":"Add the jemalloc buildpack to reduce the effects of memory fragmentation. Set NODE_MODULES_CACHE","k":"heroku add jemalloc buildpack reduce effects memory fragmentation nodemodulescache","l":"/install#heroku"},{"t":"AWS Lambda","d":"Set the Lambda runtime to nodejs12.x. The binaries in the node_modules directory of the deployment package must be for the Linux x64 platfor","k":"aws lambda lambda runtime nodejs binaries nodemodules directory deployment package must linux platfor","l":"/install#aws-lambda"},{"t":"Electron","d":"Electron provides versions of the V8 JavaScript engine that are incompatible with Node.js. To ensure the correct binaries are used, run the","k":"electron electron provides versions javascript engine incompatible node ensure correct binaries used run","l":"/install#electron"},{"t":"Sharp","d":"Constructor factory to create an instance of sharp, to which further methods are chained.","k":"sharp constructor factory create instance sharp further methods chained","l":"/api-constructor#sharp"},{"t":"clone","d":"Take a snapshot of the Sharp instance, returning a new instance. Cloned instances inherit the input of their parent instance. This allows mu","k":"clone take snapshot sharp instance returning new instance cloned instances inherit input parent instance allows","l":"/api-constructor#clone"},{"t":"metadata","d":"Fast access to uncached image metadata without decoding any compressed image data. A Promise is returned when callback is not provided.","k":"metadata fast access uncached image metadata without decoding compressed image data promise returned callback provided","l":"/api-input#metadata"},{"t":"stats","d":"Access to pixel-derived image statistics for every channel in the image. A Promise is returned when callback is not provided.","k":"stats access pixel derived image statistics every channel image promise returned callback provided","l":"/api-input#stats"},{"t":"toFile","d":"Write output image data to a file.","k":"tofile write output image data file","l":"/api-output#tofile"},{"t":"toBuffer","d":"Write output to a Buffer. JPEG, PNG, WebP, TIFF and RAW output are supported.","k":"tobuffer write output buffer jpeg png webp tiff raw output supported","l":"/api-output#tobuffer"},{"t":"withMetadata","d":"Include all metadata EXIF, XMP, IPTC from the input image in the output image. This will also convert to and add a web-friendly sRGB ICC pro","k":"withmetadata include metadata exif xmp iptc input image output image also convert add web friendly srgb icc pro","l":"/api-output#withmetadata"},{"t":"toFormat","d":"Force output to a given format.","k":"toformat force output given format","l":"/api-output#toformat"},{"t":"jpeg","d":"Use these JPEG options for output image.","k":"jpeg jpeg options output image","l":"/api-output#jpeg"},{"t":"png","d":"Use these PNG options for output image.","k":"png png options output image","l":"/api-output#png"},{"t":"webp","d":"Use these WebP options for output image.","k":"webp webp options output image","l":"/api-output#webp"},{"t":"tiff","d":"Use these TIFF options for output image.","k":"tiff tiff options output image","l":"/api-output#tiff"},{"t":"heif","d":"Use these HEIF options for output image.","k":"heif heif options output image","l":"/api-output#heif"},{"t":"raw","d":"Force output to be raw, uncompressed, 8-bit unsigned integer unit8 pixel data. Pixel ordering is left-to-right, top-to-bottom, without paddi","k":"raw force output raw uncompressed bit unsigned integer unit pixel data pixel ordering left right top bottom without paddi","l":"/api-output#raw"},{"t":"tile","d":"Use tile-based deep zoom image pyramid output. Set the format and options for tile images via the toFormat, jpeg, png or webp functions. Use","k":"tile tile based deep zoom image pyramid output format options tile images via toformat jpeg png webp functions","l":"/api-output#tile"},{"t":"resize","d":"Resize image to width, height or width x height.","k":"resize resize image width height width height","l":"/api-resize#resize"},{"t":"extend","d":"Extends/pads the edges of the image with the provided background colour. This operation will always occur after resizing and extraction, if","k":"extend extends pads edges image provided background colour operation occur after resizing extraction","l":"/api-resize#extend"},{"t":"extract","d":"Extract/crop a region of the image.","k":"extract extract crop region image","l":"/api-resize#extract"},{"t":"trim","d":"Trim boring pixels from all edges that contain values similar to the top-left pixel. Images consisting entirely of a single colour will calc","k":"trim trim boring pixels edges contain values similar top left pixel images consisting entirely single colour calc","l":"/api-resize#trim"},{"t":"composite","d":"Composite images over the processed resized, extracted etc. image.","k":"composite composite images processed resized extracted image","l":"/api-composite#composite"},{"t":"rotate","d":"Rotate the output image by either an explicit angle or auto-orient based on the EXIF Orientation tag.","k":"rotate rotate output image explicit angle auto orient based exif orientation tag","l":"/api-operation#rotate"},{"t":"flip","d":"Flip the image about the vertical Y axis. This always occurs after rotation, if any. The use of flip implies the removal of the EXIF Orienta","k":"flip flip image vertical axis occurs after rotation flip implies removal exif orienta","l":"/api-operation#flip"},{"t":"flop","d":"Flop the image about the horizontal X axis. This always occurs after rotation, if any. The use of flop implies the removal of the EXIF Orien","k":"flop flop image horizontal axis occurs after rotation flop implies removal exif orien","l":"/api-operation#flop"},{"t":"sharpen","d":"Sharpen the image. When used without parameters, performs a fast, mild sharpen of the output image. When a sigma is provided, performs a slo","k":"sharpen sharpen image used without parameters performs fast mild sharpen output image sigma provided performs slo","l":"/api-operation#sharpen"},{"t":"median","d":"Apply median filter. When used without parameters the default window is 3x3.","k":"median apply median filter used without parameters default window","l":"/api-operation#median"},{"t":"blur","d":"Blur the image. When used without parameters, performs a fast, mild blur of the output image. When a sigma is provided, performs a slower, m","k":"blur blur image used without parameters performs fast mild blur output image sigma provided performs slower","l":"/api-operation#blur"},{"t":"flatten","d":"Merge alpha transparency channel, if any, with a background.","k":"flatten merge alpha transparency channel background","l":"/api-operation#flatten"},{"t":"gamma","d":"Apply a gamma correction by reducing the encoding darken pre-resize at a factor of 1/gamma then increasing the encoding brighten post-resize","k":"gamma apply gamma correction reducing encoding darken pre resize factor gamma then increasing encoding brighten post resize","l":"/api-operation#gamma"},{"t":"negate","d":"Produce the negative of the image.","k":"negate produce negative image","l":"/api-operation#negate"},{"t":"normalise","d":"Enhance output image contrast by stretching its luminance to cover the full dynamic range.","k":"normalise enhance output image contrast stretching luminance cover full dynamic range","l":"/api-operation#normalise"},{"t":"normalize","d":"Alternative spelling of normalise.","k":"normalize alternative spelling normalise","l":"/api-operation#normalize"},{"t":"convolve","d":"Convolve the image with the specified kernel.","k":"convolve convolve image specified kernel","l":"/api-operation#convolve"},{"t":"threshold","d":"Any pixel value greather than or equal to the threshold value will be set to 255, otherwise it will be set to 0.","k":"threshold pixel value greather than equal threshold value otherwise","l":"/api-operation#threshold"},{"t":"boolean","d":"Perform a bitwise boolean operation with operand image.","k":"boolean perform bitwise boolean operation operand image","l":"/api-operation#boolean"},{"t":"linear","d":"Apply the linear formula a input b to the image levels adjustment","k":"linear apply linear formula input image levels adjustment","l":"/api-operation#linear"},{"t":"recomb","d":"Recomb the image with the specified matrix.","k":"recomb recomb image specified matrix","l":"/api-operation#recomb"},{"t":"modulate","d":"Transforms the image using brightness, saturation and hue rotation.","k":"modulate transforms image brightness saturation hue rotation","l":"/api-operation#modulate"},{"t":"removeAlpha","d":"Remove alpha channel, if any. This is a no-op if the image does not have an alpha channel.","k":"removealpha remove alpha channel image alpha channel","l":"/api-channel#removealpha"},{"t":"ensureAlpha","d":"Ensure alpha channel, if missing. The added alpha channel will be fully opaque. This is a no-op if the image already has an alpha channel.","k":"ensurealpha ensure alpha channel missing added alpha channel fully opaque image alpha channel","l":"/api-channel#ensurealpha"},{"t":"extractChannel","d":"Extract a single channel from a multi-channel image.","k":"extractchannel extract single channel multi channel image","l":"/api-channel#extractchannel"},{"t":"joinChannel","d":"Join one or more channels to the image. The meaning of the added channels depends on the output colourspace, set with toColourspace. By defa","k":"joinchannel join one channels image meaning added channels depends output colourspace tocolourspace defa","l":"/api-channel#joinchannel"},{"t":"bandbool","d":"Perform a bitwise boolean operation on all input image channels bands to produce a single channel output image.","k":"bandbool perform bitwise boolean operation input image channels bands produce single channel output image","l":"/api-channel#bandbool"},{"t":"tint","d":"Tint the image using the provided chroma while preserving the image luminance. An alpha channel may be present and will be unchanged by the","k":"tint tint image provided chroma while preserving image luminance alpha channel present unchanged","l":"/api-colour#tint"},{"t":"greyscale","d":"Convert to 8-bit greyscale 256 shades of grey. This is a linear operation. If the input image is in a non-linear colour space such as sRGB,","k":"greyscale convert bit greyscale shades grey linear operation input image non linear colour space such srgb","l":"/api-colour#greyscale"},{"t":"grayscale","d":"Alternative spelling of greyscale.","k":"grayscale alternative spelling greyscale","l":"/api-colour#grayscale"},{"t":"toColourspace","d":"Set the output colourspace. By default output image will be web-friendly sRGB, with additional channels interpreted as alpha channels.","k":"tocolourspace output colourspace default output image web friendly srgb additional channels interpreted alpha channels","l":"/api-colour#tocolourspace"},{"t":"toColorspace","d":"Alternative spelling of toColourspace.","k":"tocolorspace alternative spelling tocolourspace","l":"/api-colour#tocolorspace"},{"t":"format","d":"An Object containing nested boolean values representing the available input and output formats/methods.","k":"format object containing nested boolean values representing available input output formats methods","l":"/api-utility#format"},{"t":"versions","d":"An Object containing the version numbers of libvips and its dependencies.","k":"versions object containing version numbers libvips dependencies","l":"/api-utility#versions"},{"t":"cache","d":"Gets or, when options are provided, sets the limits of _libvips_ operation cache. Existing entries in the cache will be trimmed after any ch","k":"cache options provided limits libvips operation cache existing entries cache trimmed after","l":"/api-utility#cache"},{"t":"concurrency","d":"Gets or, when a concurrency is provided, sets the number of threads _libvips_ should create to process each image. The default value is the","k":"concurrency concurrency provided number threads libvips create process image default value","l":"/api-utility#concurrency"},{"t":"queue","d":"An EventEmitter that emits a change event when a task is either","k":"queue eventemitter emits change event task","l":"/api-utility#queue"},{"t":"counters","d":"Provides access to internal task counters.","k":"counters provides access internal task counters","l":"/api-utility#counters"},{"t":"simd","d":"Get and set use of SIMD vector unit instructions. Requires libvips to have been compiled with liborc support.","k":"simd simd vector unit instructions requires libvips compiled liborc support","l":"/api-utility#simd"}] \ No newline at end of file +[{"t":"Prerequisites","d":"Node.js v10.16.0","k":"prerequisites node","l":"/install#prerequisites"},{"t":"Prebuilt binaries","d":"Ready-compiled sharp and libvips binaries are provided for use with Node.js v10.16.0 on the most common platforms macOS x64 10.13 Linux x64","k":"prebuilt binaries ready compiled sharp libvips binaries provided node most common platforms macos linux","l":"/install#prebuilt-binaries"},{"t":"Common problems","d":"The architecture and platform of Node.js used for npm install must be the same as the architecture and platform of Node.js used at runtime.","k":"common problems architecture platform node used npm install must same architecture platform node used runtime","l":"/install#common-problems"},{"t":"Custom libvips","d":"To use a custom, globally-installed version of libvips instead of the provided binaries, make sure it is at least the version listed under c","k":"custom libvips custom globally installed version libvips instead provided binaries make sure least version listed under","l":"/install#custom-libvips"},{"t":"Building from source","d":"This module will be compiled from source at npm install time when a globally-installed libvips is detected set the SHARP_IGNORE_GLOBAL_LIBVI","k":"building source module compiled source npm install time globally installed libvips detected sharpignoregloballibvi","l":"/install#building-from-source"},{"t":"Custom prebuilt binaries","d":"This is an advanced approach that most people will not require. To install the prebuilt sharp binaries from a custom URL, set the sharp_bina","k":"custom prebuilt binaries advanced approach most people require install prebuilt sharp binaries custom url sharpbina","l":"/install#custom-prebuilt-binaries"},{"t":"Chinese mirror","d":"Alibaba provide a mirror site based in China containing binaries for both sharp and libvips. To use this either set the following configurat","k":"chinese mirror alibaba provide mirror site based china containing binaries both sharp libvips following configurat","l":"/install#chinese-mirror"},{"t":"FreeBSD","d":"The vips package must be installed before npm install is run. sh pkg install -y pkgconf vips sh cd /usr/ports/graphics/vips/ make install cl","k":"freebsd vips package must installed before npm install run pkg install pkgconf vips usr ports graphics vips make install","l":"/install#freebsd"},{"t":"Heroku","d":"Add the jemalloc buildpack to reduce the effects of memory fragmentation. Set NODE_MODULES_CACHE","k":"heroku add jemalloc buildpack reduce effects memory fragmentation nodemodulescache","l":"/install#heroku"},{"t":"AWS Lambda","d":"Set the Lambda runtime to nodejs12.x. The binaries in the node_modules directory of the deployment package must be for the Linux x64 platfor","k":"aws lambda lambda runtime nodejs binaries nodemodules directory deployment package must linux platfor","l":"/install#aws-lambda"},{"t":"Electron","d":"Electron provides versions of the V8 JavaScript engine that are incompatible with Node.js. To ensure the correct binaries are used, run the","k":"electron electron provides versions javascript engine incompatible node ensure correct binaries used run","l":"/install#electron"},{"t":"Worker threads","d":"The main thread must call requiresharp before worker threads are created to ensure shared libraries remain loaded in memory until after all","k":"worker threads main thread must call requiresharp before worker threads created ensure shared libraries remain loaded memory until after","l":"/install#worker-threads"},{"t":"Sharp","d":"Constructor factory to create an instance of sharp, to which further methods are chained.","k":"sharp constructor factory create instance sharp further methods chained","l":"/api-constructor#sharp"},{"t":"clone","d":"Take a snapshot of the Sharp instance, returning a new instance. Cloned instances inherit the input of their parent instance. This allows mu","k":"clone take snapshot sharp instance returning new instance cloned instances inherit input parent instance allows","l":"/api-constructor#clone"},{"t":"metadata","d":"Fast access to uncached image metadata without decoding any compressed image data. A Promise is returned when callback is not provided.","k":"metadata fast access uncached image metadata without decoding compressed image data promise returned callback provided","l":"/api-input#metadata"},{"t":"stats","d":"Access to pixel-derived image statistics for every channel in the image. A Promise is returned when callback is not provided.","k":"stats access pixel derived image statistics every channel image promise returned callback provided","l":"/api-input#stats"},{"t":"toFile","d":"Write output image data to a file.","k":"tofile write output image data file","l":"/api-output#tofile"},{"t":"toBuffer","d":"Write output to a Buffer. JPEG, PNG, WebP, TIFF and RAW output are supported.","k":"tobuffer write output buffer jpeg png webp tiff raw output supported","l":"/api-output#tobuffer"},{"t":"withMetadata","d":"Include all metadata EXIF, XMP, IPTC from the input image in the output image. This will also convert to and add a web-friendly sRGB ICC pro","k":"withmetadata include metadata exif xmp iptc input image output image also convert add web friendly srgb icc pro","l":"/api-output#withmetadata"},{"t":"toFormat","d":"Force output to a given format.","k":"toformat force output given format","l":"/api-output#toformat"},{"t":"jpeg","d":"Use these JPEG options for output image.","k":"jpeg jpeg options output image","l":"/api-output#jpeg"},{"t":"png","d":"Use these PNG options for output image.","k":"png png options output image","l":"/api-output#png"},{"t":"webp","d":"Use these WebP options for output image.","k":"webp webp options output image","l":"/api-output#webp"},{"t":"tiff","d":"Use these TIFF options for output image.","k":"tiff tiff options output image","l":"/api-output#tiff"},{"t":"heif","d":"Use these HEIF options for output image.","k":"heif heif options output image","l":"/api-output#heif"},{"t":"raw","d":"Force output to be raw, uncompressed, 8-bit unsigned integer unit8 pixel data. Pixel ordering is left-to-right, top-to-bottom, without paddi","k":"raw force output raw uncompressed bit unsigned integer unit pixel data pixel ordering left right top bottom without paddi","l":"/api-output#raw"},{"t":"tile","d":"Use tile-based deep zoom image pyramid output. Set the format and options for tile images via the toFormat, jpeg, png or webp functions. Use","k":"tile tile based deep zoom image pyramid output format options tile images via toformat jpeg png webp functions","l":"/api-output#tile"},{"t":"resize","d":"Resize image to width, height or width x height.","k":"resize resize image width height width height","l":"/api-resize#resize"},{"t":"extend","d":"Extends/pads the edges of the image with the provided background colour. This operation will always occur after resizing and extraction, if","k":"extend extends pads edges image provided background colour operation occur after resizing extraction","l":"/api-resize#extend"},{"t":"extract","d":"Extract/crop a region of the image.","k":"extract extract crop region image","l":"/api-resize#extract"},{"t":"trim","d":"Trim boring pixels from all edges that contain values similar to the top-left pixel. Images consisting entirely of a single colour will calc","k":"trim trim boring pixels edges contain values similar top left pixel images consisting entirely single colour calc","l":"/api-resize#trim"},{"t":"composite","d":"Composite images over the processed resized, extracted etc. image.","k":"composite composite images processed resized extracted image","l":"/api-composite#composite"},{"t":"rotate","d":"Rotate the output image by either an explicit angle or auto-orient based on the EXIF Orientation tag.","k":"rotate rotate output image explicit angle auto orient based exif orientation tag","l":"/api-operation#rotate"},{"t":"flip","d":"Flip the image about the vertical Y axis. This always occurs after rotation, if any. The use of flip implies the removal of the EXIF Orienta","k":"flip flip image vertical axis occurs after rotation flip implies removal exif orienta","l":"/api-operation#flip"},{"t":"flop","d":"Flop the image about the horizontal X axis. This always occurs after rotation, if any. The use of flop implies the removal of the EXIF Orien","k":"flop flop image horizontal axis occurs after rotation flop implies removal exif orien","l":"/api-operation#flop"},{"t":"sharpen","d":"Sharpen the image. When used without parameters, performs a fast, mild sharpen of the output image. When a sigma is provided, performs a slo","k":"sharpen sharpen image used without parameters performs fast mild sharpen output image sigma provided performs slo","l":"/api-operation#sharpen"},{"t":"median","d":"Apply median filter. When used without parameters the default window is 3x3.","k":"median apply median filter used without parameters default window","l":"/api-operation#median"},{"t":"blur","d":"Blur the image. When used without parameters, performs a fast, mild blur of the output image. When a sigma is provided, performs a slower, m","k":"blur blur image used without parameters performs fast mild blur output image sigma provided performs slower","l":"/api-operation#blur"},{"t":"flatten","d":"Merge alpha transparency channel, if any, with a background.","k":"flatten merge alpha transparency channel background","l":"/api-operation#flatten"},{"t":"gamma","d":"Apply a gamma correction by reducing the encoding darken pre-resize at a factor of 1/gamma then increasing the encoding brighten post-resize","k":"gamma apply gamma correction reducing encoding darken pre resize factor gamma then increasing encoding brighten post resize","l":"/api-operation#gamma"},{"t":"negate","d":"Produce the negative of the image.","k":"negate produce negative image","l":"/api-operation#negate"},{"t":"normalise","d":"Enhance output image contrast by stretching its luminance to cover the full dynamic range.","k":"normalise enhance output image contrast stretching luminance cover full dynamic range","l":"/api-operation#normalise"},{"t":"normalize","d":"Alternative spelling of normalise.","k":"normalize alternative spelling normalise","l":"/api-operation#normalize"},{"t":"convolve","d":"Convolve the image with the specified kernel.","k":"convolve convolve image specified kernel","l":"/api-operation#convolve"},{"t":"threshold","d":"Any pixel value greather than or equal to the threshold value will be set to 255, otherwise it will be set to 0.","k":"threshold pixel value greather than equal threshold value otherwise","l":"/api-operation#threshold"},{"t":"boolean","d":"Perform a bitwise boolean operation with operand image.","k":"boolean perform bitwise boolean operation operand image","l":"/api-operation#boolean"},{"t":"linear","d":"Apply the linear formula a input b to the image levels adjustment","k":"linear apply linear formula input image levels adjustment","l":"/api-operation#linear"},{"t":"recomb","d":"Recomb the image with the specified matrix.","k":"recomb recomb image specified matrix","l":"/api-operation#recomb"},{"t":"modulate","d":"Transforms the image using brightness, saturation and hue rotation.","k":"modulate transforms image brightness saturation hue rotation","l":"/api-operation#modulate"},{"t":"removeAlpha","d":"Remove alpha channel, if any. This is a no-op if the image does not have an alpha channel.","k":"removealpha remove alpha channel image alpha channel","l":"/api-channel#removealpha"},{"t":"ensureAlpha","d":"Ensure alpha channel, if missing. The added alpha channel will be fully opaque. This is a no-op if the image already has an alpha channel.","k":"ensurealpha ensure alpha channel missing added alpha channel fully opaque image alpha channel","l":"/api-channel#ensurealpha"},{"t":"extractChannel","d":"Extract a single channel from a multi-channel image.","k":"extractchannel extract single channel multi channel image","l":"/api-channel#extractchannel"},{"t":"joinChannel","d":"Join one or more channels to the image. The meaning of the added channels depends on the output colourspace, set with toColourspace. By defa","k":"joinchannel join one channels image meaning added channels depends output colourspace tocolourspace defa","l":"/api-channel#joinchannel"},{"t":"bandbool","d":"Perform a bitwise boolean operation on all input image channels bands to produce a single channel output image.","k":"bandbool perform bitwise boolean operation input image channels bands produce single channel output image","l":"/api-channel#bandbool"},{"t":"tint","d":"Tint the image using the provided chroma while preserving the image luminance. An alpha channel may be present and will be unchanged by the","k":"tint tint image provided chroma while preserving image luminance alpha channel present unchanged","l":"/api-colour#tint"},{"t":"greyscale","d":"Convert to 8-bit greyscale 256 shades of grey. This is a linear operation. If the input image is in a non-linear colour space such as sRGB,","k":"greyscale convert bit greyscale shades grey linear operation input image non linear colour space such srgb","l":"/api-colour#greyscale"},{"t":"grayscale","d":"Alternative spelling of greyscale.","k":"grayscale alternative spelling greyscale","l":"/api-colour#grayscale"},{"t":"toColourspace","d":"Set the output colourspace. By default output image will be web-friendly sRGB, with additional channels interpreted as alpha channels.","k":"tocolourspace output colourspace default output image web friendly srgb additional channels interpreted alpha channels","l":"/api-colour#tocolourspace"},{"t":"toColorspace","d":"Alternative spelling of toColourspace.","k":"tocolorspace alternative spelling tocolourspace","l":"/api-colour#tocolorspace"},{"t":"format","d":"An Object containing nested boolean values representing the available input and output formats/methods.","k":"format object containing nested boolean values representing available input output formats methods","l":"/api-utility#format"},{"t":"versions","d":"An Object containing the version numbers of libvips and its dependencies.","k":"versions object containing version numbers libvips dependencies","l":"/api-utility#versions"},{"t":"cache","d":"Gets or, when options are provided, sets the limits of _libvips_ operation cache. Existing entries in the cache will be trimmed after any ch","k":"cache options provided limits libvips operation cache existing entries cache trimmed after","l":"/api-utility#cache"},{"t":"concurrency","d":"Gets or, when a concurrency is provided, sets the number of threads _libvips_ should create to process each image. The default value is the","k":"concurrency concurrency provided number threads libvips create process image default value","l":"/api-utility#concurrency"},{"t":"queue","d":"An EventEmitter that emits a change event when a task is either","k":"queue eventemitter emits change event task","l":"/api-utility#queue"},{"t":"counters","d":"Provides access to internal task counters.","k":"counters provides access internal task counters","l":"/api-utility#counters"},{"t":"simd","d":"Get and set use of SIMD vector unit instructions. Requires libvips to have been compiled with liborc support.","k":"simd simd vector unit instructions requires libvips compiled liborc support","l":"/api-utility#simd"}] \ No newline at end of file diff --git a/install/libvips.js b/install/libvips.js index 84eb9955..4bde9879 100644 --- a/install/libvips.js +++ b/install/libvips.js @@ -81,7 +81,7 @@ try { } } // Download to per-process temporary file - const tarFilename = ['libvips', minimumLibvipsVersion, platformAndArch].join('-') + '.tar.br'; + const tarFilename = ['libvips', minimumLibvipsVersionLabelled, platformAndArch].join('-') + '.tar.br'; const tarPathCache = path.join(libvips.cachePath(), tarFilename); if (fs.existsSync(tarPathCache)) { npmLog.info('sharp', `Using cached ${tarPathCache}`); diff --git a/lib/constructor.js b/lib/constructor.js index 0cb2e6df..d9cb63ec 100644 --- a/lib/constructor.js +++ b/lib/constructor.js @@ -214,7 +214,7 @@ const Sharp = function (input, options) { tiffCompression: 'jpeg', tiffPredictor: 'horizontal', tiffPyramid: false, - tiffSquash: false, + tiffBitdepth: 8, tiffTile: false, tiffTileHeight: 256, tiffTileWidth: 256, diff --git a/lib/output.js b/lib/output.js index fc37adb6..7e36a35c 100644 --- a/lib/output.js +++ b/lib/output.js @@ -187,7 +187,7 @@ function toFormat (format, options) { * @param {Object} [options] - output options * @param {number} [options.quality=80] - quality, integer 1-100 * @param {boolean} [options.progressive=false] - use progressive (interlace) scan - * @param {string} [options.chromaSubsampling='4:2:0'] - for quality < 90, set to '4:4:4' to prevent chroma subsampling otherwise defaults to '4:2:0' (use chroma subsampling); for quality >= 90 chroma is never subsampled + * @param {string} [options.chromaSubsampling='4:2:0'] - set to '4:4:4' to prevent chroma subsampling otherwise defaults to '4:2:0' chroma subsampling * @param {boolean} [options.optimiseCoding=true] - optimise Huffman coding tables * @param {boolean} [options.optimizeCoding=true] - alternative spelling of optimiseCoding * @param {boolean} [options.trellisQuantisation=false] - apply trellis quantisation, requires libvips compiled with support for mozjpeg @@ -386,7 +386,7 @@ function webp (options) { * sharp('input.svg') * .tiff({ * compression: 'lzw', - * squash: true + * bitdepth: 1 * }) * .toFile('1-bpp-output.tiff') * .then(info => { ... }); @@ -402,7 +402,7 @@ function webp (options) { * @param {boolean} [options.tileHeight=256] - vertical tile size * @param {number} [options.xres=1.0] - horizontal resolution in pixels/mm * @param {number} [options.yres=1.0] - vertical resolution in pixels/mm - * @param {boolean} [options.squash=false] - squash 8-bit images down to 1 bit + * @param {boolean} [options.bitdepth=8] - reduce bitdepth to 1, 2 or 4 bit * @returns {Sharp} * @throws {Error} Invalid options */ @@ -415,8 +415,12 @@ function tiff (options) { throw is.invalidParameterError('quality', 'integer between 1 and 100', options.quality); } } - if (is.defined(options.squash)) { - this._setBooleanOption('tiffSquash', options.squash); + if (is.defined(options.bitdepth)) { + if (is.integer(options.bitdepth) && is.inArray(options.bitdepth, [1, 2, 4, 8])) { + this.options.tiffBitdepth = options.bitdepth; + } else { + throw is.invalidParameterError('bitdepth', '1, 2, 4 or 8', options.bitdepth); + } } // tiling if (is.defined(options.tile)) { diff --git a/package.json b/package.json index 8a98caff..c234ed0d 100644 --- a/package.json +++ b/package.json @@ -111,9 +111,9 @@ "dependencies": { "color": "^3.1.2", "detect-libc": "^1.0.3", - "node-addon-api": "^3.0.0", + "node-addon-api": "^3.0.1", "npmlog": "^4.1.2", - "prebuild-install": "^5.3.4", + "prebuild-install": "^5.3.5", "semver": "^7.3.2", "simple-get": "^4.0.0", "tar-fs": "^2.1.0", @@ -123,9 +123,9 @@ "async": "^3.2.0", "cc": "^2.0.1", "decompress-zip": "^0.3.2", - "documentation": "^13.0.1", + "documentation": "^13.0.2", "exif-reader": "^1.0.3", - "icc": "^1.0.0", + "icc": "^2.0.0", "license-checker": "^25.0.1", "mocha": "^8.0.1", "mock-fs": "^4.12.0", @@ -137,7 +137,7 @@ }, "license": "Apache-2.0", "config": { - "libvips": "8.9.2-alpha5" + "libvips": "8.10.0-beta2" }, "engines": { "node": ">=10.16.0" diff --git a/src/common.cc b/src/common.cc index 0a6ddbd7..0f6043a4 100644 --- a/src/common.cc +++ b/src/common.cc @@ -243,7 +243,7 @@ namespace sharp { imageType = ImageType::MAGICK; } } else { - if (EndsWith(vips::VError().what(), " not found\n")) { + if (EndsWith(vips::VError().what(), " does not exist\n")) { imageType = ImageType::MISSING; } } diff --git a/src/libvips/cplusplus/VImage.cpp b/src/libvips/cplusplus/VImage.cpp index 5abe632c..27654f22 100644 --- a/src/libvips/cplusplus/VImage.cpp +++ b/src/libvips/cplusplus/VImage.cpp @@ -5,7 +5,7 @@ * 10/6/16 * - missing implementation of VImage::write() * 11/6/16 - * - added arithmetic assignment overloads, += etc. + * - added arithmetic assignment overloads, += etc. */ /* @@ -51,7 +51,7 @@ VIPS_NAMESPACE_START -std::vector +std::vector to_vectorv( int n, ... ) { std::vector vector( n ); @@ -65,13 +65,13 @@ to_vectorv( int n, ... ) return( vector ); } -std::vector +std::vector to_vector( double value ) { return( to_vectorv( 1, value ) ); } -std::vector +std::vector to_vector( int n, double array[] ) { std::vector vector( n ); @@ -82,10 +82,10 @@ to_vector( int n, double array[] ) return( vector ); } -std::vector +std::vector negate( std::vector vector ) { - std::vector new_vector( vector.size() ); + std::vector new_vector( vector.size() ); for( unsigned int i = 0; i < vector.size(); i++ ) new_vector[i] = vector[i] * -1; @@ -93,7 +93,7 @@ negate( std::vector vector ) return( new_vector ); } -std::vector +std::vector invert( std::vector vector ) { std::vector new_vector( vector.size() ); @@ -108,7 +108,7 @@ VOption::~VOption() { std::list::iterator i; - for( i = options.begin(); i != options.end(); ++i ) + for( i = options.begin(); i != options.end(); ++i ) delete *i; } @@ -140,7 +140,7 @@ VOption::set( const char *name, int value ) return( this ); } -// input double +// input double VOption * VOption::set( const char *name, double value ) { @@ -188,17 +188,17 @@ VOption::set( const char *name, std::vector value ) Pair *pair = new Pair( name ); double *array; - unsigned int i; + unsigned int i; pair->input = true; g_value_init( &pair->value, VIPS_TYPE_ARRAY_DOUBLE ); vips_value_set_array_double( &pair->value, NULL, static_cast< int >( value.size() ) ); - array = vips_value_get_array_double( &pair->value, NULL ); + array = vips_value_get_array_double( &pair->value, NULL ); - for( i = 0; i < value.size(); i++ ) - array[i] = value[i]; + for( i = 0; i < value.size(); i++ ) + array[i] = value[i]; options.push_back( pair ); @@ -212,17 +212,17 @@ VOption::set( const char *name, std::vector value ) Pair *pair = new Pair( name ); int *array; - unsigned int i; + unsigned int i; pair->input = true; g_value_init( &pair->value, VIPS_TYPE_ARRAY_INT ); vips_value_set_array_int( &pair->value, NULL, static_cast< int >( value.size() ) ); - array = vips_value_get_array_int( &pair->value, NULL ); + array = vips_value_get_array_int( &pair->value, NULL ); - for( i = 0; i < value.size(); i++ ) - array[i] = value[i]; + for( i = 0; i < value.size(); i++ ) + array[i] = value[i]; options.push_back( pair ); @@ -236,7 +236,7 @@ VOption::set( const char *name, std::vector value ) Pair *pair = new Pair( name ); VipsImage **array; - unsigned int i; + unsigned int i; pair->input = true; @@ -245,11 +245,11 @@ VOption::set( const char *name, std::vector value ) static_cast< int >( value.size() ) ); array = vips_value_get_array_image( &pair->value, NULL ); - for( i = 0; i < value.size(); i++ ) { + for( i = 0; i < value.size(); i++ ) { VipsImage *vips_image = value[i].get_image(); - array[i] = vips_image; - g_object_ref( vips_image ); + array[i] = vips_image; + g_object_ref( vips_image ); } options.push_back( pair ); @@ -279,7 +279,7 @@ VOption::set( const char *name, bool *value ) pair->input = false; pair->vbool = value; - g_value_init( &pair->value, G_TYPE_BOOLEAN ); + g_value_init( &pair->value, G_TYPE_BOOLEAN ); options.push_back( pair ); @@ -294,7 +294,7 @@ VOption::set( const char *name, int *value ) pair->input = false; pair->vint = value; - g_value_init( &pair->value, G_TYPE_INT ); + g_value_init( &pair->value, G_TYPE_INT ); options.push_back( pair ); @@ -309,7 +309,7 @@ VOption::set( const char *name, double *value ) pair->input = false; pair->vdouble = value; - g_value_init( &pair->value, G_TYPE_DOUBLE ); + g_value_init( &pair->value, G_TYPE_DOUBLE ); options.push_back( pair ); @@ -339,7 +339,7 @@ VOption::set( const char *name, std::vector *value ) pair->input = false; pair->vvector = value; - g_value_init( &pair->value, VIPS_TYPE_ARRAY_DOUBLE ); + g_value_init( &pair->value, VIPS_TYPE_ARRAY_DOUBLE ); options.push_back( pair ); @@ -354,7 +354,7 @@ VOption::set( const char *name, VipsBlob **value ) pair->input = false; pair->vblob = value; - g_value_init( &pair->value, VIPS_TYPE_BLOB ); + g_value_init( &pair->value, VIPS_TYPE_BLOB ); options.push_back( pair ); @@ -362,7 +362,7 @@ VOption::set( const char *name, VipsBlob **value ) } // just g_object_set_property(), except we allow set enum from string -static void +static void set_property( VipsObject *object, const char *name, const GValue *value ) { VipsObjectClass *object_class = VIPS_OBJECT_GET_CLASS( object ); @@ -372,7 +372,7 @@ set_property( VipsObject *object, const char *name, const GValue *value ) VipsArgumentClass *argument_class; VipsArgumentInstance *argument_instance; - if( vips_object_get_argument( object, name, + if( vips_object_get_argument( object, name, &pspec, &argument_class, &argument_instance ) ) { g_warning( "%s", vips_error_buffer() ); vips_error_clear(); @@ -384,17 +384,17 @@ set_property( VipsObject *object, const char *name, const GValue *value ) GType pspec_type = G_PARAM_SPEC_VALUE_TYPE( pspec ); int enum_value; - GValue value2 = { 0 }; + GValue value2 = { 0 }; - if( (enum_value = vips_enum_from_nick( object_class->nickname, + if( (enum_value = vips_enum_from_nick( object_class->nickname, pspec_type, g_value_get_string( value ) )) < 0 ) { g_warning( "%s", vips_error_buffer() ); vips_error_clear(); return; } - g_value_init( &value2, pspec_type ); - g_value_set_enum( &value2, enum_value ); + g_value_init( &value2, pspec_type ); + g_value_set_enum( &value2, enum_value ); g_object_set_property( G_OBJECT( object ), name, &value2 ); g_value_unset( &value2 ); } @@ -402,18 +402,19 @@ set_property( VipsObject *object, const char *name, const GValue *value ) g_object_set_property( G_OBJECT( object ), name, value ); } -// walk the options and set props on the operation -void +// walk the options and set props on the operation +void VOption::set_operation( VipsOperation *operation ) { std::list::iterator i; - for( i = options.begin(); i != options.end(); ++i ) + for( i = options.begin(); i != options.end(); ++i ) if( (*i)->input ) { #ifdef VIPS_DEBUG_VERBOSE printf( "set_operation: " ); vips_object_print_name( VIPS_OBJECT( operation ) ); - char *str_value = g_strdup_value_contents( &(*i)->value ); + char *str_value = + g_strdup_value_contents( &(*i)->value ); printf( ".%s = %s\n", (*i)->name, str_value ); g_free( str_value ); #endif /*VIPS_DEBUG_VERBOSE*/ @@ -424,12 +425,12 @@ VOption::set_operation( VipsOperation *operation ) } // walk the options and fetch any requested outputs -void +void VOption::get_operation( VipsOperation *operation ) { std::list::iterator i; - for( i = options.begin(); i != options.end(); ++i ) + for( i = options.begin(); i != options.end(); ++i ) if( ! (*i)->input ) { const char *name = (*i)->name; @@ -439,7 +440,7 @@ VOption::get_operation( VipsOperation *operation ) #ifdef VIPS_DEBUG_VERBOSE printf( "get_operation: " ); vips_object_print_name( VIPS_OBJECT( operation ) ); - char *str_value = g_strdup_value_contents( + char *str_value = g_strdup_value_contents( &(*i)->value ); printf( ".%s = %s\n", name, str_value ); g_free( str_value ); @@ -450,59 +451,59 @@ VOption::get_operation( VipsOperation *operation ) if( type == VIPS_TYPE_IMAGE ) { // rebox object - VipsImage *image = VIPS_IMAGE( - g_value_get_object( value ) ); - *((*i)->vimage) = VImage( image ); + VipsImage *image = VIPS_IMAGE( + g_value_get_object( value ) ); + *((*i)->vimage) = VImage( image ); } - else if( type == G_TYPE_INT ) - *((*i)->vint) = g_value_get_int( value ); - else if( type == G_TYPE_BOOLEAN ) - *((*i)->vbool) = g_value_get_boolean( value ); - else if( type == G_TYPE_DOUBLE ) - *((*i)->vdouble) = g_value_get_double( value ); + else if( type == G_TYPE_INT ) + *((*i)->vint) = g_value_get_int( value ); + else if( type == G_TYPE_BOOLEAN ) + *((*i)->vbool) = g_value_get_boolean( value ); + else if( type == G_TYPE_DOUBLE ) + *((*i)->vdouble) = g_value_get_double( value ); else if( type == VIPS_TYPE_ARRAY_DOUBLE ) { int length; - double *array = - vips_value_get_array_double( value, + double *array = + vips_value_get_array_double( value, &length ); int j; - ((*i)->vvector)->resize( length ); + ((*i)->vvector)->resize( length ); for( j = 0; j < length; j++ ) (*((*i)->vvector))[j] = array[j]; } else if( type == VIPS_TYPE_BLOB ) { // our caller gets a reference - *((*i)->vblob) = + *((*i)->vblob) = (VipsBlob *) g_value_dup_boxed( value ); } } } -void -VImage::call_option_string( const char *operation_name, - const char *option_string, VOption *options ) +void +VImage::call_option_string( const char *operation_name, + const char *option_string, VOption *options ) { VipsOperation *operation; - VIPS_DEBUG_MSG( "call_option_string: starting for %s ...\n", + VIPS_DEBUG_MSG( "call_option_string: starting for %s ...\n", operation_name ); if( !(operation = vips_operation_new( operation_name )) ) { delete options; - throw( VError() ); + throw( VError() ); } - /* Set str options before vargs options, so the user can't + /* Set str options before vargs options, so the user can't * override things we set deliberately. */ if( option_string && - vips_object_set_from_string( VIPS_OBJECT( operation ), + vips_object_set_from_string( VIPS_OBJECT( operation ), option_string ) ) { vips_object_unref_outputs( VIPS_OBJECT( operation ) ); - g_object_unref( operation ); - delete options; - throw( VError() ); + g_object_unref( operation ); + delete options; + throw( VError() ); } if( options ) @@ -512,9 +513,9 @@ VImage::call_option_string( const char *operation_name, */ if( vips_cache_operation_buildp( &operation ) ) { vips_object_unref_outputs( VIPS_OBJECT( operation ) ); - g_object_unref( operation ); - delete options; - throw( VError() ); + g_object_unref( operation ); + delete options; + throw( VError() ); } /* Walk args again, writing output. @@ -524,46 +525,46 @@ VImage::call_option_string( const char *operation_name, /* We're done with options! */ - delete options; + delete options; - /* The operation we have built should now have been reffed by - * one of its arguments or have finished its work. Either + /* The operation we have built should now have been reffed by + * one of its arguments or have finished its work. Either * way, we can unref. */ g_object_unref( operation ); } -void -VImage::call( const char *operation_name, VOption *options ) +void +VImage::call( const char *operation_name, VOption *options ) { - call_option_string( operation_name, NULL, options ); + call_option_string( operation_name, NULL, options ); } -VImage +VImage VImage::new_from_file( const char *name, VOption *options ) { char filename[VIPS_PATH_MAX]; char option_string[VIPS_PATH_MAX]; const char *operation_name; - VImage out; + VImage out; vips__filename_split8( name, filename, option_string ); if( !(operation_name = vips_foreign_find_load( filename )) ) { - delete options; - throw VError(); + delete options; + throw VError(); } call_option_string( operation_name, option_string, - (options ? options : VImage::option())-> + (options ? options : VImage::option())-> set( "filename", filename )-> set( "out", &out ) ); - return( out ); + return( out ); } -VImage -VImage::new_from_buffer( const void *buf, size_t len, const char *option_string, +VImage +VImage::new_from_buffer( const void *buf, size_t len, const char *option_string, VOption *options ) { const char *operation_name; @@ -571,87 +572,87 @@ VImage::new_from_buffer( const void *buf, size_t len, const char *option_string, VImage out; if( !(operation_name = vips_foreign_find_load_buffer( buf, len )) ) { - delete options; - throw( VError() ); + delete options; + throw( VError() ); } /* We don't take a copy of the data or free it. */ blob = vips_blob_new( NULL, buf, len ); - options = (options ? options : VImage::option())-> + options = (options ? options : VImage::option())-> set( "buffer", blob )-> set( "out", &out ); vips_area_unref( VIPS_AREA( blob ) ); - call_option_string( operation_name, option_string, options ); + call_option_string( operation_name, option_string, options ); return( out ); } -VImage -VImage::new_from_buffer( const std::string &buf, const char *option_string, +VImage +VImage::new_from_buffer( const std::string &buf, const char *option_string, VOption *options ) { - return( new_from_buffer( buf.c_str(), buf.size(), + return( new_from_buffer( buf.c_str(), buf.size(), option_string, options ) ); } -VImage -VImage::new_from_source( VSource source, const char *option_string, +VImage +VImage::new_from_source( VSource source, const char *option_string, VOption *options ) { const char *operation_name; VImage out; - if( !(operation_name = vips_foreign_find_load_source( + if( !(operation_name = vips_foreign_find_load_source( source.get_source() )) ) { - delete options; - throw( VError() ); + delete options; + throw( VError() ); } - options = (options ? options : VImage::option())-> + options = (options ? options : VImage::option())-> set( "source", source )-> set( "out", &out ); - call_option_string( operation_name, option_string, options ); + call_option_string( operation_name, option_string, options ); return( out ); } -VImage -VImage::new_matrix( int width, int height ) +VImage +VImage::new_matrix( int width, int height ) { - return( VImage( vips_image_new_matrix( width, height ) ) ); + return( VImage( vips_image_new_matrix( width, height ) ) ); } -VImage +VImage VImage::new_matrixv( int width, int height, ... ) { VImage matrix = new_matrix( width, height ); - VipsImage *vips_matrix = matrix.get_image(); + VipsImage *vips_matrix = matrix.get_image(); va_list ap; va_start( ap, height ); for( int y = 0; y < height; y++ ) for( int x = 0; x < width; x++ ) - *VIPS_MATRIX( vips_matrix, x, y ) = + *VIPS_MATRIX( vips_matrix, x, y ) = va_arg( ap, double ); va_end( ap ); - return( matrix ); + return( matrix ); } VImage VImage::write( VImage out ) const { if( vips_image_write( this->get_image(), out.get_image() ) ) - throw VError(); + throw VError(); - return( out ); + return( out ); } -void +void VImage::write_to_file( const char *name, VOption *options ) const { char filename[VIPS_PATH_MAX]; @@ -660,18 +661,18 @@ VImage::write_to_file( const char *name, VOption *options ) const vips__filename_split8( name, filename, option_string ); if( !(operation_name = vips_foreign_find_save( filename )) ) { - delete options; - throw VError(); + delete options; + throw VError(); } - call_option_string( operation_name, option_string, - (options ? options : VImage::option())-> + call_option_string( operation_name, option_string, + (options ? options : VImage::option())-> set( "in", *this )-> set( "filename", filename ) ); } -void -VImage::write_to_buffer( const char *suffix, void **buf, size_t *size, +void +VImage::write_to_buffer( const char *suffix, void **buf, size_t *size, VOption *options ) const { char filename[VIPS_PATH_MAX]; @@ -681,16 +682,16 @@ VImage::write_to_buffer( const char *suffix, void **buf, size_t *size, vips__filename_split8( suffix, filename, option_string ); if( !(operation_name = vips_foreign_find_save_buffer( filename )) ) { - delete options; - throw VError(); + delete options; + throw VError(); } - call_option_string( operation_name, option_string, - (options ? options : VImage::option())-> + call_option_string( operation_name, option_string, + (options ? options : VImage::option())-> set( "in", *this )-> set( "buffer", &blob ) ); - if( blob ) { + if( blob ) { if( buf ) { *buf = VIPS_AREA( blob )->data; VIPS_AREA( blob )->free_fn = NULL; @@ -702,8 +703,8 @@ VImage::write_to_buffer( const char *suffix, void **buf, size_t *size, } } -void -VImage::write_to_target( const char *suffix, VTarget target, +void +VImage::write_to_target( const char *suffix, VTarget target, VOption *options ) const { char filename[VIPS_PATH_MAX]; @@ -712,755 +713,755 @@ VImage::write_to_target( const char *suffix, VTarget target, vips__filename_split8( suffix, filename, option_string ); if( !(operation_name = vips_foreign_find_save_target( filename )) ) { - delete options; - throw VError(); + delete options; + throw VError(); } - call_option_string( operation_name, option_string, - (options ? options : VImage::option())-> + call_option_string( operation_name, option_string, + (options ? options : VImage::option())-> set( "in", *this )-> set( "target", target ) ); } #include "vips-operators.cpp" -std::vector +std::vector VImage::bandsplit( VOption *options ) const { - std::vector b; + std::vector b; for( int i = 0; i < bands(); i++ ) - b.push_back( extract_band( i ) ); + b.push_back( extract_band( i ) ); - return( b ); + return( b ); } -VImage +VImage VImage::bandjoin( VImage other, VOption *options ) const { - VImage v[2] = { *this, other }; + VImage v[2] = { *this, other }; std::vector vec( v, v + VIPS_NUMBER( v ) ); - return( bandjoin( vec, options ) ); + return( bandjoin( vec, options ) ); } -VImage +VImage VImage::composite( VImage other, VipsBlendMode mode, VOption *options ) const { - VImage v[2] = { *this, other }; + VImage v[2] = { *this, other }; std::vector ivec( v, v + VIPS_NUMBER( v ) ); - int m[1] = { static_cast( mode ) }; + int m[1] = { static_cast( mode ) }; std::vector mvec( m, m + VIPS_NUMBER( m ) ); - return( composite( ivec, mvec, options ) ); + return( composite( ivec, mvec, options ) ); } -std::complex +std::complex VImage::minpos( VOption *options ) const { double x, y; - (void) min( + (void) min( (options ? options : VImage::option()) -> set( "x", &x ) -> set( "y", &y ) ); - return( std::complex( x, y ) ); + return( std::complex( x, y ) ); } -std::complex +std::complex VImage::maxpos( VOption *options ) const { double x, y; - (void) max( + (void) max( (options ? options : VImage::option()) -> set( "x", &x ) -> set( "y", &y ) ); - return( std::complex( x, y ) ); + return( std::complex( x, y ) ); } // Operator overloads -VImage +VImage VImage::operator[]( int index ) const { - return( this->extract_band( index ) ); + return( this->extract_band( index ) ); } -std::vector +std::vector VImage::operator()( int x, int y ) const { - return( this->getpoint( x, y ) ); + return( this->getpoint( x, y ) ); } -VImage +VImage operator+( const VImage a, const VImage b ) { return( a.add( b ) ); } -VImage -operator+( double a, const VImage b ) +VImage +operator+( double a, const VImage b ) { - return( b.linear( 1.0, a ) ); + return( b.linear( 1.0, a ) ); } -VImage -operator+( const VImage a, double b ) -{ - return( a.linear( 1.0, b ) ); -} - -VImage -operator+( const std::vector a, const VImage b ) +VImage +operator+( const VImage a, double b ) { - return( b.linear( 1.0, a ) ); + return( a.linear( 1.0, b ) ); } -VImage -operator+( const VImage a, const std::vector b ) -{ - return( a.linear( 1.0, b ) ); +VImage +operator+( const std::vector a, const VImage b ) +{ + return( b.linear( 1.0, a ) ); } -VImage & +VImage +operator+( const VImage a, const std::vector b ) +{ + return( a.linear( 1.0, b ) ); +} + +VImage & operator+=( VImage &a, const VImage b ) { - return( a = a + b ); + return( a = a + b ); } -VImage & +VImage & operator+=( VImage &a, const double b ) { - return( a = a + b ); + return( a = a + b ); } -VImage & +VImage & operator+=( VImage &a, const std::vector b ) { - return( a = a + b ); + return( a = a + b ); } -VImage -operator-( const VImage a, const VImage b ) +VImage +operator-( const VImage a, const VImage b ) { return( a.subtract( b ) ); } -VImage -operator-( double a, const VImage b ) +VImage +operator-( double a, const VImage b ) { - return( b.linear( -1.0, a ) ); + return( b.linear( -1.0, a ) ); } -VImage -operator-( const VImage a, double b ) -{ - return( a.linear( 1.0, -b ) ); -} - -VImage -operator-( const std::vector a, const VImage b ) +VImage +operator-( const VImage a, double b ) { - return( b.linear( -1.0, a ) ); + return( a.linear( 1.0, -b ) ); } -VImage -operator-( const VImage a, const std::vector b ) -{ - return( a.linear( 1.0, vips::negate( b ) ) ); +VImage +operator-( const std::vector a, const VImage b ) +{ + return( b.linear( -1.0, a ) ); } -VImage & +VImage +operator-( const VImage a, const std::vector b ) +{ + return( a.linear( 1.0, vips::negate( b ) ) ); +} + +VImage & operator-=( VImage &a, const VImage b ) { - return( a = a - b ); + return( a = a - b ); } -VImage & +VImage & operator-=( VImage &a, const double b ) { - return( a = a - b ); + return( a = a - b ); } -VImage & +VImage & operator-=( VImage &a, const std::vector b ) { - return( a = a - b ); + return( a = a - b ); } -VImage -operator-( const VImage a ) -{ +VImage +operator-( const VImage a ) +{ return( a * -1 ); } -VImage -operator*( const VImage a, const VImage b ) +VImage +operator*( const VImage a, const VImage b ) { return( a.multiply( b ) ); } -VImage -operator*( double a, const VImage b ) +VImage +operator*( double a, const VImage b ) { - return( b.linear( a, 0.0 ) ); + return( b.linear( a, 0.0 ) ); } -VImage -operator*( const VImage a, double b ) -{ - return( a.linear( b, 0.0 ) ); -} - -VImage -operator*( const std::vector a, const VImage b ) +VImage +operator*( const VImage a, double b ) { - return( b.linear( a, 0.0 ) ); + return( a.linear( b, 0.0 ) ); } -VImage -operator*( const VImage a, const std::vector b ) -{ - return( a.linear( b, 0.0 ) ); +VImage +operator*( const std::vector a, const VImage b ) +{ + return( b.linear( a, 0.0 ) ); } -VImage & +VImage +operator*( const VImage a, const std::vector b ) +{ + return( a.linear( b, 0.0 ) ); +} + +VImage & operator*=( VImage &a, const VImage b ) { - return( a = a * b ); + return( a = a * b ); } -VImage & +VImage & operator*=( VImage &a, const double b ) { - return( a = a * b ); + return( a = a * b ); } -VImage & +VImage & operator*=( VImage &a, const std::vector b ) { - return( a = a * b ); + return( a = a * b ); } -VImage -operator/( const VImage a, const VImage b ) +VImage +operator/( const VImage a, const VImage b ) { return( a.divide( b ) ); } -VImage -operator/( double a, const VImage b ) +VImage +operator/( double a, const VImage b ) { - return( b.pow( -1.0 ).linear( a, 0.0 ) ); + return( b.pow( -1.0 ).linear( a, 0.0 ) ); } -VImage -operator/( const VImage a, double b ) -{ - return( a.linear( 1.0 / b, 0.0 ) ); -} - -VImage -operator/( const std::vector a, const VImage b ) +VImage +operator/( const VImage a, double b ) { - return( b.pow( -1.0 ).linear( a, 0.0 ) ); + return( a.linear( 1.0 / b, 0.0 ) ); } -VImage -operator/( const VImage a, const std::vector b ) -{ - return( a.linear( vips::invert( b ), 0.0 ) ); +VImage +operator/( const std::vector a, const VImage b ) +{ + return( b.pow( -1.0 ).linear( a, 0.0 ) ); } -VImage & +VImage +operator/( const VImage a, const std::vector b ) +{ + return( a.linear( vips::invert( b ), 0.0 ) ); +} + +VImage & operator/=( VImage &a, const VImage b ) { - return( a = a / b ); + return( a = a / b ); } -VImage & +VImage & operator/=( VImage &a, const double b ) { - return( a = a / b ); + return( a = a / b ); } -VImage & +VImage & operator/=( VImage &a, const std::vector b ) { - return( a = a / b ); + return( a = a / b ); } -VImage -operator%( const VImage a, const VImage b ) +VImage +operator%( const VImage a, const VImage b ) { return( a.remainder( b ) ); } -VImage -operator%( const VImage a, const double b ) -{ - return( a.remainder_const( to_vector( b ) ) ); +VImage +operator%( const VImage a, const double b ) +{ + return( a.remainder_const( to_vector( b ) ) ); } -VImage -operator%( const VImage a, const std::vector b ) -{ - return( a.remainder_const( b ) ); +VImage +operator%( const VImage a, const std::vector b ) +{ + return( a.remainder_const( b ) ); } -VImage & +VImage & operator%=( VImage &a, const VImage b ) { - return( a = a % b ); + return( a = a % b ); } -VImage & +VImage & operator%=( VImage &a, const double b ) { - return( a = a % b ); + return( a = a % b ); } -VImage & +VImage & operator%=( VImage &a, const std::vector b ) { - return( a = a % b ); + return( a = a % b ); } -VImage -operator<( const VImage a, const VImage b ) +VImage +operator<( const VImage a, const VImage b ) { return( a.relational( b, VIPS_OPERATION_RELATIONAL_LESS ) ); } -VImage -operator<( const double a, const VImage b ) +VImage +operator<( const double a, const VImage b ) { - return( b.relational_const( VIPS_OPERATION_RELATIONAL_MORE, - to_vector( a ) ) ); + return( b.relational_const( VIPS_OPERATION_RELATIONAL_MORE, + to_vector( a ) ) ); } -VImage -operator<( const VImage a, const double b ) -{ - return( a.relational_const( VIPS_OPERATION_RELATIONAL_LESS, - to_vector( b ) ) ); -} - -VImage -operator<( const std::vector a, const VImage b ) +VImage +operator<( const VImage a, const double b ) { - return( b.relational_const( VIPS_OPERATION_RELATIONAL_MORE, - a ) ); + return( a.relational_const( VIPS_OPERATION_RELATIONAL_LESS, + to_vector( b ) ) ); } -VImage -operator<( const VImage a, const std::vector b ) -{ - return( a.relational_const( VIPS_OPERATION_RELATIONAL_LESS, - b ) ); +VImage +operator<( const std::vector a, const VImage b ) +{ + return( b.relational_const( VIPS_OPERATION_RELATIONAL_MORE, + a ) ); } -VImage -operator<=( const VImage a, const VImage b ) +VImage +operator<( const VImage a, const std::vector b ) +{ + return( a.relational_const( VIPS_OPERATION_RELATIONAL_LESS, + b ) ); +} + +VImage +operator<=( const VImage a, const VImage b ) { return( a.relational( b, VIPS_OPERATION_RELATIONAL_LESSEQ ) ); } -VImage -operator<=( const double a, const VImage b ) +VImage +operator<=( const double a, const VImage b ) { - return( b.relational_const( VIPS_OPERATION_RELATIONAL_MOREEQ, - to_vector( a ) ) ); + return( b.relational_const( VIPS_OPERATION_RELATIONAL_MOREEQ, + to_vector( a ) ) ); } -VImage -operator<=( const VImage a, const double b ) -{ - return( a.relational_const( VIPS_OPERATION_RELATIONAL_LESSEQ, - to_vector( b ) ) ); +VImage +operator<=( const VImage a, const double b ) +{ + return( a.relational_const( VIPS_OPERATION_RELATIONAL_LESSEQ, + to_vector( b ) ) ); } -VImage -operator<=( const std::vector a, const VImage b ) +VImage +operator<=( const std::vector a, const VImage b ) { - return( b.relational_const( VIPS_OPERATION_RELATIONAL_MOREEQ, + return( b.relational_const( VIPS_OPERATION_RELATIONAL_MOREEQ, a ) ); } -VImage -operator<=( const VImage a, const std::vector b ) -{ +VImage +operator<=( const VImage a, const std::vector b ) +{ return( a.relational_const( VIPS_OPERATION_RELATIONAL_LESSEQ, b ) ); } -VImage -operator>( const VImage a, const VImage b ) +VImage +operator>( const VImage a, const VImage b ) { return( a.relational( b, VIPS_OPERATION_RELATIONAL_MORE ) ); } -VImage -operator>( const double a, const VImage b ) +VImage +operator>( const double a, const VImage b ) { - return( b.relational_const( VIPS_OPERATION_RELATIONAL_LESS, - to_vector( a ) ) ); + return( b.relational_const( VIPS_OPERATION_RELATIONAL_LESS, + to_vector( a ) ) ); } -VImage -operator>( const VImage a, const double b ) -{ - return( a.relational_const( VIPS_OPERATION_RELATIONAL_MORE, +VImage +operator>( const VImage a, const double b ) +{ + return( a.relational_const( VIPS_OPERATION_RELATIONAL_MORE, to_vector( b ) ) ); } -VImage -operator>( const std::vector a, const VImage b ) +VImage +operator>( const std::vector a, const VImage b ) { - return( b.relational_const( VIPS_OPERATION_RELATIONAL_LESS, + return( b.relational_const( VIPS_OPERATION_RELATIONAL_LESS, a ) ); } -VImage -operator>( const VImage a, const std::vector b ) -{ - return( a.relational_const( VIPS_OPERATION_RELATIONAL_MORE, +VImage +operator>( const VImage a, const std::vector b ) +{ + return( a.relational_const( VIPS_OPERATION_RELATIONAL_MORE, b ) ); } -VImage -operator>=( const VImage a, const VImage b ) +VImage +operator>=( const VImage a, const VImage b ) { return( a.relational( b, VIPS_OPERATION_RELATIONAL_MOREEQ ) ); } -VImage -operator>=( const double a, const VImage b ) +VImage +operator>=( const double a, const VImage b ) { - return( b.relational_const( VIPS_OPERATION_RELATIONAL_LESSEQ, - to_vector( a ) ) ); + return( b.relational_const( VIPS_OPERATION_RELATIONAL_LESSEQ, + to_vector( a ) ) ); } -VImage -operator>=( const VImage a, const double b ) -{ - return( a.relational_const( VIPS_OPERATION_RELATIONAL_MOREEQ, - to_vector( b ) ) ); +VImage +operator>=( const VImage a, const double b ) +{ + return( a.relational_const( VIPS_OPERATION_RELATIONAL_MOREEQ, + to_vector( b ) ) ); } -VImage -operator>=( const std::vector a, const VImage b ) +VImage +operator>=( const std::vector a, const VImage b ) { - return( b.relational_const( VIPS_OPERATION_RELATIONAL_LESSEQ, + return( b.relational_const( VIPS_OPERATION_RELATIONAL_LESSEQ, a ) ); } -VImage -operator>=( const VImage a, const std::vector b ) -{ - return( a.relational_const( VIPS_OPERATION_RELATIONAL_MOREEQ, +VImage +operator>=( const VImage a, const std::vector b ) +{ + return( a.relational_const( VIPS_OPERATION_RELATIONAL_MOREEQ, b ) ); } -VImage -operator==( const VImage a, const VImage b ) +VImage +operator==( const VImage a, const VImage b ) { return( a.relational( b, VIPS_OPERATION_RELATIONAL_EQUAL ) ); } -VImage -operator==( const double a, const VImage b ) +VImage +operator==( const double a, const VImage b ) { - return( b.relational_const( VIPS_OPERATION_RELATIONAL_EQUAL, + return( b.relational_const( VIPS_OPERATION_RELATIONAL_EQUAL, to_vector( a ) ) ); } -VImage -operator==( const VImage a, const double b ) -{ - return( a.relational_const( VIPS_OPERATION_RELATIONAL_EQUAL, +VImage +operator==( const VImage a, const double b ) +{ + return( a.relational_const( VIPS_OPERATION_RELATIONAL_EQUAL, to_vector( b ) ) ); } -VImage -operator==( const std::vector a, const VImage b ) +VImage +operator==( const std::vector a, const VImage b ) { - return( b.relational_const( VIPS_OPERATION_RELATIONAL_EQUAL, + return( b.relational_const( VIPS_OPERATION_RELATIONAL_EQUAL, a ) ); } -VImage -operator==( const VImage a, const std::vector b ) -{ - return( a.relational_const( VIPS_OPERATION_RELATIONAL_EQUAL, +VImage +operator==( const VImage a, const std::vector b ) +{ + return( a.relational_const( VIPS_OPERATION_RELATIONAL_EQUAL, b ) ); } -VImage -operator!=( const VImage a, const VImage b ) +VImage +operator!=( const VImage a, const VImage b ) { return( a.relational( b, VIPS_OPERATION_RELATIONAL_NOTEQ ) ); } -VImage -operator!=( const double a, const VImage b ) +VImage +operator!=( const double a, const VImage b ) { return( b.relational_const( VIPS_OPERATION_RELATIONAL_NOTEQ, - to_vector( a ) ) ); + to_vector( a ) ) ); } -VImage -operator!=( const VImage a, const double b ) -{ - return( a.relational_const( VIPS_OPERATION_RELATIONAL_NOTEQ, +VImage +operator!=( const VImage a, const double b ) +{ + return( a.relational_const( VIPS_OPERATION_RELATIONAL_NOTEQ, to_vector( b ) ) ); } -VImage -operator!=( const std::vector a, const VImage b ) +VImage +operator!=( const std::vector a, const VImage b ) { return( b.relational_const( VIPS_OPERATION_RELATIONAL_NOTEQ, a ) ); } -VImage -operator!=( const VImage a, const std::vector b ) -{ +VImage +operator!=( const VImage a, const std::vector b ) +{ return( a.relational_const( VIPS_OPERATION_RELATIONAL_NOTEQ, b ) ); } -VImage -operator&( const VImage a, const VImage b ) +VImage +operator&( const VImage a, const VImage b ) { return( a.boolean( b, VIPS_OPERATION_BOOLEAN_AND ) ); } -VImage -operator&( const double a, const VImage b ) +VImage +operator&( const double a, const VImage b ) { - return( b.boolean_const( VIPS_OPERATION_BOOLEAN_AND, - to_vector( a ) ) ); + return( b.boolean_const( VIPS_OPERATION_BOOLEAN_AND, + to_vector( a ) ) ); } -VImage -operator&( const VImage a, const double b ) -{ - return( a.boolean_const( VIPS_OPERATION_BOOLEAN_AND, +VImage +operator&( const VImage a, const double b ) +{ + return( a.boolean_const( VIPS_OPERATION_BOOLEAN_AND, to_vector( b ) ) ); } -VImage -operator&( const std::vector a, const VImage b ) +VImage +operator&( const std::vector a, const VImage b ) { return( b.boolean_const( VIPS_OPERATION_BOOLEAN_AND, a ) ); } -VImage -operator&( const VImage a, const std::vector b ) -{ +VImage +operator&( const VImage a, const std::vector b ) +{ return( a.boolean_const( VIPS_OPERATION_BOOLEAN_AND, b ) ); } -VImage & +VImage & operator&=( VImage &a, const VImage b ) { - return( a = a & b ); + return( a = a & b ); } -VImage & +VImage & operator&=( VImage &a, const double b ) { - return( a = a & b ); + return( a = a & b ); } -VImage & +VImage & operator&=( VImage &a, const std::vector b ) { - return( a = a & b ); + return( a = a & b ); } -VImage -operator|( const VImage a, const VImage b ) +VImage +operator|( const VImage a, const VImage b ) { return( a.boolean( b, VIPS_OPERATION_BOOLEAN_OR ) ); } -VImage -operator|( const double a, const VImage b ) +VImage +operator|( const double a, const VImage b ) { - return( b.boolean_const( VIPS_OPERATION_BOOLEAN_OR, - to_vector( a ) ) ); + return( b.boolean_const( VIPS_OPERATION_BOOLEAN_OR, + to_vector( a ) ) ); } -VImage -operator|( const VImage a, const double b ) -{ - return( a.boolean_const( VIPS_OPERATION_BOOLEAN_OR, +VImage +operator|( const VImage a, const double b ) +{ + return( a.boolean_const( VIPS_OPERATION_BOOLEAN_OR, to_vector( b ) ) ); } -VImage -operator|( const std::vector a, const VImage b ) +VImage +operator|( const std::vector a, const VImage b ) { - return( b.boolean_const( VIPS_OPERATION_BOOLEAN_OR, + return( b.boolean_const( VIPS_OPERATION_BOOLEAN_OR, a ) ); } -VImage -operator|( const VImage a, const std::vector b ) -{ - return( a.boolean_const( VIPS_OPERATION_BOOLEAN_OR, +VImage +operator|( const VImage a, const std::vector b ) +{ + return( a.boolean_const( VIPS_OPERATION_BOOLEAN_OR, b ) ); } -VImage & +VImage & operator|=( VImage &a, const VImage b ) { - return( a = a | b ); + return( a = a | b ); } -VImage & +VImage & operator|=( VImage &a, const double b ) { - return( a = a | b ); + return( a = a | b ); } -VImage & +VImage & operator|=( VImage &a, const std::vector b ) { - return( a = a | b ); + return( a = a | b ); } -VImage -operator^( const VImage a, const VImage b ) +VImage +operator^( const VImage a, const VImage b ) { return( a.boolean( b, VIPS_OPERATION_BOOLEAN_EOR ) ); } -VImage -operator^( const double a, const VImage b ) +VImage +operator^( const double a, const VImage b ) { - return( b.boolean_const( VIPS_OPERATION_BOOLEAN_EOR, - to_vector( a ) ) ); + return( b.boolean_const( VIPS_OPERATION_BOOLEAN_EOR, + to_vector( a ) ) ); } -VImage -operator^( const VImage a, const double b ) -{ - return( a.boolean_const( VIPS_OPERATION_BOOLEAN_EOR, - to_vector( b ) ) ); +VImage +operator^( const VImage a, const double b ) +{ + return( a.boolean_const( VIPS_OPERATION_BOOLEAN_EOR, + to_vector( b ) ) ); } -VImage -operator^( const std::vector a, const VImage b ) +VImage +operator^( const std::vector a, const VImage b ) { return( b.boolean_const( VIPS_OPERATION_BOOLEAN_EOR, a ) ); } -VImage -operator^( const VImage a, const std::vector b ) -{ +VImage +operator^( const VImage a, const std::vector b ) +{ return( a.boolean_const( VIPS_OPERATION_BOOLEAN_EOR, b ) ); } -VImage & +VImage & operator^=( VImage &a, const VImage b ) { - return( a = a ^ b ); + return( a = a ^ b ); } -VImage & +VImage & operator^=( VImage &a, const double b ) { - return( a = a ^ b ); + return( a = a ^ b ); } -VImage & +VImage & operator^=( VImage &a, const std::vector b ) { - return( a = a ^ b ); + return( a = a ^ b ); } -VImage -operator<<( const VImage a, const VImage b ) +VImage +operator<<( const VImage a, const VImage b ) { return( a.boolean( b, VIPS_OPERATION_BOOLEAN_LSHIFT ) ); } -VImage -operator<<( const VImage a, const double b ) -{ - return( a.boolean_const( VIPS_OPERATION_BOOLEAN_LSHIFT, - to_vector( b ) ) ); +VImage +operator<<( const VImage a, const double b ) +{ + return( a.boolean_const( VIPS_OPERATION_BOOLEAN_LSHIFT, + to_vector( b ) ) ); } -VImage -operator<<( const VImage a, const std::vector b ) -{ - return( a.boolean_const( VIPS_OPERATION_BOOLEAN_LSHIFT, - b ) ); +VImage +operator<<( const VImage a, const std::vector b ) +{ + return( a.boolean_const( VIPS_OPERATION_BOOLEAN_LSHIFT, + b ) ); } -VImage & +VImage & operator<<=( VImage &a, const VImage b ) { - return( a = a << b ); + return( a = a << b ); } -VImage & +VImage & operator<<=( VImage &a, const double b ) { - return( a = a << b ); + return( a = a << b ); } -VImage & +VImage & operator<<=( VImage &a, const std::vector b ) { - return( a = a << b ); + return( a = a << b ); } -VImage -operator>>( const VImage a, const VImage b ) +VImage +operator>>( const VImage a, const VImage b ) { return( a.boolean( b, VIPS_OPERATION_BOOLEAN_RSHIFT ) ); } -VImage -operator>>( const VImage a, const double b ) -{ - return( a.boolean_const( VIPS_OPERATION_BOOLEAN_RSHIFT, - to_vector( b ) ) ); -} - -VImage -operator>>( const VImage a, const std::vector b ) -{ +VImage +operator>>( const VImage a, const double b ) +{ return( a.boolean_const( VIPS_OPERATION_BOOLEAN_RSHIFT, - b ) ); + to_vector( b ) ) ); } -VImage & +VImage +operator>>( const VImage a, const std::vector b ) +{ + return( a.boolean_const( VIPS_OPERATION_BOOLEAN_RSHIFT, + b ) ); +} + +VImage & operator>>=( VImage &a, const VImage b ) { - return( a = a << b ); + return( a = a << b ); } -VImage & +VImage & operator>>=( VImage &a, const double b ) { - return( a = a << b ); + return( a = a << b ); } -VImage & +VImage & operator>>=( VImage &a, const std::vector b ) { - return( a = a << b ); + return( a = a << b ); } VIPS_NAMESPACE_END diff --git a/src/libvips/cplusplus/vips-operators.cpp b/src/libvips/cplusplus/vips-operators.cpp index 12694762..f8456a5f 100644 --- a/src/libvips/cplusplus/vips-operators.cpp +++ b/src/libvips/cplusplus/vips-operators.cpp @@ -1,5 +1,5 @@ // bodies for vips operations -// Wed 01 Jan 2020 12:22:12 PM CET +// Sun 5 Jul 22:36:37 BST 2020 // this file is generated automatically, do not edit! VImage VImage::CMC2LCh( VOption *options ) const @@ -754,6 +754,18 @@ VImage VImage::csvload( const char *filename, VOption *options ) return( out ); } +VImage VImage::csvload_source( VSource source, VOption *options ) +{ + VImage out; + + call( "csvload_source", + (options ? options : VImage::option())-> + set( "out", &out )-> + set( "source", source ) ); + + return( out ); +} + void VImage::csvsave( const char *filename, VOption *options ) const { call( "csvsave", @@ -762,6 +774,14 @@ void VImage::csvsave( const char *filename, VOption *options ) const set( "filename", filename ) ); } +void VImage::csvsave_target( VTarget target, VOption *options ) const +{ + call( "csvsave_target", + (options ? options : VImage::option())-> + set( "in", *this )-> + set( "target", target ) ); +} + VImage VImage::dE00( VImage right, VOption *options ) const { VImage out; @@ -1218,6 +1238,18 @@ VImage VImage::gifload_buffer( VipsBlob *buffer, VOption *options ) return( out ); } +VImage VImage::gifload_source( VSource source, VOption *options ) +{ + VImage out; + + call( "gifload_source", + (options ? options : VImage::option())-> + set( "out", &out )-> + set( "source", source ) ); + + return( out ); +} + VImage VImage::globalbalance( VOption *options ) const { VImage out; @@ -1297,6 +1329,18 @@ VImage VImage::heifload_buffer( VipsBlob *buffer, VOption *options ) return( out ); } +VImage VImage::heifload_source( VSource source, VOption *options ) +{ + VImage out; + + call( "heifload_source", + (options ? options : VImage::option())-> + set( "out", &out )-> + set( "source", source ) ); + + return( out ); +} + void VImage::heifsave( const char *filename, VOption *options ) const { call( "heifsave", @@ -1317,6 +1361,14 @@ VipsBlob *VImage::heifsave_buffer( VOption *options ) const return( buffer ); } +void VImage::heifsave_target( VTarget target, VOption *options ) const +{ + call( "heifsave_target", + (options ? options : VImage::option())-> + set( "in", *this )-> + set( "target", target ) ); +} + VImage VImage::hist_cum( VOption *options ) const { VImage out; @@ -2028,6 +2080,18 @@ VImage VImage::matload( const char *filename, VOption *options ) return( out ); } +VImage VImage::matrixinvert( VOption *options ) const +{ + VImage out; + + call( "matrixinvert", + (options ? options : VImage::option())-> + set( "in", *this )-> + set( "out", &out ) ); + + return( out ); +} + VImage VImage::matrixload( const char *filename, VOption *options ) { VImage out; @@ -2040,6 +2104,18 @@ VImage VImage::matrixload( const char *filename, VOption *options ) return( out ); } +VImage VImage::matrixload_source( VSource source, VOption *options ) +{ + VImage out; + + call( "matrixload_source", + (options ? options : VImage::option())-> + set( "out", &out )-> + set( "source", source ) ); + + return( out ); +} + void VImage::matrixprint( VOption *options ) const { call( "matrixprint", @@ -2055,6 +2131,14 @@ void VImage::matrixsave( const char *filename, VOption *options ) const set( "filename", filename ) ); } +void VImage::matrixsave_target( VTarget target, VOption *options ) const +{ + call( "matrixsave_target", + (options ? options : VImage::option())-> + set( "in", *this )-> + set( "target", target ) ); +} + double VImage::max( VOption *options ) const { double out; @@ -2256,6 +2340,18 @@ VImage VImage::pdfload_buffer( VipsBlob *buffer, VOption *options ) return( out ); } +VImage VImage::pdfload_source( VSource source, VOption *options ) +{ + VImage out; + + call( "pdfload_source", + (options ? options : VImage::option())-> + set( "out", &out )-> + set( "source", source ) ); + + return( out ); +} + int VImage::percent( double percent, VOption *options ) const { int threshold; @@ -2371,6 +2467,18 @@ VImage VImage::ppmload( const char *filename, VOption *options ) return( out ); } +VImage VImage::ppmload_source( VSource source, VOption *options ) +{ + VImage out; + + call( "ppmload_source", + (options ? options : VImage::option())-> + set( "out", &out )-> + set( "source", source ) ); + + return( out ); +} + void VImage::ppmsave( const char *filename, VOption *options ) const { call( "ppmsave", @@ -2379,6 +2487,14 @@ void VImage::ppmsave( const char *filename, VOption *options ) const set( "filename", filename ) ); } +void VImage::ppmsave_target( VTarget target, VOption *options ) const +{ + call( "ppmsave_target", + (options ? options : VImage::option())-> + set( "in", *this )-> + set( "target", target ) ); +} + VImage VImage::premultiply( VOption *options ) const { VImage out; diff --git a/src/pipeline.cc b/src/pipeline.cc index 7830d6b0..8c1cb9bc 100644 --- a/src/pipeline.cc +++ b/src/pipeline.cc @@ -703,7 +703,9 @@ class PipelineWorker : public Napi::AsyncWorker { ->set("strip", !baton->withMetadata) ->set("Q", baton->jpegQuality) ->set("interlace", baton->jpegProgressive) - ->set("no_subsample", baton->jpegChromaSubsampling == "4:4:4") + ->set("subsample_mode", baton->jpegChromaSubsampling == "4:4:4" + ? VIPS_FOREIGN_JPEG_SUBSAMPLE_OFF + : VIPS_FOREIGN_JPEG_SUBSAMPLE_ON) ->set("trellis_quant", baton->jpegTrellisQuantisation) ->set("quant_table", baton->jpegQuantisationTable) ->set("overshoot_deringing", baton->jpegOvershootDeringing) @@ -769,7 +771,7 @@ class PipelineWorker : public Napi::AsyncWorker { VipsArea *area = VIPS_AREA(image.tiffsave_buffer(VImage::option() ->set("strip", !baton->withMetadata) ->set("Q", baton->tiffQuality) - ->set("squash", baton->tiffSquash) + ->set("bitdepth", baton->tiffBitdepth) ->set("compression", baton->tiffCompression) ->set("predictor", baton->tiffPredictor) ->set("pyramid", baton->tiffPyramid) @@ -845,7 +847,9 @@ class PipelineWorker : public Napi::AsyncWorker { ->set("strip", !baton->withMetadata) ->set("Q", baton->jpegQuality) ->set("interlace", baton->jpegProgressive) - ->set("no_subsample", baton->jpegChromaSubsampling == "4:4:4") + ->set("subsample_mode", baton->jpegChromaSubsampling == "4:4:4" + ? VIPS_FOREIGN_JPEG_SUBSAMPLE_OFF + : VIPS_FOREIGN_JPEG_SUBSAMPLE_ON) ->set("trellis_quant", baton->jpegTrellisQuantisation) ->set("quant_table", baton->jpegQuantisationTable) ->set("overshoot_deringing", baton->jpegOvershootDeringing) @@ -891,7 +895,7 @@ class PipelineWorker : public Napi::AsyncWorker { image.tiffsave(const_cast(baton->fileOut.data()), VImage::option() ->set("strip", !baton->withMetadata) ->set("Q", baton->tiffQuality) - ->set("squash", baton->tiffSquash) + ->set("bitdepth", baton->tiffBitdepth) ->set("compression", baton->tiffCompression) ->set("predictor", baton->tiffPredictor) ->set("pyramid", baton->tiffPyramid) @@ -940,7 +944,7 @@ class PipelineWorker : public Napi::AsyncWorker { std::vector> options { {"Q", std::to_string(baton->jpegQuality)}, {"interlace", baton->jpegProgressive ? "TRUE" : "FALSE"}, - {"no_subsample", baton->jpegChromaSubsampling == "4:4:4" ? "TRUE": "FALSE"}, + {"subsample_mode", baton->jpegChromaSubsampling == "4:4:4" ? "off" : "on"}, {"trellis_quant", baton->jpegTrellisQuantisation ? "TRUE" : "FALSE"}, {"quant_table", std::to_string(baton->jpegQuantisationTable)}, {"overshoot_deringing", baton->jpegOvershootDeringing ? "TRUE": "FALSE"}, @@ -1306,7 +1310,7 @@ Napi::Value pipeline(const Napi::CallbackInfo& info) { baton->webpReductionEffort = sharp::AttrAsUint32(options, "webpReductionEffort"); baton->tiffQuality = sharp::AttrAsUint32(options, "tiffQuality"); baton->tiffPyramid = sharp::AttrAsBool(options, "tiffPyramid"); - baton->tiffSquash = sharp::AttrAsBool(options, "tiffSquash"); + baton->tiffBitdepth = sharp::AttrAsUint32(options, "tiffBitdepth"); baton->tiffTile = sharp::AttrAsBool(options, "tiffTile"); baton->tiffTileWidth = sharp::AttrAsUint32(options, "tiffTileWidth"); baton->tiffTileHeight = sharp::AttrAsUint32(options, "tiffTileHeight"); diff --git a/src/pipeline.h b/src/pipeline.h index 1ec5afba..722f7cf7 100644 --- a/src/pipeline.h +++ b/src/pipeline.h @@ -143,7 +143,7 @@ struct PipelineBaton { VipsForeignTiffCompression tiffCompression; VipsForeignTiffPredictor tiffPredictor; bool tiffPyramid; - bool tiffSquash; + int tiffBitdepth; bool tiffTile; int tiffTileHeight; int tiffTileWidth; @@ -251,7 +251,7 @@ struct PipelineBaton { tiffCompression(VIPS_FOREIGN_TIFF_COMPRESSION_JPEG), tiffPredictor(VIPS_FOREIGN_TIFF_PREDICTOR_HORIZONTAL), tiffPyramid(false), - tiffSquash(false), + tiffBitdepth(8), tiffTile(false), tiffTileHeight(256), tiffTileWidth(256), diff --git a/test/fixtures/expected/conv-sobel-horizontal.jpg b/test/fixtures/expected/conv-sobel-horizontal.jpg index f886a607..4a9e2423 100644 Binary files a/test/fixtures/expected/conv-sobel-horizontal.jpg and b/test/fixtures/expected/conv-sobel-horizontal.jpg differ diff --git a/test/fixtures/expected/extract.webp b/test/fixtures/expected/extract.webp index 9165ab5a..e090ce73 100644 Binary files a/test/fixtures/expected/extract.webp and b/test/fixtures/expected/extract.webp differ diff --git a/test/fixtures/expected/tint-cmyk.jpg b/test/fixtures/expected/tint-cmyk.jpg index bdcdef05..715898a7 100644 Binary files a/test/fixtures/expected/tint-cmyk.jpg and b/test/fixtures/expected/tint-cmyk.jpg differ diff --git a/test/unit/failOnError.js b/test/unit/failOnError.js index b2f5837e..df0147bd 100644 --- a/test/unit/failOnError.js +++ b/test/unit/failOnError.js @@ -23,7 +23,7 @@ describe('failOnError', function () { let isWarningEmitted = false; sharp(fixtures.inputPngTruncated, { failOnError: false }) .on('warning', function (warning) { - assert.strictEqual('not enough data', warning); + assert.ok(warning.includes('not enough data') || warning.includes('end of stream')); isWarningEmitted = true; }) .resize(320, 240) @@ -62,7 +62,7 @@ describe('failOnError', function () { it('returns errors to callback for truncated PNG', function (done) { sharp(fixtures.inputPngTruncated).toBuffer(function (err, data, info) { - assert.ok(err.message.includes('vipspng: libpng read error'), err); + assert.ok(err.message.includes('read error'), err); assert.strictEqual(data, undefined); assert.strictEqual(info, undefined); done(); diff --git a/test/unit/tiff.js b/test/unit/tiff.js index 5c11eb6a..ec94db7c 100644 --- a/test/unit/tiff.js +++ b/test/unit/tiff.js @@ -116,7 +116,7 @@ describe('TIFF', function () { sharp(fixtures.inputTiff8BitDepth) .toColourspace('b-w') // can only squash 1 band uchar images .tiff({ - squash: false, + bitdepth: 8, compression: 'none', predictor: 'none' }) @@ -133,7 +133,7 @@ describe('TIFF', function () { sharp(fixtures.inputTiff8BitDepth) .toColourspace('b-w') // can only squash 1 band uchar images .tiff({ - squash: true, + bitdepth: 1, compression: 'none', predictor: 'none' }) @@ -145,10 +145,10 @@ describe('TIFF', function () { }); }); - it('Invalid TIFF squash value throws error', function () { + it('Invalid TIFF bitdepth value throws error', function () { assert.throws(function () { - sharp().tiff({ squash: 'true' }); - }); + sharp().tiff({ bitdepth: 3 }); + }, /Error: Expected 1, 2, 4 or 8 for bitdepth but received 3 of type number/); }); it('TIFF setting xres and yres on file', () => @@ -255,7 +255,7 @@ describe('TIFF', function () { sharp(fixtures.inputTiff) .toColourspace('b-w') .tiff({ - squash: true, + bitdepth: 1, compression: 'ccittfax4' }) .toFile(fixtures.outputTiff, (err, info) => {