diff --git a/CHANGELOG.md b/CHANGELOG.md index 03dc9797e..3ea229d83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [v0.0.6] - TBD -Uses libvips v8.14.5, compiled with Emscripten v3.1.46. +Uses libvips v8.15.0, compiled with Emscripten v3.1.46. + +### Changed + +- Update methods/enums for libvips 8.15. ## [v0.0.5] - 2023-04-27 diff --git a/build.sh b/build.sh index d4673c06f..0c33345d9 100755 --- a/build.sh +++ b/build.sh @@ -183,7 +183,7 @@ VERSION_TIFF=4.6.0 # https://gitlab.com/libtiff/libtiff VERSION_RESVG=0.35.0 # https://github.com/RazrFalcon/resvg VERSION_AOM=3.7.0 # https://aomedia.googlesource.com/aom VERSION_HEIF=1.16.2 # https://github.com/strukturag/libheif -VERSION_VIPS=8.14.5 # https://github.com/libvips/libvips +VERSION_VIPS=0789614 # https://github.com/libvips/libvips # Remove patch version component without_patch() { @@ -450,14 +450,14 @@ node --version [ -f "$TARGET/lib/pkgconfig/vips.pc" ] || ( stage "Compiling vips" mkdir $DEPS/vips - curl -Ls https://github.com/libvips/libvips/releases/download/v$VERSION_VIPS/vips-$(without_prerelease $VERSION_VIPS).tar.xz | tar xJC $DEPS/vips --strip-components=1 + curl -Ls https://github.com/libvips/libvips/archive/$VERSION_VIPS.tar.gz | tar xzC $DEPS/vips --strip-components=1 cd $DEPS/vips # Emscripten specific patches - curl -Ls https://github.com/libvips/libvips/compare/v$VERSION_VIPS...kleisauke:wasm-vips-8.14.patch | patch -p1 + curl -Ls https://github.com/libvips/libvips/compare/$VERSION_VIPS...kleisauke:wasm-vips-8.15.patch | patch -p1 # Disable building man pages, gettext po files, tools, and (fuzz-)tests sed -i "/subdir('man')/{N;N;N;N;d;}" meson.build meson setup _build --prefix=$TARGET --cross-file=$MESON_CROSS --default-library=static --buildtype=release \ - -Ddeprecated=false -Dexamples=false -Dcplusplus=$LIBVIPS_CPP -Dintrospection=false -Dauto_features=disabled \ + -Ddeprecated=false -Dexamples=false -Dcplusplus=$LIBVIPS_CPP -Dauto_features=disabled \ ${ENABLE_MODULES:+-Dmodules=enabled} -Dcgif=enabled -Dexif=enabled ${ENABLE_AVIF:+-Dheif=enabled} \ -Dheif-module=enabled -Dimagequant=enabled -Djpeg=enabled ${ENABLE_JXL:+-Djpeg-xl=enabled} \ -Djpeg-xl-module=enabled -Dlcms=enabled ${ENABLE_SVG:+-Dresvg=enabled} -Dresvg-module=enabled \ diff --git a/build/preamble_vips.d.ts b/build/preamble_vips.d.ts index 2d8ceab6a..ffe09c920 100644 --- a/build/preamble_vips.d.ts +++ b/build/preamble_vips.d.ts @@ -576,6 +576,10 @@ declare module Vips { * loaders are permissive, that is, [[FailOn.none]]. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean }): Image; /** @@ -641,6 +645,10 @@ declare module Vips { * loaders are permissive, that is, [[FailOn.none]]. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean }): Image; /** @@ -663,6 +671,10 @@ declare module Vips { * loaders are permissive, that is, [[FailOn.none]]. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean }): Image; /** @@ -966,6 +978,10 @@ declare module Vips { * Color for background pixels. */ background?: ArrayConstant + /** + * Enable line art mode. + */ + line_art?: boolean }): { /** * Output left edge. diff --git a/lib/vips.d.ts b/lib/vips.d.ts index e97c352a1..315e43f56 100644 --- a/lib/vips.d.ts +++ b/lib/vips.d.ts @@ -576,6 +576,10 @@ declare module Vips { * loaders are permissive, that is, [[FailOn.none]]. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean }): Image; /** @@ -641,6 +645,10 @@ declare module Vips { * loaders are permissive, that is, [[FailOn.none]]. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean }): Image; /** @@ -663,6 +671,10 @@ declare module Vips { * loaders are permissive, that is, [[FailOn.none]]. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean }): Image; /** @@ -966,6 +978,10 @@ declare module Vips { * Color for background pixels. */ background?: ArrayConstant + /** + * Enable line art mode. + */ + line_art?: boolean }): { /** * Output left edge. @@ -1722,30 +1738,28 @@ declare module Vips { } /** - * See vips_image_pipelinev(). Operations can hint to the VIPS image IO - * system about the kind of demand geometry they prefer. + * See vips_image_pipelinev(). Operations can hint + * the kind of demand geometry they prefer + * to the VIPS image IO system. * * These demand styles are given below in order of increasing - * restrictiveness. When demanding output from a pipeline, + * specialisation. When demanding output from a pipeline, * vips_image_generate() - * will use the most restrictive of the styles requested by the operations + * will use the most general style requested by the operations * in the pipeline. * - * #VIPS_DEMAND_STYLE_THINSTRIP --- This operation would like to output strips - * the width of the image and a few pels high. This is option suitable for - * point-to-point operations, such as those in the arithmetic package. - * - * This option is only efficient for cases where each output pel depends - * upon the pel in the corresponding position in the input image. + * #VIPS_DEMAND_STYLE_SMALLTILE --- This is the most general demand format. + * Output is demanded in small (around 100x100 pel) sections. This style works + * reasonably efficiently, even for bizarre operations like 45 degree rotate. * * #VIPS_DEMAND_STYLE_FATSTRIP --- This operation would like to output strips * the width of the image and as high as possible. This option is suitable * for area operations which do not violently transform coordinates, such * as vips_conv(). * - * #VIPS_DEMAND_STYLE_SMALLTILE --- This is the most general demand format. - * Output is demanded in small (around 100x100 pel) sections. This style works - * reasonably efficiently, even for bizzare operations like 45 degree rotate. + * #VIPS_DEMAND_STYLE_THINSTRIP --- This operation would like to output strips + * the width of the image and a few pels high. This option is suitable for + * point-to-point operations, such as those in the arithmetic package. * * #VIPS_DEMAND_STYLE_ANY --- This image is not being demand-read from a disc * file (even indirectly) so any demand style is OK. It's used for things like @@ -1755,11 +1769,11 @@ declare module Vips { */ enum DemandStyle { /** - * Demand in small (typically 64x64 pixel) tiles + * Demand in small (typically 128x128 pixel) tiles */ smalltile = 'smalltile', /** - * Demand in fat (typically 10 pixel high) strips + * Demand in fat (typically 16 pixel high) strips */ fatstrip = 'fatstrip', /** @@ -1829,15 +1843,15 @@ declare module Vips { */ enum OperationMath2 { /** - * Pow( left, right ) + * Pow(left, right) */ pow = 'pow', /** - * Pow( right, left ) + * Pow(right, left) */ wop = 'wop', /** - * Atan2( left, right ) + * Atan2(left, right) */ atan2 = 'atan2' } @@ -2825,6 +2839,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -2937,6 +2955,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -2978,6 +3000,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -3021,6 +3047,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -3046,6 +3076,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -3128,6 +3162,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -3161,6 +3199,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -3194,6 +3236,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -3249,6 +3295,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -3290,6 +3340,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -3331,6 +3385,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -3380,6 +3438,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -3409,6 +3471,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -3438,6 +3504,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -3475,6 +3545,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -3512,6 +3586,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -3549,6 +3627,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -3574,6 +3656,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -3599,6 +3685,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -3624,6 +3714,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -3679,6 +3773,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -3716,6 +3814,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -4029,6 +4131,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -4054,6 +4160,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -4079,6 +4189,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -4104,6 +4218,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -4129,6 +4247,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -4154,6 +4276,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -4199,6 +4325,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -4244,6 +4374,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -4293,6 +4427,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -4342,6 +4480,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -4391,6 +4533,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -4442,6 +4588,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -4471,6 +4621,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -4500,6 +4654,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -4525,6 +4683,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -4550,6 +4712,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -4582,6 +4748,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -4607,6 +4777,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -4632,6 +4806,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -4672,6 +4850,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -4738,6 +4920,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -4775,6 +4961,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -4812,6 +5002,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -5087,6 +5281,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -5128,6 +5326,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -5169,6 +5371,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -5242,6 +5448,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -5267,6 +5477,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -5304,6 +5518,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -5341,6 +5559,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -5378,6 +5600,10 @@ declare module Vips { * Error level to fail on. */ fail_on?: FailOn | Enum + /** + * Don't use a cached result for this operation. + */ + revalidate?: boolean /** * Flags for this file (output). */ @@ -5924,7 +6150,7 @@ declare module Vips { convi(mask: Image | ArrayConstant): Image; /** - * Seperable convolution operation. + * Separable convolution operation. * @param mask Input matrix image. * @param options Optional options. * @return Output image. @@ -6205,9 +6431,9 @@ declare module Vips { */ dzsave(filename: string, options?: { /** - * Base name to save to. + * Image name. */ - basename?: string + imagename?: string /** * Directory layout. */ @@ -6260,6 +6486,10 @@ declare module Vips { * Resource id. */ id?: string + /** + * Q factor. + */ + Q?: number /** * Strip all metadata from image. */ @@ -6281,9 +6511,9 @@ declare module Vips { */ dzsaveBuffer(options?: { /** - * Base name to save to. + * Image name. */ - basename?: string + imagename?: string /** * Directory layout. */ @@ -6336,6 +6566,10 @@ declare module Vips { * Resource id. */ id?: string + /** + * Q factor. + */ + Q?: number /** * Strip all metadata from image. */ @@ -6357,9 +6591,9 @@ declare module Vips { */ dzsaveTarget(target: Target, options?: { /** - * Base name to save to. + * Image name. */ - basename?: string + imagename?: string /** * Directory layout. */ @@ -6412,6 +6646,10 @@ declare module Vips { * Resource id. */ id?: string + /** + * Q factor. + */ + Q?: number /** * Strip all metadata from image. */ @@ -8502,6 +8740,12 @@ declare module Vips { max_alpha?: number }): Image; + /** + * Prewitt edge detector. + * @return Output image. + */ + prewitt(): Image; + /** * Resample an image with a quadratic transform. * @param coeff Coefficient matrix. @@ -8850,6 +9094,12 @@ declare module Vips { log?: boolean }): Image; + /** + * Scharr edge detector. + * @return Output image. + */ + scharr(): Image; + /** * Check sequential access. * @param options Optional options. @@ -8992,6 +9242,10 @@ declare module Vips { * How to measure interestingness. */ interesting?: Interesting | Enum + /** + * Input image already has premultiplied alpha. + */ + premultiplied?: boolean /** * Horizontal position of attention centre (output). */ diff --git a/src/bindings/vips-operators.cpp b/src/bindings/vips-operators.cpp index d99f48136..677fd369d 100644 --- a/src/bindings/vips-operators.cpp +++ b/src/bindings/vips-operators.cpp @@ -3186,6 +3186,18 @@ Image Image::premultiply(emscripten::val js_options) const return out; } +Image Image::prewitt() const +{ + Image out; + + this->call("prewitt", + (new Option) + ->set("in", *this) + ->set("out", &out)); + + return out; +} + Image Image::profile(Image *rows) const { Image columns; @@ -3546,6 +3558,18 @@ Image Image::scale(emscripten::val js_options) const return out; } +Image Image::scharr() const +{ + Image out; + + this->call("scharr", + (new Option) + ->set("in", *this) + ->set("out", &out)); + + return out; +} + Image Image::sequential(emscripten::val js_options) const { Image out; diff --git a/src/bindings/vips-operators.h b/src/bindings/vips-operators.h index f3742cdeb..a5837bb92 100644 --- a/src/bindings/vips-operators.h +++ b/src/bindings/vips-operators.h @@ -1068,7 +1068,7 @@ Image convf(emscripten::val mask) const; Image convi(emscripten::val mask) const; /** - * Seperable convolution operation. + * Separable convolution operation. * @param mask Input matrix image. * @param js_options Optional options. * @return Output image. @@ -1889,6 +1889,12 @@ void ppmsave_target(const Target &target, emscripten::val js_options = emscripte */ Image premultiply(emscripten::val js_options = emscripten::val::null()) const; +/** + * Prewitt edge detector. + * @return Output image. + */ +Image prewitt() const; + /** * Find image profiles. * @param rows First non-zero pixel in row. @@ -2092,6 +2098,12 @@ Image scRGB2sRGB(emscripten::val js_options = emscripten::val::null()) const; */ Image scale(emscripten::val js_options = emscripten::val::null()) const; +/** + * Scharr edge detector. + * @return Output image. + */ +Image scharr() const; + /** * Check sequential access. * @param js_options Optional options. diff --git a/src/vips-emscripten.cpp b/src/vips-emscripten.cpp index d5180a4ef..5bfbf25ef 100644 --- a/src/vips-emscripten.cpp +++ b/src/vips-emscripten.cpp @@ -1847,6 +1847,7 @@ EMSCRIPTEN_BINDINGS(my_module) { .function("premultiply", optional_override([](const Image &image) { return image.premultiply(); })) + .function("prewitt", &Image::prewitt) .function("quadratic", &Image::quadratic) .function("quadratic", optional_override([](const Image &image, emscripten::val coeff) { return image.quadratic(coeff); @@ -1914,6 +1915,7 @@ EMSCRIPTEN_BINDINGS(my_module) { .function("scale", optional_override([](const Image &image) { return image.scale(); })) + .function("scharr", &Image::scharr) .function("sequential", &Image::sequential) .function("sequential", optional_override([](const Image &image) { return image.sequential(); diff --git a/test/bench/perf.js b/test/bench/perf.js index 51580ee93..e446f823e 100644 --- a/test/bench/perf.js +++ b/test/bench/perf.js @@ -8,8 +8,9 @@ import { inputJpg, inputPng, inputWebP, getPath } from './images.js'; const width = 720; -// vips_thumbnail resize behavior is based on a square bounding box, so -// pass a huge value to resize on a specific axis instead. +// `vips_thumbnail` resize behavior is based on a square bounding box. +// To resize along a specific axis, pass a huge value to the opposite axis. +// See: https://github.com/libvips/libvips/pull/1639 const height = 10000000; // = VIPS_MAX_COORD const jpegOut = getPath('output.jpg'); diff --git a/test/unit/test_arithmetic.js b/test/unit/test_arithmetic.js index cce9f023a..fcabddeff 100644 --- a/test/unit/test_arithmetic.js +++ b/test/unit/test_arithmetic.js @@ -758,6 +758,7 @@ describe('arithmetic', () => { const testRgb = test.bandjoin([test, test]); const trim = testRgb.findTrim({ + line_art: true, background: [255, 255, 255] }); diff --git a/test/unit/test_colour.js b/test/unit/test_colour.js index 654d6d0e9..f184d07d9 100644 --- a/test/unit/test_colour.js +++ b/test/unit/test_colour.js @@ -29,7 +29,11 @@ describe('colour', () => { } const pixel = im.getpoint(10, 10); - expect(pixel[3]).to.be.closeTo(42, 0.01); + if (col === 'scrgb') { + expect(pixel[3]).to.be.closeTo(42.0 / 255.0, 0.0001); + } else { + expect(pixel[3]).to.be.closeTo(42, 0.01); + } } // alpha won't be equal for RGB16, but it should be preserved if we go diff --git a/test/unit/test_create.js b/test/unit/test_create.js index 2107da0dc..f3f7678b1 100644 --- a/test/unit/test_create.js +++ b/test/unit/test_create.js @@ -496,12 +496,14 @@ describe('create', () => { return this.skip(); } - let im = vips.Image.text('Hello, world!'); + let im = vips.Image.text('Hello, world!', { + dpi: 300 + }); expect(im.width).to.be.above(10); expect(im.height).to.be.above(10); expect(im.bands).to.equal(1); expect(im.format).to.equal('uchar'); - expect(im.max()).to.equal(255); + expect(im.max()).to.be.above(240); expect(im.min()).to.equal(0); // test autofit diff --git a/test/unit/test_foreign.js b/test/unit/test_foreign.js index cd06c48d1..b157f10dc 100644 --- a/test/unit/test_foreign.js +++ b/test/unit/test_foreign.js @@ -148,7 +148,7 @@ describe('foreign', () => { it('vips', function () { // ftruncate() is not yet available in the Node backend of WasmFS. - // https://github.com/emscripten-core/emscripten/blob/3.1.42/system/lib/wasmfs/backends/node_backend.cpp#L120-L122 + // https://github.com/emscripten-core/emscripten/blob/3.1.46/system/lib/wasmfs/backends/node_backend.cpp#L120-L122 if (typeof vips.FS.statBufToObject === 'function') { return this.skip(); } @@ -399,6 +399,7 @@ describe('foreign', () => { expect(im.width).to.equal(290); expect(im.height).to.equal(442); expect(im.bands).to.equal(3); + expect(im.getInt('bits-per-sample')).to.equal(16); }; fileLoader('pngload', Helpers.pngFile, pngValid); @@ -434,6 +435,7 @@ describe('foreign', () => { }); const after = vips.Image.newFromBuffer(buf, ''); expect(onebit.subtract(after).abs().max()).to.equal(0); + expect(after.getInt('bits-per-sample')).to.equal(1); // we can't test palette save since we can't be sure libimagequant is // available and there's no easy test for its presence @@ -452,6 +454,13 @@ describe('foreign', () => { const y = vips.Image.newFromBuffer(buf, ''); expect(y.getInt('orientation')).to.equal(2); } + + // Add EXIF to new PNG + const im1 = vips.Image.black(8, 8); + im1.setString('exif-ifd0-ImageDescription', 'test description'); + const im2 = vips.Image.newFromBuffer(im1.pngsaveBuffer(), ''); + expect(im2.getString('exif-ifd0-ImageDescription')).to.satisfy(desc => + desc.startsWith('test description')); }); it('tiff', function () { @@ -466,6 +475,7 @@ describe('foreign', () => { expect(im.width).to.equal(290); expect(im.height).to.equal(442); expect(im.bands).to.equal(3); + expect(im.getInt('bits-per-sample')).to.equal(16); }; fileLoader('tiffload', Helpers.tifFile, tiffValid); @@ -479,6 +489,7 @@ describe('foreign', () => { expect(im.width).to.equal(256); expect(im.height).to.equal(4); expect(im.bands).to.equal(1); + expect(im.getInt('bits-per-sample')).to.equal(1); }; fileLoader('tiffload', Helpers.tif1File, tiff1Valid); @@ -491,6 +502,7 @@ describe('foreign', () => { expect(im.width).to.equal(256); expect(im.height).to.equal(4); expect(im.bands).to.equal(1); + expect(im.getInt('bits-per-sample')).to.equal(2); }; fileLoader('tiffload', Helpers.tif2File, tiff2Valid); @@ -503,6 +515,7 @@ describe('foreign', () => { expect(im.width).to.equal(256); expect(im.height).to.equal(4); expect(im.bands).to.equal(1); + expect(im.getInt('bits-per-sample')).to.equal(4); }; fileLoader('tiffload', Helpers.tif4File, tiff4Valid); @@ -753,17 +766,24 @@ describe('foreign', () => { expect(im.width).to.equal(159); expect(im.height).to.equal(203); expect(im.bands).to.equal(3); + expect(im.getInt('bits-per-sample')).to.equal(4); }; fileLoader('gifload', Helpers.gifFile, gifValid); bufferLoader('gifload_buffer', Helpers.gifFile, gifValid); // test metadata - let x1 = vips.Image.newFromFile(Helpers.gifAnimFile, { n: -1 }); + let x1 = vips.Image.newFromFile(Helpers.gifFile, { n: -1 }); + expect(x1.getInt('n-pages')).to.equal(1); + expect(x1.getArrayDouble('background')).to.deep.equal([81.0, 81.0, 81.0]); + expect(x1.getInt('interlaced')).to.equal(1); + + x1 = vips.Image.newFromFile(Helpers.gifAnimFile, { n: -1 }); // our test gif has delay 0 for the first frame set in error expect(x1.getArrayInt('delay')).to.deep.equal([0, 50, 50, 50, 50]); expect(x1.getInt('loop')).to.equal(32761); expect(x1.getArrayDouble('background')).to.deep.equal([255.0, 255.0, 255.0]); + expect(x1.getTypeof('interlaced')).to.equal(0); // test deprecated fields too expect(x1.getInt('gif-loop')).to.equal(32760); expect(x1.getInt('gif-delay')).to.equal(0); @@ -961,6 +981,7 @@ describe('foreign', () => { expect(im.width).to.equal(3024); expect(im.height).to.equal(4032); expect(im.bands).to.equal(3); + expect(im.getInt('bits-per-sample')).to.equal(8); }; fileLoader('heifload', Helpers.avifFile, heifValid); @@ -1066,6 +1087,7 @@ describe('foreign', () => { expect(im.width).to.equal(290); expect(im.height).to.equal(442); expect(im.bands).to.equal(4); + expect(im.getInt('bits-per-sample')).to.equal(8); }; fileLoader('jxlload', Helpers.jxlFile, jxlValid); diff --git a/test/unit/test_iofuncs.js b/test/unit/test_iofuncs.js index b0235ac32..e1180ce06 100644 --- a/test/unit/test_iofuncs.js +++ b/test/unit/test_iofuncs.js @@ -62,4 +62,39 @@ describe('iofuncs', () => { expect(s).to.deep.equal(t); }); + + it('revalidate', function () { + // ftruncate() is not yet available in the Node backend of WasmFS. + // https://github.com/emscripten-core/emscripten/blob/3.1.46/system/lib/wasmfs/backends/node_backend.cpp#L120-L122 + if (typeof vips.FS.statBufToObject === 'function') { + return this.skip(); + } + + const filename = vips.Utils.tempName('%s.v'); + + const im1 = vips.Image.black(10, 10); + im1.writeToFile(filename); + + const load1 = vips.Image.newFromFile(filename); + expect(load1.width).to.equal(im1.width); + + const im2 = vips.Image.black(20, 20); + im2.writeToFile(filename); + + // this will use the old, cached load + let load2 = vips.Image.newFromFile(filename); + expect(load2.width).to.equal(im1.width); + + // load again with 'revalidate' and we should see the new image + load2 = vips.Image.newFromFile(filename, { + revalidate: true + }); + expect(load2.width).to.equal(im2.width); + + // load once more without revalidate and we should see the cached + // new image + load2 = vips.Image.newFromFile(filename); + load2.setDeleteOnClose(true); + expect(load2.width).to.equal(im2.width); + }); });