diff --git a/.make/release.mk b/.make/release.mk index da0cf31c0d..67d50cc1ec 100644 --- a/.make/release.mk +++ b/.make/release.mk @@ -9,11 +9,7 @@ release-dirs: DOCKER_LDFLAGS += -X "$(OC_REPO)/pkg/config/defaults.BaseDataPathType=path" -X "$(OC_REPO)/pkg/config/defaults.BaseDataPathValue=/var/lib/opencloud" DOCKER_LDFLAGS += -X "$(OC_REPO)/pkg/config/defaults.BaseConfigPathType=path" -X "$(OC_REPO)/pkg/config/defaults.BaseConfigPathValue=/etc/opencloud" -# We can't link statically when vips is enabled but we still -# prefer static linking where possible -ifndef ENABLE_VIPS - DOCKER_LDFLAGS += -extldflags "-static" -endif +DOCKER_LDFLAGS += -extldflags "-static" release-linux-docker-amd64: release-dirs GOOS=linux \ diff --git a/.vscode/launch.json b/.vscode/launch.json index 2df4ec3068..250a748b1f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -19,9 +19,6 @@ "type": "go", "request": "launch", "mode": "debug", - "buildFlags": [ - // "-tags", "enable_vips" - ], "program": "${workspaceFolder}/opencloud/cmd/opencloud", "args": ["server"], "env": { diff --git a/.woodpecker.star b/.woodpecker.star index 07b4e30440..b509f87279 100644 --- a/.woodpecker.star +++ b/.woodpecker.star @@ -806,20 +806,6 @@ def testOpencloud(ctx): "mv coverage.out unit.coverage.out", ], }, - { - # the only run that covers the resize code the official docker - # images ship - # FIXME: run it with the libvips those images ship, see issue 3746 - "name": "test-thumbnail-parity-vips", - "image": OC_CI_GOLANG, - "environment": { - "THUMBNAILS_PARITY_IMAGOR_URL": "http://imagor:8000", - "THUMBNAILS_PARITY_IMAGOR_MAGICK_URL": "http://imagor-magick:8000", - }, - "commands": [ - "go test -tags enable_vips ./services/thumbnails/pkg/parity/...", - ], - }, { "name": "codacy-coverage", "image": CODACY_COVERAGE_REPORTER, @@ -2650,7 +2636,7 @@ def build(): "name": "build", "image": OC_CI_GOLANG, "commands": [ - "for i in $(seq 3); do make -C opencloud build ENABLE_VIPS=1 && break || sleep 1; done", + "for i in $(seq 3); do make -C opencloud build && break || sleep 1; done", ], "environment": CI_HTTP_PROXY_ENV, }, diff --git a/Dockerfile b/Dockerfile index d5756b2717..e76bdd0a5c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,11 +26,11 @@ FROM quay.io/opencloudeu/golang-ci:1.26 AS build COPY --from=generate /opencloud /opencloud WORKDIR /opencloud/opencloud -RUN make go-generate build ENABLE_VIPS=true +RUN make go-generate build FROM alpine:3.24 -RUN apk add --no-cache attr ca-certificates curl mailcap tree vips && \ +RUN apk add --no-cache attr ca-certificates curl mailcap tree && \ echo 'hosts: files dns' >| /etc/nsswitch.conf LABEL maintainer="OpenCloud GmbH " \ diff --git a/go.mod b/go.mod index ea88912154..317236a7bb 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,6 @@ require ( github.com/cenkalti/backoff v2.2.1+incompatible github.com/coreos/go-oidc/v3 v3.21.0 github.com/cs3org/go-cs3apis v0.0.0-20260424072047-8d9ef7076ae9 - github.com/davidbyttow/govips/v2 v2.20.0 github.com/dhowden/tag v0.0.0-20240417053706-3d75831295e8 github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e github.com/gabriel-vasile/mimetype v1.4.15 diff --git a/go.sum b/go.sum index 0850faa2df..1ec8085787 100644 --- a/go.sum +++ b/go.sum @@ -223,8 +223,6 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davidbyttow/govips/v2 v2.20.0 h1:sftLOcLeI+sMPVrBiw/ulWHuMm0kKyTQ2hfnoIYSxwc= -github.com/davidbyttow/govips/v2 v2.20.0/go.mod h1:QK5liLrx7YaHC7xPcYnm4KaQIYvu9xSGrBt9goXrfgo= github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.1 h1:5RVFMOWjMyRy8cARdy79nAmgYw3hK/4HUq48LQ6Wwqo= diff --git a/opencloud/Makefile b/opencloud/Makefile index fe9d51a7ed..fe1afc9abd 100644 --- a/opencloud/Makefile +++ b/opencloud/Makefile @@ -3,9 +3,6 @@ NAME := opencloud TAGS := disable_crypt GOARCH := $(shell go env GOARCH) CONFIG_DOCS_BASE_PATH := ../docs -ifdef ENABLE_VIPS - TAGS := ${TAGS},enable_vips -endif ifneq (, $(shell command -v go 2> /dev/null)) # suppress `command not found warnings` for non go targets in CI include ../.bingo/Variables.mk diff --git a/opencloud/docker/Dockerfile.linux.debug.amd64 b/opencloud/docker/Dockerfile.linux.debug.amd64 index 5740fa9b2c..edf3f156ca 100644 --- a/opencloud/docker/Dockerfile.linux.debug.amd64 +++ b/opencloud/docker/Dockerfile.linux.debug.amd64 @@ -3,7 +3,7 @@ FROM amd64/alpine:edge ARG VERSION="" ARG REVISION="" -RUN apk add --no-cache attr bash ca-certificates curl delve inotify-tools libc6-compat mailcap tree vips patch && \ +RUN apk add --no-cache attr bash ca-certificates curl delve inotify-tools libc6-compat mailcap tree patch && \ echo 'hosts: files dns' >| /etc/nsswitch.conf LABEL maintainer="OpenCloud GmbH " \ diff --git a/opencloud/docker/Dockerfile.linux.debug.arm64 b/opencloud/docker/Dockerfile.linux.debug.arm64 index ef80f6a32e..6341048f93 100644 --- a/opencloud/docker/Dockerfile.linux.debug.arm64 +++ b/opencloud/docker/Dockerfile.linux.debug.arm64 @@ -3,7 +3,7 @@ FROM arm64v8/alpine:edge ARG VERSION="" ARG REVISION="" -RUN apk add --no-cache attr bash ca-certificates curl delve inotify-tools libc6-compat mailcap tree vips patch && \ +RUN apk add --no-cache attr bash ca-certificates curl delve inotify-tools libc6-compat mailcap tree patch && \ echo 'hosts: files dns' >| /etc/nsswitch.conf LABEL maintainer="OpenCloud GmbH " \ diff --git a/opencloud/docker/Dockerfile.multiarch b/opencloud/docker/Dockerfile.multiarch index e6d96ced54..6fbf8a684c 100644 --- a/opencloud/docker/Dockerfile.multiarch +++ b/opencloud/docker/Dockerfile.multiarch @@ -12,7 +12,7 @@ RUN --mount=type=bind,target=/build,rw \ --mount=type=cache,target=/root/.cache \ GOOS="${TARGETOS:-linux}" GOARCH="${TARGETARCH:-amd64}" ; \ make -C ${SRCDIR:-.}/opencloud release-linux-docker-${TARGETARCH} \ - ENABLE_VIPS=true DIST=/dist \ + DIST=/dist \ VERSION="${VERSION}" EDITION="${EDITION}" \ ${STRING:+STRING="${STRING}"} @@ -23,8 +23,7 @@ ARG TARGETOS ARG TARGETARCH RUN apk add --no-cache attr bash ca-certificates curl imagemagick \ - inotify-tools libc6-compat mailcap tree vips \ - vips-magick patch && \ + inotify-tools libc6-compat mailcap tree patch && \ echo 'hosts: files dns' >| /etc/nsswitch.conf LABEL maintainer="openCloud GmbH " \ diff --git a/services/thumbnails/README.md b/services/thumbnails/README.md index f0e12e0690..ee0f495705 100644 --- a/services/thumbnails/README.md +++ b/services/thumbnails/README.md @@ -22,7 +22,7 @@ source file to this endpoint and receives the processed image back. | `POST /unsafe/fit-in/{width}x{height}/filters:{filters}` | Scale to fit within width x height, preserving aspect ratio and never upscaling | | `POST /unsafe/stretch/{width}x{height}/filters:{filters}` | Resize to the exact width x height without preserving aspect ratio (distorts) | -A `smart` segment behind the box, `POST /unsafe/{width}x{height}/smart/filters:{filters}`, asks for the crop that keeps the region carrying the image rather than the middle, which is what webdav sends for every cropping resize. With libvips that is an attention crop; the pure Go build has nothing of the kind and crops the centre, as the thumbnails service has always done without libvips. +A `smart` segment behind the box, `POST /unsafe/{width}x{height}/smart/filters:{filters}`, asks for the crop that keeps the region carrying the image rather than the middle, which is what webdav sends for every cropping resize. A real imagor answers it with an attention crop; this service has nothing of the kind and crops the centre. The path is imagor's. The filters segment is optional and may be empty (`filters:`), and an image key behind it is accepted and ignored, because the @@ -34,11 +34,10 @@ resized, while this service treats it as the box. Inside the filters segment, filter is ignored. `format` itself is optional: without it the input's own format is preserved, the same way imagor does it. An input this service cannot write (tiff, bmp) becomes a JPEG; imagor writes tiff back in its own format and only -falls back to JPEG for the ones it cannot write either. Which formats those are -depends on the build: with libvips a webp source stays a webp, the pure Go build -answers it as a JPEG because it has no webp encoder. +falls back to JPEG for the ones it cannot write either. A webp source is +answered as a JPEG, because this service has no webp encoder. -What a build can read is its own backend's answer rather than a list: the library +What this service can read is its decoders' answer rather than a list: the library that will decode the image reads the header first, so a source it cannot read answers `406` before anything is decoded, and the maximum dimensions are checked on that same header. @@ -61,13 +60,11 @@ decides it, are the webdav service's business and documented in The request body is a `multipart/form-data` upload with a single file field named `image`, typed `image/*`; an untyped part is refused the way imagor's -upload loader refuses it. Output formats are `jpg`, `png`, `gif` and, with -libvips, `webp`; the pure Go build answers `406` for `format(webp)` because it -has no webp encoder. An animated gif asked for a still format is flattened to +upload loader refuses it. Output formats are `jpg`, `png` and `gif`; `format(webp)` +is answered with `406` because this service has no webp encoder. An animated gif asked for a still format is flattened to its first frame, and a still source asked for `format(gif)` is palettised. -Reading an ICO needs libvips with its magick loader; the pure Go build answers -`406` for one. +An ICO is answered with `406`; imagor reads one only with its magick loader. An animation is the one source whose frames are all decoded here, so what its blocks declare is read before any of them is: a gif with more frames than @@ -82,7 +79,7 @@ none. The answers are imagor's: `400` for a malformed request, which includes a `format` nobody writes (anything but `jpg`, `png`, `gif` and `webp`); `406` for a source it cannot read, for an upload part that is not typed `image/*`, and for a -format this build has no encoder for (`webp` without libvips); `422` for an image +format this service has no encoder for (`webp`); `422` for an image above the configured maximum dimensions and for an animation above the frame limit; `429` when the concurrency limit is reached; `413` for a body above `THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE`. @@ -107,41 +104,12 @@ The source and the thumbnail have ceilings of their own, for different reasons. A real imagor has one pair of knobs for both, `-vips-max-width` and `-vips-max-height`, which bound every image in its pipeline, the loaded source as well as the result. Set them to the source ceiling. They are also more forgiving than this service for formats libvips can shrink while loading: a 9000 pixel wide JPEG passes a 2048 limit there, where this service refuses it on the header. -## Using libvips for Image Processing +## Supported Formats -To improve performance and to support a wider range of image formats, the -thumbnails service is able to utilize the -[libvips library](https://www.libvips.org/) for image processing. Support for -libvips needs to be enabled at buildtime and has a couple of implications: - -- With libvips support enabled, it is not possible to create a statically - linked OpenCloud binary. -- Therefore, the libvips shared libraries need to be available at runtime in - the same release that was used to build the OpenCloud binary. -- When using the OpenCloud docker images, the libvips shared libraries are - included in the image and are correctly embedded. - -Support of libvips is disabled by default. To enable it, make sure libvips -and its buildtime dependencies are installed in your build environment. For -macOS users, add the build time dependencies via: - -```shell -brew install vips pkg-config -export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig" -``` - -Then you just need to set the `ENABLE_VIPS` variable on the `make` command: - -```shell -make -C opencloud build ENABLE_VIPS=1 -``` - -Or include the `enable_vips` build tag in the `go build` command: - -```shell -go build -tags enable_vips -o opencloud -o bin/opencloud ./cmd/opencloud -``` - -When building a docker image using the Dockerfile in the top-level directory of -OpenCloud, libvips support is enabled and the libvips shared libraries are -included in the resulting docker image. +This service deliberately supports a small set of formats, decoded and encoded in +pure Go: it reads `jpeg`, `png`, `gif`, `bmp`, `tiff` and `webp` and writes `jpg`, +`png` and `gif`. It is meant as a fallback generator that keeps working when +libvips or imagor need to be taken out of a deployment, for example while a +security issue in them is being fixed. A deployment that wants more formats, +webp output or an attention crop runs a real [imagor](https://imagor.net) and +points `WEBDAV_THUMBNAILS_GENERATOR_URL` at it. diff --git a/services/thumbnails/pkg/parity/build_imaging_test.go b/services/thumbnails/pkg/parity/build_imaging_test.go index c84331d19e..27a6250ebf 100644 --- a/services/thumbnails/pkg/parity/build_imaging_test.go +++ b/services/thumbnails/pkg/parity/build_imaging_test.go @@ -1,5 +1,3 @@ -//go:build !enable_vips - package parity const builtinBuild = "imaging" diff --git a/services/thumbnails/pkg/parity/build_vips_test.go b/services/thumbnails/pkg/parity/build_vips_test.go deleted file mode 100644 index 20b216f2ba..0000000000 --- a/services/thumbnails/pkg/parity/build_vips_test.go +++ /dev/null @@ -1,7 +0,0 @@ -//go:build enable_vips - -package parity - -// builtinBuild is the resize implementation compiled into this run, and the -// override key for a divergence only it has. The container images ship vips. -const builtinBuild = "vips" diff --git a/services/thumbnails/pkg/service/http/v0/push.go b/services/thumbnails/pkg/service/http/v0/push.go index 47e64d283a..8700966132 100644 --- a/services/thumbnails/pkg/service/http/v0/push.go +++ b/services/thumbnails/pkg/service/http/v0/push.go @@ -141,10 +141,9 @@ func (s Thumbnails) pushHandler(w http.ResponseWriter, r *http.Request) { MaxOutWidth: s.maxOutWidth, MaxOutHeight: s.maxOutHeight, } - // An animated gif is the one source both builds treat the same way: neither - // libvips nor the pure Go path has anything better for a paletted animation, - // so it never reaches a backend. Asking for a still format flattens it, and - // that is a backend's job again. + // An animated gif never reaches the still image backend, it is resized + // frame by frame. Asking for a still format flattens it, and that is the + // backend's job again. if bytes.HasPrefix(imgData, gifMagic) && (ext == "gif" || !hasFormat) { s.serveAnimation(w, imgData, req) diff --git a/services/thumbnails/pkg/service/http/v0/push_imaging.go b/services/thumbnails/pkg/service/http/v0/push_imaging.go index ef8a0813ed..583bca8538 100644 --- a/services/thumbnails/pkg/service/http/v0/push_imaging.go +++ b/services/thumbnails/pkg/service/http/v0/push_imaging.go @@ -1,5 +1,3 @@ -//go:build !enable_vips - package svc import ( @@ -15,9 +13,7 @@ import ( "github.com/kovidgoyal/imaging/prism/meta/autometa" ) -// The backend this build resizes with. The implementations keep their own names -// so a symbol search finds both builds' versions side by side, the variables are -// what the shared handler calls. +// The backend the service resizes with, as variables the shared handler calls. var ( loadSource = loadSourceImaging extForSourceFormat = extForSourceFormatImaging @@ -28,7 +24,7 @@ var ( encodeWebP = encodeWebPImaging ) -// imagingSource is a request's body as this build holds it between the header +// imagingSource is a request's body as the service holds it between the header // read and the resize: the bytes plus what the header said about them. The // pixels are decoded in resizeSourceImaging, so the dimension guard has its say // before anything allocates a frame buffer. @@ -38,8 +34,8 @@ type imagingSource struct { format string } -// loadSourceImaging reads the header through the stdlib decoder registry, which this -// build also decodes with: png, jpeg and gif from the stdlib, bmp, tiff and webp +// loadSourceImaging reads the header through the stdlib decoder registry, which the +// service also decodes with: png, jpeg and gif from the stdlib, bmp, tiff and webp // from the imaging library. func loadSourceImaging(data []byte) (*imagingSource, error) { config, format, err := image.DecodeConfig(bytes.NewReader(data)) @@ -51,14 +47,14 @@ func loadSourceImaging(data []byte) (*imagingSource, error) { } // Width and Height are what the header declared, so the dimension guard can ask -// before the pixels exist. Close is there because the libvips build's image has -// one; this build holds nothing that needs releasing. +// before the pixels exist. Close is a no-op, the source holds nothing that +// needs releasing. func (s *imagingSource) Width() int { return s.config.Width } func (s *imagingSource) Height() int { return s.config.Height } func (s *imagingSource) Close() {} // extForSourceFormatImaging is the output format for a request that asked for none: the -// input's own where this build can write it, a JPEG for the rest, which is how +// input's own where the service can write it, a JPEG for the rest, which is how // imagor answers a format it cannot write either. func extForSourceFormatImaging(src *imagingSource) string { switch src.format { @@ -160,8 +156,8 @@ func resizeSourceImaging(src *imagingSource, req resizeRequest) (image.Image, er return img, nil } - // smart() asks for the most interesting window, which needs libvips; - // this build crops the centre for it, the way main always did + // smart() asks for the most interesting window, which real imagor + // finds with libvips; this service crops the centre for it. return imaging.Thumbnail(img, req.Width, req.Height, imaging.Lanczos), nil } @@ -176,6 +172,6 @@ func encodeGIFImaging(w io.Writer, img image.Image) error { return gif.Encode(w, palettedAtOrigin(img, palette.Plan9), nil) } -// encodeWebPImaging refuses: there is no webp encoder in the pure Go build, so a -// deployment that needs webp output runs the libvips build or a real imagor. +// encodeWebPImaging refuses: there is no webp encoder in pure Go, so a +// deployment that needs webp output runs a real imagor. func encodeWebPImaging(io.Writer, image.Image) error { return errFormatUnsupported } diff --git a/services/thumbnails/pkg/service/http/v0/push_test.go b/services/thumbnails/pkg/service/http/v0/push_test.go index 94802b9ac1..9f3ec9ede3 100644 --- a/services/thumbnails/pkg/service/http/v0/push_test.go +++ b/services/thumbnails/pkg/service/http/v0/push_test.go @@ -226,7 +226,7 @@ var _ = Describe("outputFormatFromFilters", func() { Entry("jpeg maps onto our jpg", "format(jpeg)", "jpg", true, false), Entry("png", "format(png)", "png", true, false), Entry("gif", "format(gif)", "gif", true, false), - Entry("webp, which only the libvips build writes", "format(webp)", "webp", true, false), + Entry("webp, which only imagor writes", "format(webp)", "webp", true, false), Entry("behind another filter", "no_upscale():format(png)", "png", true, false), Entry("no format filter at all", "no_upscale()", "", false, false), Entry("an empty segment", "", "", false, false), diff --git a/services/thumbnails/pkg/service/http/v0/push_vips.go b/services/thumbnails/pkg/service/http/v0/push_vips.go deleted file mode 100644 index dd5c58a449..0000000000 --- a/services/thumbnails/pkg/service/http/v0/push_vips.go +++ /dev/null @@ -1,148 +0,0 @@ -//go:build enable_vips - -package svc - -import ( - "image/color/palette" - "image/gif" - "io" - - "github.com/davidbyttow/govips/v2/vips" -) - -// The backend this build resizes with, as variables the shared handler calls, so -// a symbol search finds both builds' implementations side by side. libvips is -// demand-driven: loading a buffer parses the header and leaves the pixels alone -// until something pulls them, so the dimension guard runs before any frame buffer -// exists. -var ( - loadSource = loadSourceVips - extForSourceFormat = extForSourceFormatVips - resizeSource = resizeSourceVips - encodeJPEG = encodeJPEGVips - encodePNG = encodePNGVips - encodeGIF = encodeGIFVips - encodeWebP = encodeWebPVips -) - -// loadSourceVips reads the header through libvips, which this build also decodes -// with, so whatever the deployed libvips reads is what this service accepts. -func loadSourceVips(data []byte) (*vips.ImageRef, error) { return vips.NewImageFromBuffer(data) } - -// extForSourceFormatVips is the output format for a request that asked for none: the -// input's own where this build can write it, a JPEG for the rest, which is how -// imagor answers a format it cannot write either. -func extForSourceFormatVips(src *vips.ImageRef) string { - switch src.Format() { - case vips.ImageTypePNG: - return "png" - case vips.ImageTypeGIF: - return "gif" - case vips.ImageTypeWEBP: - return "webp" - default: // jpeg, tiff, bmp, heif, ... - return "jpg" - } -} - -// resizeSourceVips resizes with libvips. The operation selects the resize/crop mode: -// fill (center-crop to the box, upscaling by default like real imagor's default -// resize), fit-in (fit within the box without cropping and without ever enlarging -// the source, like imagor without its upscale() filter), or stretch (resize to -// the exact box). noUpscale caps the default fill at the source size, mirroring -// imagor's no_upscale() filter. -func resizeSourceVips(src *vips.ImageRef, req resizeRequest) (*vips.ImageRef, error) { - if req.Width == 0 || req.Height == 0 { - boxW, boxH, resize, err := req.freeAxis(src.Width(), src.Height()) - if err != nil { - return nil, err - } - if resize { - if err := scaleTo(src, boxW, boxH); err != nil { - return nil, err - } - } - - return src, src.RemoveMetadata() - } - - switch req.Operation { - case OpStretch: - if err := scaleTo(src, req.Width, req.Height); err != nil { - return nil, err - } - case OpFitIn: - // imagor's fit-in only enlarges with the upscale() filter, which webdav - // never sends, so it always caps at the source size. - if err := src.ThumbnailWithSize(req.Width, req.Height, vips.InterestingNone, vips.SizeDown); err != nil { - return nil, err - } - default: // OpFill - // SizeBoth upscales a small source the way imagor's default resize does, - // no_upscale() caps it at the source size via SizeDown. - size := vips.SizeBoth - if req.NoUpscale { - size = vips.SizeDown - } - crop := vips.InterestingCentre - if req.Smart { - crop = vips.InterestingAttention - } - if err := src.ThumbnailWithSize(req.Width, req.Height, crop, size); err != nil { - return nil, err - } - } - - return src, src.RemoveMetadata() -} - -// scaleTo resizes to the exact box without preserving the aspect ratio. -func scaleTo(src *vips.ImageRef, width, height int) error { - hScale := float64(width) / float64(src.Width()) - vScale := float64(height) / float64(src.Height()) - - return src.ResizeWithVScale(hScale, vScale, vips.KernelLanczos3) -} - -// The encoders keep the image in libvips form up to here, so a JPEG comes out of -// libvips (progressive, quality 80) instead of a stdlib re-encode. -func encodeJPEGVips(w io.Writer, img *vips.ImageRef) error { - buf, _, err := img.ExportJpeg(vips.NewJpegExportParams()) - if err != nil { - return err - } - _, err = w.Write(buf) - - return err -} - -func encodePNGVips(w io.Writer, img *vips.ImageRef) error { - buf, _, err := img.ExportPng(vips.NewPngExportParams()) - if err != nil { - return err - } - _, err = w.Write(buf) - - return err -} - -// encodeGIFVips goes through the same palette the animated path uses, as libvips has -// no gif export. -func encodeGIFVips(w io.Writer, img *vips.ImageRef) error { - still, err := img.ToImage(vips.NewDefaultPNGExportParams()) - if err != nil { - return err - } - - return gif.Encode(w, palettedAtOrigin(still, palette.Plan9), nil) -} - -func encodeWebPVips(w io.Writer, img *vips.ImageRef) error { - buf, _, err := img.ExportWebp(vips.NewWebpExportParams()) - if err != nil { - return err - } - _, err = w.Write(buf) - - return err -} diff --git a/services/thumbnails/pkg/service/http/v0/resizegif.go b/services/thumbnails/pkg/service/http/v0/resizegif.go index f7c584e664..1d8443fcb3 100644 --- a/services/thumbnails/pkg/service/http/v0/resizegif.go +++ b/services/thumbnails/pkg/service/http/v0/resizegif.go @@ -10,9 +10,7 @@ import ( // resizeGIF resizes every frame of an animated gif, compositing each frame onto // a running canvas to honour the gif disposal method and re-palletting with -// Floyd-Steinberg dithering. Both backends share it: the frames go through -// imaging either way, because neither libvips nor the pure Go path has anything -// better for a paletted animation. Code adapted from +// Floyd-Steinberg dithering. Code adapted from // https://github.com/willnorris/gifresize. The only error is errBoxTooLarge. func resizeGIF(m *gif.GIF, req resizeRequest) (*gif.GIF, error) { srcX, srcY := m.Config.Width, m.Config.Height diff --git a/services/webdav/README.md b/services/webdav/README.md index 5b5aa464d7..a3d089ea7f 100644 --- a/services/webdav/README.md +++ b/services/webdav/README.md @@ -64,7 +64,7 @@ Without a processor two things decide, in this order. An unconstrained axis is a #### Thumbnail Generator -The thumbnails themselves are made by a generator the webdav service POSTs to, configured with `WEBDAV_THUMBNAILS_GENERATOR_URL` (and `WEBDAV_THUMBNAILS_GENERATOR_TIMEOUT`). The built-in thumbnails service speaks the imagor image endpoint, so a real [imagor](https://imagor.net) can be put in its place without changing anything else. A source the generator cannot read answers `404`, one that is too large `403`, and `WEBDAV_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE` caps what is sent at all; `OC_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE` sets this and the generator's own cap together, so one does not send what the other refuses. A generator that refuses because it is busy answers `429` with its own `Retry-After`, so a client can come back instead of treating it as a missing preview. The same cap bounds an image webdav extracts itself, the cover of an audio file or the thumbnail inside a geogebra container, because a compressed entry says nothing about its size until it is read. A cropping resize asks the generator for a smart crop, so what survives is the region that carries the image; a generator without libvips answers the same request with a centre crop. +The thumbnails themselves are made by a generator the webdav service POSTs to, configured with `WEBDAV_THUMBNAILS_GENERATOR_URL` (and `WEBDAV_THUMBNAILS_GENERATOR_TIMEOUT`). The built-in thumbnails service speaks the imagor image endpoint, so a real [imagor](https://imagor.net) can be put in its place without changing anything else. A source the generator cannot read answers `404`, one that is too large `403`, and `WEBDAV_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE` caps what is sent at all; `OC_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE` sets this and the generator's own cap together, so one does not send what the other refuses. A generator that refuses because it is busy answers `429` with its own `Retry-After`, so a client can come back instead of treating it as a missing preview. The same cap bounds an image webdav extracts itself, the cover of an audio file or the thumbnail inside a geogebra container, because a compressed entry says nothing about its size until it is read. A cropping resize asks the generator for a smart crop, so what survives is the region that carries the image; the built-in thumbnails service answers the same request with a centre crop. Three settings say what is made of what. Each one is merged onto the built-in defaults, which is what their `ADDITIONAL` says: naming one type does not take the answer away from the others, and an entry for a type the defaults already answer for replaces that one entry. The first takes bare mime types, the other two take `key:value` entries: diff --git a/services/webdav/pkg/generator/url.go b/services/webdav/pkg/generator/url.go index 6b80745148..f215cad7d0 100644 --- a/services/webdav/pkg/generator/url.go +++ b/services/webdav/pkg/generator/url.go @@ -42,8 +42,8 @@ func operationSegment(op string) string { // // A cropping resize also asks for the smart crop, so the generator keeps the // region that carries the image instead of whatever sits in the middle. What a -// generator makes of it is its own: real imagor and the libvips build crop on -// attention, the pure Go build has no such thing and crops the centre. +// generator makes of it is its own: real imagor crops on attention, the +// built-in thumbnails service has no such thing and crops the centre. func BuildURL(baseURL string, width, height int32, operation, format string, noUpscale bool) string { base := strings.TrimRight(baseURL, "/") diff --git a/tests/acceptance/features/coreApiWebdavPreviews/previews.feature b/tests/acceptance/features/coreApiWebdavPreviews/previews.feature index 277e657600..d545bd020d 100644 --- a/tests/acceptance/features/coreApiWebdavPreviews/previews.feature +++ b/tests/acceptance/features/coreApiWebdavPreviews/previews.feature @@ -236,7 +236,7 @@ Feature: previews of files downloaded through the webdav API | new | | spaces | - @need-build-with-VIPS @issue-1451 + @issue-1451 Scenario Outline: it should update the preview content if the file content is updated (content with UTF chars) Given using DAV path And user "Alice" has uploaded file "filesForUpload/lorem.txt" to "/lorem.txt" @@ -250,7 +250,7 @@ Feature: previews of files downloaded through the webdav API | new | | spaces | - @need-build-with-VIPS @issue-1452 + @issue-1452 Scenario Outline: download preview of the text file Given using DAV path And user "Alice" has uploaded file "filesForUpload/lorem.txt" to "/lorem.txt" @@ -359,7 +359,7 @@ Feature: previews of files downloaded through the webdav API | new | | spaces | - @need-build-with-VIPS + Scenario Outline: download previews of an image with different processors Given using DAV path And user "Alice" has uploaded file "filesForUpload/testavatar.jpg" to "/testimage.jpg" diff --git a/tests/acceptance/fixtures/fill.jpg b/tests/acceptance/fixtures/fill.jpg index b240453454..a2eccea067 100644 Binary files a/tests/acceptance/fixtures/fill.jpg and b/tests/acceptance/fixtures/fill.jpg differ diff --git a/tests/acceptance/fixtures/fit.jpg b/tests/acceptance/fixtures/fit.jpg index 8b6dc4181a..87442265b4 100644 Binary files a/tests/acceptance/fixtures/fit.jpg and b/tests/acceptance/fixtures/fit.jpg differ diff --git a/tests/acceptance/fixtures/resize.jpg b/tests/acceptance/fixtures/resize.jpg index 4723c2b8ec..83db2049fa 100644 Binary files a/tests/acceptance/fixtures/resize.jpg and b/tests/acceptance/fixtures/resize.jpg differ diff --git a/tests/acceptance/fixtures/text-file-fixture.jpg b/tests/acceptance/fixtures/text-file-fixture.jpg index 59b64a93d6..0d632986e7 100644 Binary files a/tests/acceptance/fixtures/text-file-fixture.jpg and b/tests/acceptance/fixtures/text-file-fixture.jpg differ diff --git a/tests/acceptance/fixtures/thumbnail.jpg b/tests/acceptance/fixtures/thumbnail.jpg index b240453454..a2eccea067 100644 Binary files a/tests/acceptance/fixtures/thumbnail.jpg and b/tests/acceptance/fixtures/thumbnail.jpg differ diff --git a/tests/acceptance/fixtures/unicode-fixture.jpg b/tests/acceptance/fixtures/unicode-fixture.jpg index edbc6770c7..d7d6870464 100644 Binary files a/tests/acceptance/fixtures/unicode-fixture.jpg and b/tests/acceptance/fixtures/unicode-fixture.jpg differ diff --git a/vendor/github.com/davidbyttow/govips/v2/LICENSE b/vendor/github.com/davidbyttow/govips/v2/LICENSE deleted file mode 100644 index 8d0891d788..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -The MIT License - -Copyright (c) Simple Things LLC and contributors - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/error.go b/vendor/github.com/davidbyttow/govips/v2/vips/error.go deleted file mode 100644 index 08eb41e78f..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/error.go +++ /dev/null @@ -1,39 +0,0 @@ -package vips - -// #include -import "C" - -import ( - "errors" - "fmt" - dbg "runtime/debug" - "unsafe" -) - -var ( - // ErrUnsupportedImageFormat when image type is unsupported - ErrUnsupportedImageFormat = errors.New("unsupported image format") -) - -func handleImageError(out *C.VipsImage) error { - if out != nil { - clearImage(out) - } - - return handleVipsError() -} - -func handleSaveBufferError(out unsafe.Pointer) error { - if out != nil { - gFreePointer(out) - } - - return handleVipsError() -} - -func handleVipsError() error { - s := C.GoString(C.vips_error_buffer()) - C.vips_error_clear() - - return fmt.Errorf("%v\nStack:\n%s", s, dbg.Stack()) -} diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/foreign.c b/vendor/github.com/davidbyttow/govips/v2/vips/foreign.c deleted file mode 100644 index 34cbf78a42..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/foreign.c +++ /dev/null @@ -1,628 +0,0 @@ -#include "foreign.h" - -#include "lang.h" - -void set_bool_param(Param *p, gboolean b) { - p->type = PARAM_TYPE_BOOL; - p->value.b = b; - p->is_set = TRUE; -} - -void set_int_param(Param *p, gint i) { - p->type = PARAM_TYPE_INT; - p->value.i = i; - p->is_set = TRUE; -} - -void set_double_param(Param *p, gdouble d) { - p->type = PARAM_TYPE_DOUBLE; - p->value.d = d; - p->is_set = TRUE; -} - -int load_image_buffer(LoadParams *params, void *buf, size_t len, - VipsImage **out) { - int code = 1; - ImageType imageType = params->inputFormat; - - if (imageType == JPEG) { - // shrink: int, fail: bool, autorotate: bool - code = vips_jpegload_buffer(buf, len, out, "fail", params->fail, - "autorotate", params->autorotate, "shrink", - params->jpegShrink, "access", params->access, NULL); - } else if (imageType == PNG) { - code = vips_pngload_buffer(buf, len, out, "access", params->access, NULL); - } else if (imageType == WEBP) { - // page: int, n: int, scale: double - code = vips_webpload_buffer(buf, len, out, "page", params->page, "n", - params->n, "access", params->access, NULL); - } else if (imageType == TIFF) { - // page: int, n: int, autorotate: bool, subifd: int - code = - vips_tiffload_buffer(buf, len, out, "page", params->page, "n", - params->n, "autorotate", params->autorotate, "access", params->access, NULL); - } else if (imageType == GIF) { - // page: int, n: int, scale: double - code = vips_gifload_buffer(buf, len, out, "page", params->page, "n", - params->n, "access", params->access, NULL); - } else if (imageType == PDF) { - // page: int, n: int, dpi: double, scale: double, background: color - code = vips_pdfload_buffer(buf, len, out, "page", params->page, "n", - params->n, "dpi", params->dpi, "access", params->access, NULL); - } else if (imageType == SVG) { - // dpi: double, scale: double, unlimited: bool - code = vips_svgload_buffer(buf, len, out, "dpi", params->dpi, "unlimited", - params->svgUnlimited, "access", params->access, NULL); - } else if (imageType == HEIF) { - // added autorotate on load as currently it addresses orientation issues - // https://github.com/libvips/libvips/pull/1680 - // page: int, n: int, thumbnail: bool - code = vips_heifload_buffer(buf, len, out, "page", params->page, "n", - params->n, "thumbnail", params->heifThumbnail, - "autorotate", TRUE, "access", params->access, NULL); - } else if (imageType == MAGICK) { - // page: int, n: int, density: string - code = vips_magickload_buffer(buf, len, out, "page", params->page, "n", - params->n, "access", params->access, NULL); - } else if (imageType == AVIF) { - code = vips_heifload_buffer(buf, len, out, "page", params->page, "n", - params->n, "thumbnail", params->heifThumbnail, - "autorotate", params->autorotate, "access", params->access, NULL); - - } - #if (VIPS_MAJOR_VERSION >= 8) && (VIPS_MINOR_VERSION >= 11) - else if (imageType == JP2K) { - code = vips_jp2kload_buffer(buf, len, out, "page", params->page, "access", params->access, NULL); - } - #endif - - return code; -} - -#define MAYBE_SET_BOOL(OP, PARAM, NAME) \ - if (PARAM.is_set) { \ - vips_object_set(VIPS_OBJECT(OP), NAME, PARAM.value.b, NULL); \ - } - -#define MAYBE_SET_INT(OP, PARAM, NAME) \ - if (PARAM.is_set) { \ - vips_object_set(VIPS_OBJECT(OP), NAME, PARAM.value.i, NULL); \ - } - -#define MAYBE_SET_DOUBLE(OP, PARAM, NAME) \ - if (PARAM.is_set) { \ - vips_object_set(VIPS_OBJECT(OP), NAME, PARAM.value.d, NULL); \ - } - -typedef int (*SetLoadOptionsFn)(VipsOperation *operation, LoadParams *params); - -int set_jpegload_options(VipsOperation *operation, LoadParams *params) { - MAYBE_SET_BOOL(operation, params->autorotate, "autorotate"); - MAYBE_SET_BOOL(operation, params->fail, "fail"); - MAYBE_SET_INT(operation, params->jpegShrink, "shrink"); - MAYBE_SET_INT(operation, params->access, "access"); - return 0; -} - -int set_pngload_options(VipsOperation *operation, LoadParams *params) { - MAYBE_SET_BOOL(operation, params->fail, "fail"); - MAYBE_SET_INT(operation, params->access, "access"); - return 0; -} - -int set_webpload_options(VipsOperation *operation, LoadParams *params) { - MAYBE_SET_INT(operation, params->page, "page"); - MAYBE_SET_INT(operation, params->n, "n"); - MAYBE_SET_INT(operation, params->access, "access"); - MAYBE_SET_DOUBLE(operation, params->webpScale, "scale"); - return 0; -} - -int set_tiffload_options(VipsOperation *operation, LoadParams *params) { - MAYBE_SET_BOOL(operation, params->autorotate, "autorotate"); - MAYBE_SET_INT(operation, params->page, "page"); - MAYBE_SET_INT(operation, params->n, "n"); - MAYBE_SET_INT(operation, params->access, "access"); - return 0; -} - -int set_gifload_options(VipsOperation *operation, LoadParams *params) { - MAYBE_SET_INT(operation, params->page, "page"); - MAYBE_SET_INT(operation, params->n, "n"); - MAYBE_SET_INT(operation, params->access, "access"); - return 0; -} - -int set_pdfload_options(VipsOperation *operation, LoadParams *params) { - MAYBE_SET_INT(operation, params->page, "page"); - MAYBE_SET_INT(operation, params->n, "n"); - MAYBE_SET_DOUBLE(operation, params->dpi, "dpi"); - MAYBE_SET_INT(operation, params->access, "access"); - return 0; -} - -int set_svgload_options(VipsOperation *operation, LoadParams *params) { - MAYBE_SET_BOOL(operation, params->svgUnlimited, "unlimited"); - MAYBE_SET_DOUBLE(operation, params->dpi, "dpi"); - MAYBE_SET_INT(operation, params->access, "access"); - return 0; -} - -int set_heifload_options(VipsOperation *operation, LoadParams *params) { - MAYBE_SET_BOOL(operation, params->autorotate, "autorotate"); - MAYBE_SET_BOOL(operation, params->heifThumbnail, "thumbnail"); - MAYBE_SET_INT(operation, params->page, "page"); - MAYBE_SET_INT(operation, params->n, "n"); - MAYBE_SET_INT(operation, params->access, "access"); - return 0; -} - -int set_jp2kload_options(VipsOperation *operation, LoadParams *params) { - MAYBE_SET_INT(operation, params->page, "page"); - MAYBE_SET_INT(operation, params->access, "access"); - return 0; -} - -int set_jxlload_options(VipsOperation *operation, LoadParams *params) { - // nothing need to do - return 0; -} - -int set_magickload_options(VipsOperation *operation, LoadParams *params) { - MAYBE_SET_INT(operation, params->page, "page"); - MAYBE_SET_INT(operation, params->n, "n"); - MAYBE_SET_INT(operation, params->access, "access"); - return 0; -} - -int load_buffer(const char *operationName, void *buf, size_t len, - LoadParams *params, SetLoadOptionsFn setLoadOptions) { - VipsBlob *blob = vips_blob_new(NULL, buf, len); - - VipsOperation *operation = vips_operation_new(operationName); - if (!operation) { - return 1; - } - - if (vips_object_set(VIPS_OBJECT(operation), "buffer", blob, NULL)) { - vips_area_unref(VIPS_AREA(blob)); - return 1; - } - - vips_area_unref(VIPS_AREA(blob)); - - if (setLoadOptions(operation, params)) { - vips_object_unref_outputs(VIPS_OBJECT(operation)); - g_object_unref(operation); - return 1; - } - - if (vips_cache_operation_buildp(&operation)) { - vips_object_unref_outputs(VIPS_OBJECT(operation)); - g_object_unref(operation); - return 1; - } - - g_object_get(VIPS_OBJECT(operation), "out", ¶ms->outputImage, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(operation)); - g_object_unref(operation); - - return 0; -} - -typedef int (*SetSaveOptionsFn)(VipsOperation *operation, SaveParams *params); - -int save_buffer(const char *operationName, SaveParams *params, - SetSaveOptionsFn setSaveOptions) { - VipsBlob *blob; - VipsOperation *operation = vips_operation_new(operationName); - if (!operation) { - return 1; - } - - if (vips_object_set(VIPS_OBJECT(operation), "in", params->inputImage, NULL)) { - return 1; - } - - if (setSaveOptions(operation, params)) { - g_object_unref(operation); - return 1; - } - - // "keep" is set here rather than in each per-format setter so every - // saver gets it the same way. It overrides the deprecated "strip". - if (params->keepSet && - vips_object_set(VIPS_OBJECT(operation), "keep", params->keep, NULL)) { - g_object_unref(operation); - return 1; - } - - if (vips_cache_operation_buildp(&operation)) { - vips_object_unref_outputs(VIPS_OBJECT(operation)); - g_object_unref(operation); - return 1; - } - - g_object_get(VIPS_OBJECT(operation), "buffer", &blob, NULL); - g_object_unref(operation); - - VipsArea *area = VIPS_AREA(blob); - - params->outputBuffer = (char *)(area->data); - params->outputLen = area->length; - area->free_fn = NULL; - vips_area_unref(area); - - return 0; -} - -// https://libvips.github.io/libvips/API/current/VipsForeignSave.html#vips-jpegsave-buffer -int set_jpegsave_options(VipsOperation *operation, SaveParams *params) { - int ret = vips_object_set( - VIPS_OBJECT(operation), "strip", params->stripMetadata, "optimize_coding", - params->jpegOptimizeCoding, "interlace", params->interlace, - "subsample_mode", params->jpegSubsample, "trellis_quant", - params->jpegTrellisQuant, "overshoot_deringing", - params->jpegOvershootDeringing, "optimize_scans", - params->jpegOptimizeScans, "quant_table", params->jpegQuantTable, NULL); - - if (!ret && params->quality) { - ret = vips_object_set(VIPS_OBJECT(operation), "Q", params->quality, NULL); - } - - return ret; -} - -// https://libvips.github.io/libvips/API/current/VipsForeignSave.html#vips-pngsave-buffer -int set_pngsave_options(VipsOperation *operation, SaveParams *params) { - int ret = - vips_object_set(VIPS_OBJECT(operation), "strip", params->stripMetadata, - "compression", params->pngCompression, "interlace", - params->interlace, "filter", params->pngFilter, "palette", - params->pngPalette, NULL); - - if (!ret && params->quality) { - ret = vips_object_set(VIPS_OBJECT(operation), "Q", params->quality, NULL); - } - - if (!ret && params->pngDither) { - ret = vips_object_set(VIPS_OBJECT(operation), "dither", params->pngDither, NULL); - } - - if (!ret && params->pngBitdepth) { - ret = vips_object_set(VIPS_OBJECT(operation), "bitdepth", params->pngBitdepth, NULL); - } - - // TODO: Handle `profile` param. - - return ret; -} - -// https://github.com/libvips/libvips/blob/master/libvips/foreign/webpsave.c#L524 -// https://libvips.github.io/libvips/API/current/VipsForeignSave.html#vips-webpsave-buffer -int set_webpsave_options(VipsOperation *operation, SaveParams *params) { - int ret = - vips_object_set(VIPS_OBJECT(operation), - "strip", params->stripMetadata, - "lossless", params->webpLossless, - "near_lossless", params->webpNearLossless, - "reduction_effort", params->webpReductionEffort, - "min_size", params->webpMinSize, - "kmin", params->webpKMin, - "kmax", params->webpKMax, - NULL); - - // Only pass a profile the caller chose; leaving "profile" unset lets - // strip/keep decide about the source image's own ICC, as for the other - // savers. With StripMetadata and no Keep, still pass "none": webpsave in - // libvips 8.14.0-8.14.1 ignores "strip" (a shadowed field, fixed in - // 8.14.2), and "none" is what keeps the ICC out there. Elsewhere strip - // already drops it. - if (!ret && params->webpIccProfile) { - ret = vips_object_set(VIPS_OBJECT(operation), "profile", - params->webpIccProfile, NULL); - } else if (!ret && params->stripMetadata && !params->keepSet) { - ret = vips_object_set(VIPS_OBJECT(operation), "profile", "none", NULL); - } - - if (!ret && params->quality) { - ret = vips_object_set(VIPS_OBJECT(operation), "Q", params->quality, NULL); - } - - if (!ret && params->webpTargetSize) { - ret = vips_object_set(VIPS_OBJECT(operation), "target_size", params->webpTargetSize, NULL); - } - - return ret; -} - -// https://libvips.github.io/libvips/API/current/VipsForeignSave.html#vips-tiffsave-buffer -int set_tiffsave_options(VipsOperation *operation, SaveParams *params) { - int ret = vips_object_set( - VIPS_OBJECT(operation), "strip", params->stripMetadata, "compression", - params->tiffCompression, "predictor", params->tiffPredictor, "pyramid", - params->tiffPyramid, "tile_height", params->tiffTileHeight, "tile_width", - params->tiffTileWidth, "tile", params->tiffTile, NULL); - - if (!ret && params->quality) { - ret = vips_object_set(VIPS_OBJECT(operation), "Q", params->quality, NULL); - } - - return ret; -} - -// https://libvips.github.io/libvips/API/current/VipsForeignSave.html#vips-magicksave-buffer -int set_magicksave_options(VipsOperation *operation, SaveParams *params) { - int ret = vips_object_set(VIPS_OBJECT(operation), "format", params->magickFormat, - "optimize_gif_frames", params->magickOptimizeGifFrames, - "optimize_gif_transparency", params->magickOptimizeGifTransparency, - "bitdepth", params->magickBitDepth, NULL); - - if (!ret && params->quality) { - ret = vips_object_set(VIPS_OBJECT(operation), "quality", params->quality, - NULL); - } - return ret; -} - -// https://libvips.github.io/libvips/API/current/VipsForeignSave.html#vips-gifsave-buffer -int set_gifsave_options(VipsOperation *operation, SaveParams *params) { - int ret = 0; - // See for argument values: https://www.libvips.org/API/current/VipsForeignSave.html#vips-gifsave - if (params->gifDither > 0.0 && params->gifDither <= 10) { - ret = vips_object_set(VIPS_OBJECT(operation), "dither", params->gifDither, NULL); - } - if (params->gifEffort >= 1 && params->gifEffort <= 10) { - ret = vips_object_set(VIPS_OBJECT(operation), "effort", params->gifEffort, NULL); - } - if (params->gifBitdepth >= 1 && params->gifBitdepth <= 8) { - ret = vips_object_set(VIPS_OBJECT(operation), "bitdepth", params->gifBitdepth, NULL); - } - return ret; -} - -// https://github.com/libvips/libvips/blob/master/libvips/foreign/heifsave.c#L653 -int set_heifsave_options(VipsOperation *operation, SaveParams *params) { - int ret = vips_object_set(VIPS_OBJECT(operation), "lossless", - params->heifLossless, NULL); - -#if (VIPS_MAJOR_VERSION >= 8) && (VIPS_MINOR_VERSION >= 13) - if (!ret && params->heifBitdepth && params->heifEffort) { - ret = vips_object_set(VIPS_OBJECT(operation), "bitdepth", - params->heifBitdepth, "effort", params->heifEffort, - NULL); - } -#else - if (!ret && params->heifEffort) { - ret = vips_object_set(VIPS_OBJECT(operation), "speed", params->heifEffort, - NULL); - } -#endif - - if (!ret && params->quality) { - ret = vips_object_set(VIPS_OBJECT(operation), "Q", params->quality, NULL); - } - - return ret; -} - -// https://github.com/libvips/libvips/blob/master/libvips/foreign/heifsave.c#L653 -int set_avifsave_options(VipsOperation *operation, SaveParams *params) { - int ret = vips_object_set(VIPS_OBJECT(operation), "strip", params->stripMetadata, "compression", - VIPS_FOREIGN_HEIF_COMPRESSION_AV1, "lossless", - params->heifLossless, NULL); - -#if (VIPS_MAJOR_VERSION >= 8) && (VIPS_MINOR_VERSION >= 13) - if (!ret && params->heifBitdepth && params->heifEffort) { - ret = vips_object_set(VIPS_OBJECT(operation), "bitdepth", - params->heifBitdepth, "effort", params->heifEffort, - NULL); - } -#else - if (!ret && params->heifEffort) { - ret = vips_object_set(VIPS_OBJECT(operation), "speed", params->heifEffort, - NULL); - } -#endif - - if (!ret && params->quality) { - ret = vips_object_set(VIPS_OBJECT(operation), "Q", params->quality, NULL); - } - - return ret; -} - -int set_jp2ksave_options(VipsOperation *operation, SaveParams *params) { - int ret = vips_object_set( - VIPS_OBJECT(operation), "subsample_mode", params->jpegSubsample, - "tile_height", params->jp2kTileHeight, "tile_width", params->jp2kTileWidth, - "lossless", params->jp2kLossless, NULL); - - if (!ret && params->quality) { - ret = vips_object_set(VIPS_OBJECT(operation), "Q", params->quality, NULL); - } - - return ret; -} - -int set_jxlsave_options(VipsOperation *operation, SaveParams *params) { - int ret = vips_object_set( - VIPS_OBJECT(operation), "tier", params->jxlTier, - "distance", params->jxlDistance, "effort", params->jxlEffort, - "lossless", params->jxlLossless, NULL); - - if (!ret && params->quality) { - ret = vips_object_set(VIPS_OBJECT(operation), "Q", params->quality, NULL); - } - - return ret; -} - -int load_from_buffer(LoadParams *params, void *buf, size_t len) { - switch (params->inputFormat) { - case JPEG: - return load_buffer("jpegload_buffer", buf, len, params, - set_jpegload_options); - case PNG: - return load_buffer("pngload_buffer", buf, len, params, - set_pngload_options); - case WEBP: - return load_buffer("webpload_buffer", buf, len, params, - set_webpload_options); - case HEIF: - return load_buffer("heifload_buffer", buf, len, params, - set_heifload_options); - case TIFF: - return load_buffer("tiffload_buffer", buf, len, params, - set_tiffload_options); - case SVG: - return load_buffer("svgload_buffer", buf, len, params, - set_svgload_options); - case GIF: - return load_buffer("gifload_buffer", buf, len, params, - set_gifload_options); - case PDF: - return load_buffer("pdfload_buffer", buf, len, params, - set_pdfload_options); - case MAGICK: - return load_buffer("magickload_buffer", buf, len, params, - set_magickload_options); - case AVIF: - return load_buffer("heifload_buffer", buf, len, params, - set_heifload_options); - case JP2K: - return load_buffer("jp2kload_buffer", buf, len, params, - set_jp2kload_options); - case JXL: - return load_buffer("jxlload_buffer", buf, len, params, - set_jxlload_options); - default: - g_warning("Unsupported input type given: %d", params->inputFormat); - } - return 1; -} - -int save_to_buffer(SaveParams *params) { - switch (params->outputFormat) { - case JPEG: - return save_buffer("jpegsave_buffer", params, set_jpegsave_options); - case PNG: - return save_buffer("pngsave_buffer", params, set_pngsave_options); - case WEBP: - return save_buffer("webpsave_buffer", params, set_webpsave_options); - case HEIF: - return save_buffer("heifsave_buffer", params, set_heifsave_options); - case TIFF: - return save_buffer("tiffsave_buffer", params, set_tiffsave_options); - case GIF: -#if (VIPS_MAJOR_VERSION >= 8) && (VIPS_MINOR_VERSION >= 12) - return save_buffer("gifsave_buffer", params, set_gifsave_options); -#else - // Gif save through ImageMagick below Vips Version 8.12 - params->magickFormat="GIF"; - params->magickOptimizeGifFrames=FALSE; - params->magickOptimizeGifTransparency=FALSE; - params->magickBitDepth=params->gifBitdepth; - return save_buffer("magicksave_buffer", params, set_magicksave_options); -#endif - case AVIF: - return save_buffer("heifsave_buffer", params, set_avifsave_options); - case JP2K: - return save_buffer("jp2ksave_buffer", params, set_jp2ksave_options); - case JXL: - return save_buffer("jxlsave_buffer", params, set_jxlsave_options); - case MAGICK: - return save_buffer("magicksave_buffer", params, set_magicksave_options); - default: - g_warning("Unsupported output type given: %d", params->outputFormat); - } - return 1; -} - -LoadParams create_load_params(ImageType inputFormat) { - Param defaultParam = {}; - LoadParams p = { - .inputFormat = inputFormat, - .inputBlob = NULL, - .outputImage = NULL, - .autorotate = defaultParam, - .fail = defaultParam, - .page = defaultParam, - .n = defaultParam, - .dpi = defaultParam, - .jpegShrink = defaultParam, - .webpScale = defaultParam, - .heifThumbnail = defaultParam, - .svgUnlimited = defaultParam, - .access = defaultParam, - }; - return p; -} - -// TODO: Change to same pattern as ImportParams - -static SaveParams defaultSaveParams = { - .inputImage = NULL, - .outputBuffer = NULL, - .outputFormat = JPEG, - .outputLen = 0, - - .interlace = FALSE, - .quality = 0, - .stripMetadata = FALSE, - .keep = 0, - .keepSet = FALSE, - - .jpegOptimizeCoding = FALSE, - .jpegSubsample = VIPS_FOREIGN_SUBSAMPLE_ON, - .jpegTrellisQuant = FALSE, - .jpegOvershootDeringing = FALSE, - .jpegOptimizeScans = FALSE, - .jpegQuantTable = 0, - - .pngCompression = 6, - .pngPalette = FALSE, - .pngBitdepth = 0, - .pngDither = 0, - .pngFilter = VIPS_FOREIGN_PNG_FILTER_NONE, - - .gifDither = 0.0, - .gifEffort = 0, - .gifBitdepth = 0, - - .webpLossless = FALSE, - .webpNearLossless = FALSE, - .webpReductionEffort = 4, - .webpIccProfile = NULL, - .webpKMax = 0, - .webpKMin = 0, - .webpMinSize = FALSE, - .webpTargetSize = 0, - - .heifBitdepth = 8, - .heifLossless = FALSE, - .heifEffort = 5, - - .tiffCompression = VIPS_FOREIGN_TIFF_COMPRESSION_LZW, - .tiffPredictor = VIPS_FOREIGN_TIFF_PREDICTOR_HORIZONTAL, - .tiffPyramid = FALSE, - .tiffTile = FALSE, - .tiffTileHeight = 256, - .tiffTileWidth = 256, - - .jp2kLossless = FALSE, - .jp2kTileHeight = 512, - .jp2kTileWidth = 512, - - .jxlTier = 0, - .jxlDistance = 1.0, - .jxlEffort = 7, - .jxlLossless = FALSE, - }; - -SaveParams create_save_params(ImageType outputFormat) { - SaveParams params = defaultSaveParams; - params.outputFormat = outputFormat; - return params; -} diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/foreign.go b/vendor/github.com/davidbyttow/govips/v2/vips/foreign.go deleted file mode 100644 index 3d40df2c19..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/foreign.go +++ /dev/null @@ -1,759 +0,0 @@ -package vips - -// #include "foreign.h" -import "C" -import ( - "bytes" - "encoding/xml" - "errors" - "fmt" - "math" - "runtime" - "unsafe" - - "golang.org/x/net/html/charset" -) - -// SubsampleMode correlates to a libvips subsample mode -type SubsampleMode int - -// SubsampleMode enum correlating to libvips subsample modes -const ( - VipsForeignSubsampleAuto SubsampleMode = C.VIPS_FOREIGN_SUBSAMPLE_AUTO - VipsForeignSubsampleOn SubsampleMode = C.VIPS_FOREIGN_SUBSAMPLE_ON - VipsForeignSubsampleOff SubsampleMode = C.VIPS_FOREIGN_SUBSAMPLE_OFF - VipsForeignSubsampleLast SubsampleMode = C.VIPS_FOREIGN_SUBSAMPLE_LAST -) - -// ForeignKeep flags select which metadata a saver retains (libvips's "keep" -// save option, libvips 8.15+). Values may be combined with |. -// -// The values are libvips's VipsForeignKeep bits written as literals rather -// than C.VIPS_FOREIGN_KEEP_* because those macros don't exist in the -// libvips 8.14 headers govips still builds against. -const ( - // ForeignKeepNone keeps no metadata. It is a Go-only sentinel (like - // KernelAuto) translated to VIPS_FOREIGN_KEEP_NONE (0) before reaching - // libvips, because the zero value of the Keep fields means "unset". - // It is a high bit rather than -1 so that it still composes with |. - ForeignKeepNone ForeignKeep = 1 << 30 - ForeignKeepExif ForeignKeep = 1 << 0 - ForeignKeepXmp ForeignKeep = 1 << 1 - ForeignKeepIptc ForeignKeep = 1 << 2 - ForeignKeepIcc ForeignKeep = 1 << 3 - ForeignKeepOther ForeignKeep = 1 << 4 - // ForeignKeepGainmap keeps the UltraHDR gain map (libvips 8.18+). Older - // libvips cannot load gain maps, so the bit is dropped there: combined - // with other flags it changes nothing, but on its own it keeps no - // metadata at all, exactly like ForeignKeepNone. - ForeignKeepGainmap ForeignKeep = 1 << 5 - // ForeignKeepAll keeps all metadata the running libvips supports. - ForeignKeepAll = ForeignKeepExif | ForeignKeepXmp | ForeignKeepIptc | - ForeignKeepIcc | ForeignKeepOther | ForeignKeepGainmap -) - -// errKeepUnsupported is returned by resolveKeep when the libvips version -// predates the "keep" save option. -var errKeepUnsupported = errors.New("keep requires libvips 8.15+") - -// resolveKeep maps a ForeignKeep value to the libvips "keep" flags for the -// given libvips version. set is false when k is unset (zero), in which case -// the caller must not pass "keep" at all and StripMetadata decides. -func resolveKeep(k ForeignKeep, major, minor int) (flags int, set bool, err error) { - if k == 0 { - return 0, false, nil - } - if major < 8 || (major == 8 && minor < 15) { - return 0, false, errKeepUnsupported - } - if unknown := k &^ (ForeignKeepAll | ForeignKeepNone); unknown != 0 { - return 0, false, fmt.Errorf("unknown ForeignKeep bits: %#x", int(unknown)) - } - k &^= ForeignKeepNone - if major == 8 && minor < 18 { - // libvips before 8.18 doesn't know VIPS_FOREIGN_KEEP_GAINMAP. - k &^= ForeignKeepGainmap - } - return int(k), true, nil -} - -// applyKeep validates k against the running libvips and stores it in p. -// Every save-param builder calls it, so the buffer and streaming paths -// share one version guard. -func applyKeep(p *C.struct_SaveParams, k ForeignKeep) error { - flags, set, err := resolveKeep(k, MajorVersion, MinorVersion) - if errors.Is(err, errKeepUnsupported) { - return fmt.Errorf("Keep requires libvips 8.15+, found %s", Version) - } - if err != nil { - return err - } - p.keep = C.int(flags) - p.keepSet = C.int(boolToInt(set)) - return nil -} - -// ImageType represents an image type -type ImageType int - -// ImageType enum -const ( - ImageTypeUnknown ImageType = C.UNKNOWN - ImageTypeGIF ImageType = C.GIF - ImageTypeJPEG ImageType = C.JPEG - ImageTypeMagick ImageType = C.MAGICK - ImageTypePDF ImageType = C.PDF - ImageTypePNG ImageType = C.PNG - ImageTypeSVG ImageType = C.SVG - ImageTypeTIFF ImageType = C.TIFF - ImageTypeWEBP ImageType = C.WEBP - ImageTypeHEIF ImageType = C.HEIF - ImageTypeBMP ImageType = C.BMP - ImageTypeAVIF ImageType = C.AVIF - ImageTypeJP2K ImageType = C.JP2K - ImageTypeJXL ImageType = C.JXL - ImageTypePSD ImageType = C.PSD -) - -// Types which should be deligated to ImageMagick loader -var imageMagickTypes = map[ImageType]bool{ - ImageTypeBMP: true, - ImageTypePSD: true, -} - -var imageTypeExtensionMap = map[ImageType]string{ - ImageTypeGIF: ".gif", - ImageTypeJPEG: ".jpeg", - ImageTypeMagick: ".magick", - ImageTypePDF: ".pdf", - ImageTypePNG: ".png", - ImageTypeSVG: ".svg", - ImageTypeTIFF: ".tiff", - ImageTypeWEBP: ".webp", - ImageTypeHEIF: ".heic", - ImageTypeBMP: ".bmp", - ImageTypeAVIF: ".avif", - ImageTypeJP2K: ".jp2", - ImageTypeJXL: ".jxl", - ImageTypePSD: ".psd", -} - -// ImageTypes defines the various image types supported by govips -var ImageTypes = map[ImageType]string{ - ImageTypeGIF: "gif", - ImageTypeJPEG: "jpeg", - ImageTypeMagick: "magick", - ImageTypePDF: "pdf", - ImageTypePNG: "png", - ImageTypeSVG: "svg", - ImageTypeTIFF: "tiff", - ImageTypeWEBP: "webp", - ImageTypeHEIF: "heif", - ImageTypeBMP: "bmp", - ImageTypeAVIF: "heif", - ImageTypeJP2K: "jp2k", - ImageTypeJXL: "jxl", - ImageTypePSD: "psd", -} - -// TiffCompression represents method for compressing a tiff at export -type TiffCompression int - -// TiffCompression enum -const ( - TiffCompressionNone TiffCompression = C.VIPS_FOREIGN_TIFF_COMPRESSION_NONE - TiffCompressionJpeg TiffCompression = C.VIPS_FOREIGN_TIFF_COMPRESSION_JPEG - TiffCompressionDeflate TiffCompression = C.VIPS_FOREIGN_TIFF_COMPRESSION_DEFLATE - TiffCompressionPackbits TiffCompression = C.VIPS_FOREIGN_TIFF_COMPRESSION_PACKBITS - TiffCompressionFax4 TiffCompression = C.VIPS_FOREIGN_TIFF_COMPRESSION_CCITTFAX4 - TiffCompressionLzw TiffCompression = C.VIPS_FOREIGN_TIFF_COMPRESSION_LZW - TiffCompressionWebp TiffCompression = C.VIPS_FOREIGN_TIFF_COMPRESSION_WEBP - TiffCompressionZstd TiffCompression = C.VIPS_FOREIGN_TIFF_COMPRESSION_ZSTD -) - -// TiffPredictor represents method for compressing a tiff at export -type TiffPredictor int - -// TiffPredictor enum -const ( - TiffPredictorNone TiffPredictor = C.VIPS_FOREIGN_TIFF_PREDICTOR_NONE - TiffPredictorHorizontal TiffPredictor = C.VIPS_FOREIGN_TIFF_PREDICTOR_HORIZONTAL - TiffPredictorFloat TiffPredictor = C.VIPS_FOREIGN_TIFF_PREDICTOR_FLOAT -) - -// PngFilter represents filter algorithms that can be applied before compression. -// See https://www.w3.org/TR/PNG-Filters.html -type PngFilter int - -// PngFilter enum -const ( - PngFilterNone PngFilter = C.VIPS_FOREIGN_PNG_FILTER_NONE - PngFilterSub PngFilter = C.VIPS_FOREIGN_PNG_FILTER_SUB - PngFilterUo PngFilter = C.VIPS_FOREIGN_PNG_FILTER_UP - PngFilterAvg PngFilter = C.VIPS_FOREIGN_PNG_FILTER_AVG - PngFilterPaeth PngFilter = C.VIPS_FOREIGN_PNG_FILTER_PAETH - PngFilterAll PngFilter = C.VIPS_FOREIGN_PNG_FILTER_ALL -) - -// Access represents how libvips opens files. -// See https://www.libvips.org/API/current/How-it-opens-files.html -const ( - AccessRandom int = C.VIPS_ACCESS_RANDOM - AccessSequential int = C.VIPS_ACCESS_SEQUENTIAL - AccessSequentialUnbuffered int = C.VIPS_ACCESS_SEQUENTIAL_UNBUFFERED - AccessLast int = C.VIPS_ACCESS_LAST -) - -// FileExt returns the canonical extension for the ImageType -func (i ImageType) FileExt() string { - if ext, ok := imageTypeExtensionMap[i]; ok { - return ext - } - return "" -} - -// IsTypeSupported checks whether given image type is supported by govips -func IsTypeSupported(imageType ImageType) bool { - if err := startupIfNeeded(); err != nil { - govipsLog("govips", LogLevelError, fmt.Sprintf("failed to start vips: %v", err)) - return false - } - - // BMP is supported via the magick loader - if imageType == ImageTypeBMP { - return supportedImageTypes[ImageTypeMagick] - } - - return supportedImageTypes[imageType] -} - -// DetermineImageType attempts to determine the image type of the given buffer -func DetermineImageType(buf []byte) ImageType { - if len(buf) < 12 { - return ImageTypeUnknown - } else if isJPEG(buf) { - return ImageTypeJPEG - } else if isPNG(buf) { - return ImageTypePNG - } else if isGIF(buf) { - return ImageTypeGIF - } else if isTIFF(buf) { - return ImageTypeTIFF - } else if isWEBP(buf) { - return ImageTypeWEBP - } else if isAVIF(buf) { - return ImageTypeAVIF - } else if isHEIF(buf) { - return ImageTypeHEIF - } else if isSVG(buf) { - return ImageTypeSVG - } else if isBMP(buf) { - return ImageTypeBMP - } else if isJP2K(buf) { - return ImageTypeJP2K - } else if isJXL(buf) { - return ImageTypeJXL - } else if isPDF(buf) { - return ImageTypePDF - } else if isICO(buf) { - return ImageTypeMagick - } else if isPSD(buf) { - return ImageTypePSD - } else { - return ImageTypeUnknown - } -} - -var jpeg = []byte("\xFF\xD8\xFF") - -func isJPEG(buf []byte) bool { - return bytes.HasPrefix(buf, jpeg) -} - -var gifHeader = []byte("\x47\x49\x46") - -func isGIF(buf []byte) bool { - return bytes.HasPrefix(buf, gifHeader) -} - -var pngHeader = []byte("\x89\x50\x4E\x47") - -func isPNG(buf []byte) bool { - return bytes.HasPrefix(buf, pngHeader) -} - -var tifII = []byte("\x49\x49\x2A\x00") -var tifMM = []byte("\x4D\x4D\x00\x2A") -var bigTifII = []byte("\x49\x49\x2B\x00") -var bigTifMM = []byte("\x4D\x4D\x00\x2B") - -func isTIFF(buf []byte) bool { - return bytes.HasPrefix(buf, tifII) || - bytes.HasPrefix(buf, tifMM) || - bytes.HasPrefix(buf, bigTifII) || - bytes.HasPrefix(buf, bigTifMM) -} - -var webpHeader = []byte("\x57\x45\x42\x50") - -func isWEBP(buf []byte) bool { - return bytes.Equal(buf[8:12], webpHeader) -} - -// https://github.com/strukturag/libheif/blob/master/libheif/heif.cc -var ftyp = []byte("ftyp") -var heic = []byte("heic") -var heix = []byte("heix") -var heim = []byte("heim") -var heis = []byte("heis") -var mif1 = []byte("mif1") -var msf1 = []byte("msf1") -var avif = []byte("avif") -var avis = []byte("avis") - -func isHEIF(buf []byte) bool { - return bytes.Equal(buf[4:8], ftyp) && (bytes.Equal(buf[8:12], heic) || - bytes.Equal(buf[8:12], heix) || - bytes.Equal(buf[8:12], heim) || - bytes.Equal(buf[8:12], heis) || - bytes.Equal(buf[8:12], mif1) || - bytes.Equal(buf[8:12], msf1)) || - isAVIF(buf) -} - -func isAVIF(buf []byte) bool { - return bytes.Equal(buf[4:8], ftyp) && - (bytes.Equal(buf[8:12], avif) || bytes.Equal(buf[8:12], avis)) -} - -var svg = []byte("= 2 && buf[0] == 0xFF && buf[1] == 0x0A { - return true - } - if len(buf) >= 8 && bytes.Equal(buf[4:8], []byte("JXL ")) { - return true - } - return false -} - -var icoHeader = []byte("\x00\x00\x01\x00") - -func isICO(buf []byte) bool { - return bytes.HasPrefix(buf, icoHeader) -} - -var psdHeader = []byte("\x38\x42\x50\x53") - -func isPSD(buf []byte) bool { - return bytes.HasPrefix(buf, psdHeader) -} - -func isNeedToChangeLoaderToMagick(t ImageType) bool { - return imageMagickTypes[t] -} - -func vipsLoadFromBuffer(buf []byte, params *ImportParams) (*C.VipsImage, ImageType, ImageType, error) { - src := buf - // Reference src here so it's not garbage collected during image initialization. - defer runtime.KeepAlive(src) - - originalType := DetermineImageType(src) - currentType := originalType - - // Map image types which are not supported by libvips itself to ImageMagick - if isNeedToChangeLoaderToMagick(originalType) { - currentType = ImageTypeMagick - } - - if !IsTypeSupported(currentType) { - govipsLog("govips", LogLevelInfo, fmt.Sprintf("failed to understand image format size=%d", len(src))) - return nil, currentType, originalType, ErrUnsupportedImageFormat - } - - importParams := createImportParams(currentType, params) - - if err := C.load_from_buffer(&importParams, unsafe.Pointer(&src[0]), C.size_t(len(src))); err != 0 { - return nil, currentType, originalType, handleImageError(importParams.outputImage) - } - - return importParams.outputImage, currentType, originalType, nil -} - -func maybeSetBoolParam(p BoolParameter, cp *C.Param) { - if p.IsSet() { - C.set_bool_param(cp, toGboolean(p.Get())) - } -} - -func maybeSetIntParam(p IntParameter, cp *C.Param) { - if p.IsSet() { - C.set_int_param(cp, C.int(p.Get())) - } -} - -func maybeSetDoubleParam(p Float64Parameter, cp *C.Param) { - if p.IsSet() { - C.set_double_param(cp, C.gdouble(p.Get())) - } -} - -func createImportParams(format ImageType, params *ImportParams) C.LoadParams { - p := C.create_load_params(C.ImageType(format)) - - maybeSetBoolParam(params.AutoRotate, &p.autorotate) - maybeSetBoolParam(params.FailOnError, &p.fail) - maybeSetIntParam(params.Page, &p.page) - maybeSetIntParam(params.NumPages, &p.n) - maybeSetIntParam(params.JpegShrinkFactor, &p.jpegShrink) - maybeSetDoubleParam(params.WebpScaleFactor, &p.webpScale) - maybeSetBoolParam(params.HeifThumbnail, &p.heifThumbnail) - maybeSetBoolParam(params.SvgUnlimited, &p.svgUnlimited) - maybeSetIntParam(params.Access, &p.access) - - if params.Density.IsSet() { - C.set_double_param(&p.dpi, C.gdouble(params.Density.Get())) - } - return p -} - -func newSaveParamsJPEG(in *C.VipsImage, params JpegExportParams) (C.struct_SaveParams, error) { - p := C.create_save_params(C.JPEG) - p.inputImage = in - p.stripMetadata = C.int(boolToInt(params.StripMetadata)) - p.quality = C.int(params.Quality) - p.interlace = C.int(boolToInt(params.Interlace)) - p.jpegOptimizeCoding = C.int(boolToInt(params.OptimizeCoding)) - p.jpegSubsample = C.VipsForeignSubsample(params.SubsampleMode) - p.jpegTrellisQuant = C.int(boolToInt(params.TrellisQuant)) - p.jpegOvershootDeringing = C.int(boolToInt(params.OvershootDeringing)) - p.jpegOptimizeScans = C.int(boolToInt(params.OptimizeScans)) - p.jpegQuantTable = C.int(params.QuantTable) - if err := applyKeep(&p, params.Keep); err != nil { - return p, err - } - return p, nil -} - -func vipsSaveJPEGToBuffer(in *C.VipsImage, params JpegExportParams) ([]byte, error) { - incOpCounter("save_jpeg_buffer") - - p, err := newSaveParamsJPEG(in, params) - if err != nil { - return nil, err - } - return vipsSaveToBuffer(p) -} - -func newSaveParamsPNG(in *C.VipsImage, params PngExportParams) (C.struct_SaveParams, error) { - p := C.create_save_params(C.PNG) - p.inputImage = in - p.quality = C.int(params.Quality) - p.stripMetadata = C.int(boolToInt(params.StripMetadata)) - p.interlace = C.int(boolToInt(params.Interlace)) - p.pngCompression = C.int(params.Compression) - p.pngFilter = C.VipsForeignPngFilter(params.Filter) - p.pngPalette = C.int(boolToInt(params.Palette)) - p.pngDither = C.double(params.Dither) - p.pngBitdepth = C.int(params.Bitdepth) - if err := applyKeep(&p, params.Keep); err != nil { - return p, err - } - return p, nil -} - -func vipsSavePNGToBuffer(in *C.VipsImage, params PngExportParams) ([]byte, error) { - incOpCounter("save_png_buffer") - - p, err := newSaveParamsPNG(in, params) - if err != nil { - return nil, err - } - return vipsSaveToBuffer(p) -} - -// newSaveParamsWebP returns the populated params and a cleanup function -// that must be called once the save has completed; it frees the ICC -// profile C string, if one was allocated. Both the buffer and streaming -// WebP savers go through here, so the TargetSize version guard covers -// both paths. -func newSaveParamsWebP(in *C.VipsImage, params WebpExportParams) (C.struct_SaveParams, func(), error) { - noop := func() {} - p := C.create_save_params(C.WEBP) - p.inputImage = in - p.stripMetadata = C.int(boolToInt(params.StripMetadata)) - p.quality = C.int(params.Quality) - p.webpLossless = C.int(boolToInt(params.Lossless)) - p.webpNearLossless = C.int(boolToInt(params.NearLossless)) - p.webpReductionEffort = C.int(params.ReductionEffort) - p.webpMinSize = C.int(boolToInt(params.MinSize)) - p.webpKMin = C.int(params.MinKeyFrames) - p.webpKMax = C.int(params.MaxKeyFrames) - - if params.TargetSize > 0 { - // webpsave's "target_size" property was added in libvips 8.17.4; setting - // it on an older libvips fails at the C layer with an opaque "no property - // named `target_size'" error. Fail clearly instead. - if MajorVersion < 8 || (MajorVersion == 8 && MinorVersion < 17) || - (MajorVersion == 8 && MinorVersion == 17 && MicroVersion < 4) { - return p, noop, fmt.Errorf("WebpExportParams.TargetSize requires libvips 8.17.4+, found %s", Version) - } - p.webpTargetSize = C.int(params.TargetSize) - } - - if err := applyKeep(&p, params.Keep); err != nil { - return p, noop, err - } - - iccProfile := params.IccProfile - if p.keepSet != 0 && ForeignKeep(p.keep)&ForeignKeepIcc == 0 { - // An explicit Keep without ICC wins over any profile: libvips - // would otherwise embed a supplied profile regardless of keep. - iccProfile = "" - } - - cleanup := noop - if iccProfile != "" { - p.webpIccProfile = C.CString(iccProfile) - profile := p.webpIccProfile - cleanup = func() { C.free(unsafe.Pointer(profile)) } - } - return p, cleanup, nil -} - -func vipsSaveWebPToBuffer(in *C.VipsImage, params WebpExportParams) ([]byte, error) { - incOpCounter("save_webp_buffer") - - p, cleanup, err := newSaveParamsWebP(in, params) - if err != nil { - return nil, err - } - defer cleanup() - - return vipsSaveToBuffer(p) -} - -func newSaveParamsTIFF(in *C.VipsImage, params TiffExportParams) (C.struct_SaveParams, error) { - p := C.create_save_params(C.TIFF) - p.inputImage = in - p.stripMetadata = C.int(boolToInt(params.StripMetadata)) - p.quality = C.int(params.Quality) - p.tiffCompression = C.VipsForeignTiffCompression(params.Compression) - p.tiffPyramid = C.int(boolToInt(params.Pyramid)) - p.tiffTile = C.int(boolToInt(params.Tile)) - tileHeight := params.TileHeight - tileWidth := params.TileWidth - if tileHeight <= 0 { - tileHeight = 256 - } - if tileWidth <= 0 { - tileWidth = 256 - } - p.tiffTileHeight = C.int(tileHeight) - p.tiffTileWidth = C.int(tileWidth) - if err := applyKeep(&p, params.Keep); err != nil { - return p, err - } - return p, nil -} - -func vipsSaveTIFFToBuffer(in *C.VipsImage, params TiffExportParams) ([]byte, error) { - incOpCounter("save_tiff_buffer") - - p, err := newSaveParamsTIFF(in, params) - if err != nil { - return nil, err - } - return vipsSaveToBuffer(p) -} - -func newSaveParamsHEIF(in *C.VipsImage, params HeifExportParams) (C.struct_SaveParams, error) { - p := C.create_save_params(C.HEIF) - p.inputImage = in - p.outputFormat = C.HEIF - p.quality = C.int(params.Quality) - p.heifLossless = C.int(boolToInt(params.Lossless)) - p.heifBitdepth = C.int(params.Bitdepth) - p.heifEffort = C.int(params.Effort) - if err := applyKeep(&p, params.Keep); err != nil { - return p, err - } - return p, nil -} - -func vipsSaveHEIFToBuffer(in *C.VipsImage, params HeifExportParams) ([]byte, error) { - incOpCounter("save_heif_buffer") - - p, err := newSaveParamsHEIF(in, params) - if err != nil { - return nil, err - } - return vipsSaveToBuffer(p) -} - -func vipsSaveAVIFToBuffer(in *C.VipsImage, params AvifExportParams) ([]byte, error) { - incOpCounter("save_heif_buffer") - - // Speed was deprecated but we want to avoid breaking code that still uses it: - effort := params.Effort - if params.Speed != 0 { - effort = params.Speed - } - - p := C.create_save_params(C.AVIF) - p.inputImage = in - p.stripMetadata = C.int(boolToInt(params.StripMetadata)) - p.outputFormat = C.AVIF - p.quality = C.int(params.Quality) - p.heifLossless = C.int(boolToInt(params.Lossless)) - p.heifBitdepth = C.int(params.Bitdepth) - p.heifEffort = C.int(effort) - if err := applyKeep(&p, params.Keep); err != nil { - return nil, err - } - - return vipsSaveToBuffer(p) -} - -func vipsSaveJP2KToBuffer(in *C.VipsImage, params Jp2kExportParams) ([]byte, error) { - incOpCounter("save_jp2k_buffer") - - p := C.create_save_params(C.JP2K) - p.inputImage = in - p.outputFormat = C.JP2K - p.quality = C.int(params.Quality) - p.jp2kLossless = C.int(boolToInt(params.Lossless)) - p.jp2kTileWidth = C.int(params.TileWidth) - p.jp2kTileHeight = C.int(params.TileHeight) - p.jpegSubsample = C.VipsForeignSubsample(params.SubsampleMode) - if err := applyKeep(&p, params.Keep); err != nil { - return nil, err - } - - return vipsSaveToBuffer(p) -} - -func newSaveParamsGIF(in *C.VipsImage, params GifExportParams) (C.struct_SaveParams, error) { - p := C.create_save_params(C.GIF) - p.inputImage = in - p.quality = C.int(params.Quality) - p.gifDither = C.double(params.Dither) - p.gifEffort = C.int(params.Effort) - p.gifBitdepth = C.int(params.Bitdepth) - if err := applyKeep(&p, params.Keep); err != nil { - return p, err - } - return p, nil -} - -func vipsSaveGIFToBuffer(in *C.VipsImage, params GifExportParams) ([]byte, error) { - incOpCounter("save_gif_buffer") - - p, err := newSaveParamsGIF(in, params) - if err != nil { - return nil, err - } - return vipsSaveToBuffer(p) -} - -func vipsSaveJxlToBuffer(in *C.VipsImage, params JxlExportParams) ([]byte, error) { - incOpCounter("save_jxl_buffer") - - p := C.create_save_params(C.JXL) - p.inputImage = in - p.outputFormat = C.JXL - p.quality = C.int(params.Quality) - p.jxlLossless = C.int(boolToInt(params.Lossless)) - p.jxlTier = C.int(params.Tier) - p.jxlDistance = C.double(params.Distance) - p.jxlEffort = C.int(params.Effort) - if err := applyKeep(&p, params.Keep); err != nil { - return nil, err - } - - return vipsSaveToBuffer(p) -} - -func vipsSaveMagickToBuffer(in *C.VipsImage, params MagickExportParams) ([]byte, error) { - incOpCounter("save_magick_buffer") - - if params.Format == "" { - return nil, errors.New("magick format required") - } - p := C.create_save_params(C.MAGICK) - p.inputImage = in - p.outputFormat = C.MAGICK - p.quality = C.int(params.Quality) - // libvips copies the string into the operation; nothing else frees it. - cFormat := C.CString(params.Format) - defer freeCString(cFormat) - p.magickFormat = cFormat - p.magickOptimizeGifFrames = C.int(boolToInt(params.OptimizeGifFrames)) - p.magickOptimizeGifTransparency = C.int(boolToInt(params.OptimizeGifTransparency)) - p.magickBitDepth = C.int(params.BitDepth) - if err := applyKeep(&p, params.Keep); err != nil { - return nil, err - } - - return vipsSaveToBuffer(p) -} - -func vipsSaveToBuffer(params C.struct_SaveParams) ([]byte, error) { - if err := C.save_to_buffer(¶ms); err != 0 { - return nil, handleSaveBufferError(params.outputBuffer) - } - - buf := C.GoBytes(params.outputBuffer, C.int(params.outputLen)) - defer gFreePointer(params.outputBuffer) - - return buf, nil -} diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/foreign.h b/vendor/github.com/davidbyttow/govips/v2/vips/foreign.h deleted file mode 100644 index d22619ca44..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/foreign.h +++ /dev/null @@ -1,155 +0,0 @@ -// https://libvips.github.io/libvips/API/current/VipsForeignSave.html - -// clang-format off -// include order matters -#include - -#include -#include -// clang-format n - -#ifndef BOOL -#define BOOL int -#endif - -typedef enum types { - UNKNOWN = 0, - JPEG, - WEBP, - PNG, - TIFF, - GIF, - PDF, - SVG, - MAGICK, - HEIF, - BMP, - AVIF, - JP2K, - JXL, - PSD, -} ImageType; - -typedef enum ParamType { - PARAM_TYPE_NULL, - PARAM_TYPE_BOOL, - PARAM_TYPE_INT, - PARAM_TYPE_DOUBLE, -} ParamType; - -typedef struct Param { - ParamType type; - - union Value { - gboolean b; - gint i; - gdouble d; - } value; - - gboolean is_set; - -} Param; - -void set_bool_param(Param *p, gboolean b); -void set_int_param(Param *p, gint i); -void set_double_param(Param *p, gdouble d); - -typedef struct LoadParams { - ImageType inputFormat; - VipsBlob *inputBlob; - VipsImage *outputImage; - - Param autorotate; - Param fail; - Param page; - Param n; - Param dpi; - Param jpegShrink; - Param webpScale; - Param heifThumbnail; - Param svgUnlimited; - Param access; - -} LoadParams; - -LoadParams create_load_params(ImageType inputFormat); -int load_from_buffer(LoadParams *params, void *buf, size_t len); - -typedef struct SaveParams { - VipsImage *inputImage; - void *outputBuffer; - ImageType outputFormat; - size_t outputLen; - - BOOL stripMetadata; - // libvips "keep" flags (VipsForeignKeep, 8.15+). Plain int so the header - // still compiles against libvips 8.14; only applied when keepSet. - int keep; - BOOL keepSet; - int quality; - BOOL interlace; - - // JPEG - BOOL jpegOptimizeCoding; - VipsForeignSubsample jpegSubsample; - BOOL jpegTrellisQuant; - BOOL jpegOvershootDeringing; - BOOL jpegOptimizeScans; - int jpegQuantTable; - - // PNG - int pngCompression; - VipsForeignPngFilter pngFilter; - BOOL pngPalette; - double pngDither; - int pngBitdepth; - - // GIF (with CGIF) - double gifDither; - int gifEffort; - int gifBitdepth; - - // WEBP - BOOL webpLossless; - BOOL webpNearLossless; - int webpReductionEffort; - char *webpIccProfile; - BOOL webpMinSize; - int webpKMin; - int webpKMax; - int webpTargetSize; - - // HEIF - https://github.com/libvips/libvips/blob/master/libvips/foreign/heifsave.c#L71 - int heifBitdepth; // Bitdepth to save at for >8 bit images - BOOL heifLossless; // Lossless compression - int heifEffort; // CPU effort (0 - 9) - - // TIFF - VipsForeignTiffCompression tiffCompression; - VipsForeignTiffPredictor tiffPredictor; - BOOL tiffPyramid; - BOOL tiffTile; - int tiffTileHeight; - int tiffTileWidth; - - // JPEG2000 - BOOL jp2kLossless; - int jp2kTileWidth; - int jp2kTileHeight; - - // JXL - int jxlTier; - double jxlDistance; - int jxlEffort; - BOOL jxlLossless; - - // MAGICK - char *magickFormat; - BOOL magickOptimizeGifFrames; - BOOL magickOptimizeGifTransparency; - int magickBitDepth; -} SaveParams; - -SaveParams create_save_params(ImageType outputFormat); -int save_to_buffer(SaveParams *params); - diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/gen_enum_extras.go b/vendor/github.com/davidbyttow/govips/v2/vips/gen_enum_extras.go deleted file mode 100644 index 2e739a82fd..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/gen_enum_extras.go +++ /dev/null @@ -1,139 +0,0 @@ -// Code generated by vipsgen. DO NOT EDIT. -// -// Enum types needed by generated code that are not yet defined in the -// hand-written codebase. These will move to gen_enums.go in Phase 4. - -package vips - -// #include -import "C" - -// Precision represents VipsPrecision for controlling computation precision. -type Precision int - -const ( - PrecisionInteger Precision = C.VIPS_PRECISION_INTEGER - PrecisionFloat Precision = C.VIPS_PRECISION_FLOAT - PrecisionApproximate Precision = C.VIPS_PRECISION_APPROXIMATE -) - -// Combine represents VipsCombine for combining operations. -type Combine int - -const ( - CombineMax Combine = C.VIPS_COMBINE_MAX - CombineSum Combine = C.VIPS_COMBINE_SUM - CombineMin Combine = C.VIPS_COMBINE_MIN -) - -// CombineMode represents VipsCombineMode for draw combine operations. -type CombineMode int - -const ( - CombineModeSet CombineMode = C.VIPS_COMBINE_MODE_SET - CombineModeAdd CombineMode = C.VIPS_COMBINE_MODE_ADD -) - -// OperationBoolean represents VipsOperationBoolean for boolean operations. -type OperationBoolean int - -const ( - OperationBooleanAnd OperationBoolean = C.VIPS_OPERATION_BOOLEAN_AND - OperationBooleanOr OperationBoolean = C.VIPS_OPERATION_BOOLEAN_OR - OperationBooleanEor OperationBoolean = C.VIPS_OPERATION_BOOLEAN_EOR - OperationBooleanLshift OperationBoolean = C.VIPS_OPERATION_BOOLEAN_LSHIFT - OperationBooleanRshift OperationBoolean = C.VIPS_OPERATION_BOOLEAN_RSHIFT -) - -// OperationComplex represents VipsOperationComplex for complex operations. -type OperationComplex int - -const ( - OperationComplexPolar OperationComplex = C.VIPS_OPERATION_COMPLEX_POLAR - OperationComplexRect OperationComplex = C.VIPS_OPERATION_COMPLEX_RECT - OperationComplexConj OperationComplex = C.VIPS_OPERATION_COMPLEX_CONJ -) - -// OperationComplex2 represents VipsOperationComplex2 for binary complex operations. -type OperationComplex2 int - -const ( - OperationComplex2CrossPhase OperationComplex2 = C.VIPS_OPERATION_COMPLEX2_CROSS_PHASE -) - -// OperationComplexget represents VipsOperationComplexget for getting complex components. -type OperationComplexget int - -const ( - OperationComplexgetReal OperationComplexget = C.VIPS_OPERATION_COMPLEXGET_REAL - OperationComplexgetImag OperationComplexget = C.VIPS_OPERATION_COMPLEXGET_IMAG -) - -// OperationMath represents VipsOperationMath for math operations. -type OperationMath int - -const ( - OperationMathSin OperationMath = C.VIPS_OPERATION_MATH_SIN - OperationMathCos OperationMath = C.VIPS_OPERATION_MATH_COS - OperationMathTan OperationMath = C.VIPS_OPERATION_MATH_TAN - OperationMathAsin OperationMath = C.VIPS_OPERATION_MATH_ASIN - OperationMathAcos OperationMath = C.VIPS_OPERATION_MATH_ACOS - OperationMathAtan OperationMath = C.VIPS_OPERATION_MATH_ATAN - OperationMathLog OperationMath = C.VIPS_OPERATION_MATH_LOG - OperationMathLog10 OperationMath = C.VIPS_OPERATION_MATH_LOG10 - OperationMathExp OperationMath = C.VIPS_OPERATION_MATH_EXP - OperationMathExp10 OperationMath = C.VIPS_OPERATION_MATH_EXP10 -) - -// OperationMath2 represents VipsOperationMath2 for binary math operations. -type OperationMath2 int - -const ( - OperationMath2Pow OperationMath2 = C.VIPS_OPERATION_MATH2_POW - OperationMath2Wop OperationMath2 = C.VIPS_OPERATION_MATH2_WOP - OperationMath2Atan2 OperationMath2 = C.VIPS_OPERATION_MATH2_ATAN2 -) - -// OperationRelational represents VipsOperationRelational for relational operations. -type OperationRelational int - -const ( - OperationRelationalEqual OperationRelational = C.VIPS_OPERATION_RELATIONAL_EQUAL - OperationRelationalNoteq OperationRelational = C.VIPS_OPERATION_RELATIONAL_NOTEQ - OperationRelationalLess OperationRelational = C.VIPS_OPERATION_RELATIONAL_LESS - OperationRelationalLesseq OperationRelational = C.VIPS_OPERATION_RELATIONAL_LESSEQ - OperationRelationalMore OperationRelational = C.VIPS_OPERATION_RELATIONAL_MORE - OperationRelationalMoreeq OperationRelational = C.VIPS_OPERATION_RELATIONAL_MOREEQ -) - -// OperationRound represents VipsOperationRound for rounding operations. -type OperationRound int - -const ( - OperationRoundRint OperationRound = C.VIPS_OPERATION_ROUND_RINT - OperationRoundCeil OperationRound = C.VIPS_OPERATION_ROUND_CEIL - OperationRoundFloor OperationRound = C.VIPS_OPERATION_ROUND_FLOOR -) - -// OperationMorphology represents VipsOperationMorphology for morphological operations. -type OperationMorphology int - -const ( - OperationMorphologyErode OperationMorphology = C.VIPS_OPERATION_MORPHOLOGY_ERODE - OperationMorphologyDilate OperationMorphology = C.VIPS_OPERATION_MORPHOLOGY_DILATE -) - -// FailOn represents VipsFailOn for controlling error handling on load. -type FailOn int - -const ( - FailOnNone FailOn = C.VIPS_FAIL_ON_NONE - FailOnTruncated FailOn = C.VIPS_FAIL_ON_TRUNCATED - FailOnError FailOn = C.VIPS_FAIL_ON_ERROR - FailOnWarning FailOn = C.VIPS_FAIL_ON_WARNING -) - -// ForeignKeep represents VipsForeignKeep flags for controlling metadata retention. -type ForeignKeep int - -// Note: ForeignKeep is a flags (bitmask) type. Values combined with |. diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/generate.go b/vendor/github.com/davidbyttow/govips/v2/vips/generate.go deleted file mode 100644 index 52c946aae9..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/generate.go +++ /dev/null @@ -1,3 +0,0 @@ -package vips - -//go:generate go run ../cmd/vipsgen --generate --output=. diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/generated.c b/vendor/github.com/davidbyttow/govips/v2/vips/generated.c deleted file mode 100644 index c981daa4c2..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/generated.c +++ /dev/null @@ -1,5228 +0,0 @@ -// Code generated by vipsgen. DO NOT EDIT. -#include "generated.h" - -int gen_vips_CMC2LCh(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("CMC2LCh"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_CMYK2XYZ(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("CMYK2XYZ"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_HSV2sRGB(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("HSV2sRGB"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_LCh2CMC(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("LCh2CMC"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_LCh2Lab(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("LCh2Lab"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_Lab2LCh(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("Lab2LCh"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_Lab2LabQ(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("Lab2LabQ"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_Lab2LabS(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("Lab2LabS"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_Lab2XYZ(VipsImage * input, VipsImage ** out_out, GenLab2XYZOpts *opts) { - VipsOperation *op = vips_operation_new("Lab2XYZ"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_temp) { - { - VipsArrayDouble *arr = vips_array_double_new(opts->temp, opts->temp_n); - vips_object_set(VIPS_OBJECT(op), "temp", arr, NULL); - vips_area_unref(VIPS_AREA(arr)); - } - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_LabQ2Lab(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("LabQ2Lab"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_LabQ2LabS(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("LabQ2LabS"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_LabQ2sRGB(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("LabQ2sRGB"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_LabS2Lab(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("LabS2Lab"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_LabS2LabQ(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("LabS2LabQ"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_Oklab2Oklch(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("Oklab2Oklch"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_Oklab2XYZ(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("Oklab2XYZ"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_Oklch2Oklab(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("Oklch2Oklab"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_XYZ2CMYK(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("XYZ2CMYK"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_XYZ2Lab(VipsImage * input, VipsImage ** out_out, GenXYZ2LabOpts *opts) { - VipsOperation *op = vips_operation_new("XYZ2Lab"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_temp) { - { - VipsArrayDouble *arr = vips_array_double_new(opts->temp, opts->temp_n); - vips_object_set(VIPS_OBJECT(op), "temp", arr, NULL); - vips_area_unref(VIPS_AREA(arr)); - } - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_XYZ2Oklab(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("XYZ2Oklab"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_XYZ2Yxy(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("XYZ2Yxy"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_XYZ2scRGB(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("XYZ2scRGB"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_Yxy2XYZ(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("Yxy2XYZ"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_abs(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("abs"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_add(VipsImage * left, VipsImage * right, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("add"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "left", left, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "right", right, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_affine(VipsImage * input, double * matrix, int matrix_n, VipsImage ** out_out, GenAffineOpts *opts) { - VipsOperation *op = vips_operation_new("affine"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - { - VipsArrayDouble *arr = vips_array_double_new(matrix, matrix_n); - int ret = vips_object_set(VIPS_OBJECT(op), "matrix", arr, NULL); - vips_area_unref(VIPS_AREA(arr)); - if (ret) goto error; - } - - if (opts) { - if (opts->has_interpolate) { - vips_object_set(VIPS_OBJECT(op), "interpolate", opts->interpolate, NULL); - } - if (opts->has_oarea) { - { - VipsArrayInt *arr = vips_array_int_new(opts->oarea, opts->oarea_n); - vips_object_set(VIPS_OBJECT(op), "oarea", arr, NULL); - vips_area_unref(VIPS_AREA(arr)); - } - } - if (opts->has_odx) { - vips_object_set(VIPS_OBJECT(op), "odx", opts->odx, NULL); - } - if (opts->has_ody) { - vips_object_set(VIPS_OBJECT(op), "ody", opts->ody, NULL); - } - if (opts->has_idx) { - vips_object_set(VIPS_OBJECT(op), "idx", opts->idx, NULL); - } - if (opts->has_idy) { - vips_object_set(VIPS_OBJECT(op), "idy", opts->idy, NULL); - } - if (opts->has_background) { - { - VipsArrayDouble *arr = vips_array_double_new(opts->background, opts->background_n); - vips_object_set(VIPS_OBJECT(op), "background", arr, NULL); - vips_area_unref(VIPS_AREA(arr)); - } - } - if (opts->has_premultiplied) { - vips_object_set(VIPS_OBJECT(op), "premultiplied", (gboolean)opts->premultiplied, NULL); - } - if (opts->has_extend) { - vips_object_set(VIPS_OBJECT(op), "extend", (int)opts->extend, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_arrayjoin(VipsImage **input, int input_n, VipsImage ** out_out, GenArrayjoinOpts *opts) { - VipsOperation *op = vips_operation_new("arrayjoin"); - if (!op) return -1; - - { - VipsArrayImage *arr = vips_array_image_new(input, input_n); - int ret = vips_object_set(VIPS_OBJECT(op), "in", arr, NULL); - vips_area_unref(VIPS_AREA(arr)); - if (ret) goto error; - } - - if (opts) { - if (opts->has_across) { - vips_object_set(VIPS_OBJECT(op), "across", opts->across, NULL); - } - if (opts->has_shim) { - vips_object_set(VIPS_OBJECT(op), "shim", opts->shim, NULL); - } - if (opts->has_background) { - { - VipsArrayDouble *arr = vips_array_double_new(opts->background, opts->background_n); - vips_object_set(VIPS_OBJECT(op), "background", arr, NULL); - vips_area_unref(VIPS_AREA(arr)); - } - } - if (opts->has_halign) { - vips_object_set(VIPS_OBJECT(op), "halign", (int)opts->halign, NULL); - } - if (opts->has_valign) { - vips_object_set(VIPS_OBJECT(op), "valign", (int)opts->valign, NULL); - } - if (opts->has_hspacing) { - vips_object_set(VIPS_OBJECT(op), "hspacing", opts->hspacing, NULL); - } - if (opts->has_vspacing) { - vips_object_set(VIPS_OBJECT(op), "vspacing", opts->vspacing, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_autorot(VipsImage * input, VipsImage ** out_out, int * out_angle, int * out_flip) { - VipsOperation *op = vips_operation_new("autorot"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - g_object_get(VIPS_OBJECT(op), "angle", out_angle, NULL); - g_object_get(VIPS_OBJECT(op), "flip", out_flip, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_avg(VipsImage * input, double * out_out) { - VipsOperation *op = vips_operation_new("avg"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_bandbool(VipsImage * input, VipsOperationBoolean boolean, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("bandbool"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "boolean", (int)boolean, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_bandfold(VipsImage * input, VipsImage ** out_out, GenBandfoldOpts *opts) { - VipsOperation *op = vips_operation_new("bandfold"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_factor) { - vips_object_set(VIPS_OBJECT(op), "factor", opts->factor, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_bandjoin(VipsImage **input, int input_n, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("bandjoin"); - if (!op) return -1; - - { - VipsArrayImage *arr = vips_array_image_new(input, input_n); - int ret = vips_object_set(VIPS_OBJECT(op), "in", arr, NULL); - vips_area_unref(VIPS_AREA(arr)); - if (ret) goto error; - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_bandjoin_const(VipsImage * input, double * c, int c_n, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("bandjoin_const"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - { - VipsArrayDouble *arr = vips_array_double_new(c, c_n); - int ret = vips_object_set(VIPS_OBJECT(op), "c", arr, NULL); - vips_area_unref(VIPS_AREA(arr)); - if (ret) goto error; - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_bandmean(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("bandmean"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_bandrank(VipsImage **input, int input_n, VipsImage ** out_out, GenBandrankOpts *opts) { - VipsOperation *op = vips_operation_new("bandrank"); - if (!op) return -1; - - { - VipsArrayImage *arr = vips_array_image_new(input, input_n); - int ret = vips_object_set(VIPS_OBJECT(op), "in", arr, NULL); - vips_area_unref(VIPS_AREA(arr)); - if (ret) goto error; - } - - if (opts) { - if (opts->has_index) { - vips_object_set(VIPS_OBJECT(op), "index", opts->index, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_bandunfold(VipsImage * input, VipsImage ** out_out, GenBandunfoldOpts *opts) { - VipsOperation *op = vips_operation_new("bandunfold"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_factor) { - vips_object_set(VIPS_OBJECT(op), "factor", opts->factor, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_black(int width, int height, VipsImage ** out_out, GenBlackOpts *opts) { - VipsOperation *op = vips_operation_new("black"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "width", width, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "height", height, NULL)) goto error; - - if (opts) { - if (opts->has_bands) { - vips_object_set(VIPS_OBJECT(op), "bands", opts->bands, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_boolean(VipsImage * left, VipsImage * right, VipsOperationBoolean boolean, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("boolean"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "left", left, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "right", right, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "boolean", (int)boolean, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_boolean_const(VipsImage * input, VipsOperationBoolean boolean, double * c, int c_n, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("boolean_const"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "boolean", (int)boolean, NULL)) goto error; - { - VipsArrayDouble *arr = vips_array_double_new(c, c_n); - int ret = vips_object_set(VIPS_OBJECT(op), "c", arr, NULL); - vips_area_unref(VIPS_AREA(arr)); - if (ret) goto error; - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_buildlut(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("buildlut"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_byteswap(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("byteswap"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_cache(VipsImage * input, VipsImage ** out_out, GenCacheOpts *opts) { - VipsOperation *op = vips_operation_new("cache"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_maxTiles) { - vips_object_set(VIPS_OBJECT(op), "max-tiles", opts->maxTiles, NULL); - } - if (opts->has_tileHeight) { - vips_object_set(VIPS_OBJECT(op), "tile-height", opts->tileHeight, NULL); - } - if (opts->has_tileWidth) { - vips_object_set(VIPS_OBJECT(op), "tile-width", opts->tileWidth, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_canny(VipsImage * input, VipsImage ** out_out, GenCannyOpts *opts) { - VipsOperation *op = vips_operation_new("canny"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_sigma) { - vips_object_set(VIPS_OBJECT(op), "sigma", opts->sigma, NULL); - } - if (opts->has_precision) { - vips_object_set(VIPS_OBJECT(op), "precision", (int)opts->precision, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_cast(VipsImage * input, VipsBandFormat format, VipsImage ** out_out, GenCastOpts *opts) { - VipsOperation *op = vips_operation_new("cast"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "format", (int)format, NULL)) goto error; - - if (opts) { - if (opts->has_shift) { - vips_object_set(VIPS_OBJECT(op), "shift", (gboolean)opts->shift, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_clamp(VipsImage * input, VipsImage ** out_out, GenClampOpts *opts) { - VipsOperation *op = vips_operation_new("clamp"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_min) { - vips_object_set(VIPS_OBJECT(op), "min", opts->min, NULL); - } - if (opts->has_max) { - vips_object_set(VIPS_OBJECT(op), "max", opts->max, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_compass(VipsImage * input, VipsImage * mask, VipsImage ** out_out, GenCompassOpts *opts) { - VipsOperation *op = vips_operation_new("compass"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "mask", mask, NULL)) goto error; - - if (opts) { - if (opts->has_times) { - vips_object_set(VIPS_OBJECT(op), "times", opts->times, NULL); - } - if (opts->has_angle) { - vips_object_set(VIPS_OBJECT(op), "angle", (int)opts->angle, NULL); - } - if (opts->has_combine) { - vips_object_set(VIPS_OBJECT(op), "combine", (int)opts->combine, NULL); - } - if (opts->has_precision) { - vips_object_set(VIPS_OBJECT(op), "precision", (int)opts->precision, NULL); - } - if (opts->has_layers) { - vips_object_set(VIPS_OBJECT(op), "layers", opts->layers, NULL); - } - if (opts->has_cluster) { - vips_object_set(VIPS_OBJECT(op), "cluster", opts->cluster, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_complex(VipsImage * input, VipsOperationComplex cmplx, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("complex"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "cmplx", (int)cmplx, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_complex2(VipsImage * left, VipsImage * right, VipsOperationComplex2 cmplx, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("complex2"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "left", left, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "right", right, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "cmplx", (int)cmplx, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_complexform(VipsImage * left, VipsImage * right, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("complexform"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "left", left, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "right", right, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_complexget(VipsImage * input, VipsOperationComplexget get, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("complexget"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "get", (int)get, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_composite2(VipsImage * base, VipsImage * overlay, VipsBlendMode mode, VipsImage ** out_out, GenComposite2Opts *opts) { - VipsOperation *op = vips_operation_new("composite2"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "base", base, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "overlay", overlay, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "mode", (int)mode, NULL)) goto error; - - if (opts) { - if (opts->has_x) { - vips_object_set(VIPS_OBJECT(op), "x", opts->x, NULL); - } - if (opts->has_y) { - vips_object_set(VIPS_OBJECT(op), "y", opts->y, NULL); - } - if (opts->has_compositingSpace) { - vips_object_set(VIPS_OBJECT(op), "compositing-space", (int)opts->compositingSpace, NULL); - } - if (opts->has_premultiplied) { - vips_object_set(VIPS_OBJECT(op), "premultiplied", (gboolean)opts->premultiplied, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_conv(VipsImage * input, VipsImage * mask, VipsImage ** out_out, GenConvOpts *opts) { - VipsOperation *op = vips_operation_new("conv"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "mask", mask, NULL)) goto error; - - if (opts) { - if (opts->has_precision) { - vips_object_set(VIPS_OBJECT(op), "precision", (int)opts->precision, NULL); - } - if (opts->has_layers) { - vips_object_set(VIPS_OBJECT(op), "layers", opts->layers, NULL); - } - if (opts->has_cluster) { - vips_object_set(VIPS_OBJECT(op), "cluster", opts->cluster, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_conva(VipsImage * input, VipsImage * mask, VipsImage ** out_out, GenConvaOpts *opts) { - VipsOperation *op = vips_operation_new("conva"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "mask", mask, NULL)) goto error; - - if (opts) { - if (opts->has_layers) { - vips_object_set(VIPS_OBJECT(op), "layers", opts->layers, NULL); - } - if (opts->has_cluster) { - vips_object_set(VIPS_OBJECT(op), "cluster", opts->cluster, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_convasep(VipsImage * input, VipsImage * mask, VipsImage ** out_out, GenConvasepOpts *opts) { - VipsOperation *op = vips_operation_new("convasep"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "mask", mask, NULL)) goto error; - - if (opts) { - if (opts->has_layers) { - vips_object_set(VIPS_OBJECT(op), "layers", opts->layers, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_convf(VipsImage * input, VipsImage * mask, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("convf"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "mask", mask, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_convi(VipsImage * input, VipsImage * mask, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("convi"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "mask", mask, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_convsep(VipsImage * input, VipsImage * mask, VipsImage ** out_out, GenConvsepOpts *opts) { - VipsOperation *op = vips_operation_new("convsep"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "mask", mask, NULL)) goto error; - - if (opts) { - if (opts->has_precision) { - vips_object_set(VIPS_OBJECT(op), "precision", (int)opts->precision, NULL); - } - if (opts->has_layers) { - vips_object_set(VIPS_OBJECT(op), "layers", opts->layers, NULL); - } - if (opts->has_cluster) { - vips_object_set(VIPS_OBJECT(op), "cluster", opts->cluster, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_copy(VipsImage * input, VipsImage ** out_out, GenCopyOpts *opts) { - VipsOperation *op = vips_operation_new("copy"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_width) { - vips_object_set(VIPS_OBJECT(op), "width", opts->width, NULL); - } - if (opts->has_height) { - vips_object_set(VIPS_OBJECT(op), "height", opts->height, NULL); - } - if (opts->has_bands) { - vips_object_set(VIPS_OBJECT(op), "bands", opts->bands, NULL); - } - if (opts->has_format) { - vips_object_set(VIPS_OBJECT(op), "format", (int)opts->format, NULL); - } - if (opts->has_coding) { - vips_object_set(VIPS_OBJECT(op), "coding", (int)opts->coding, NULL); - } - if (opts->has_interpretation) { - vips_object_set(VIPS_OBJECT(op), "interpretation", (int)opts->interpretation, NULL); - } - if (opts->has_xres) { - vips_object_set(VIPS_OBJECT(op), "xres", opts->xres, NULL); - } - if (opts->has_yres) { - vips_object_set(VIPS_OBJECT(op), "yres", opts->yres, NULL); - } - if (opts->has_xoffset) { - vips_object_set(VIPS_OBJECT(op), "xoffset", opts->xoffset, NULL); - } - if (opts->has_yoffset) { - vips_object_set(VIPS_OBJECT(op), "yoffset", opts->yoffset, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_countlines(VipsImage * input, VipsDirection direction, double * out_nolines) { - VipsOperation *op = vips_operation_new("countlines"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "direction", (int)direction, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "nolines", out_nolines, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_dE00(VipsImage * left, VipsImage * right, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("dE00"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "left", left, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "right", right, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_dE76(VipsImage * left, VipsImage * right, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("dE76"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "left", left, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "right", right, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_dECMC(VipsImage * left, VipsImage * right, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("dECMC"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "left", left, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "right", right, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_deviate(VipsImage * input, double * out_out) { - VipsOperation *op = vips_operation_new("deviate"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_divide(VipsImage * left, VipsImage * right, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("divide"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "left", left, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "right", right, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_extract_area(VipsImage * input, int left, int top, int width, int height, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("extract_area"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "input", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "left", left, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "top", top, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "width", width, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "height", height, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_extract_band(VipsImage * input, int band, VipsImage ** out_out, GenExtractBandOpts *opts) { - VipsOperation *op = vips_operation_new("extract_band"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "band", band, NULL)) goto error; - - if (opts) { - if (opts->has_n) { - vips_object_set(VIPS_OBJECT(op), "n", opts->n, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_eye(int width, int height, VipsImage ** out_out, GenEyeOpts *opts) { - VipsOperation *op = vips_operation_new("eye"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "width", width, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "height", height, NULL)) goto error; - - if (opts) { - if (opts->has_uchar) { - vips_object_set(VIPS_OBJECT(op), "uchar", (gboolean)opts->uchar, NULL); - } - if (opts->has_factor) { - vips_object_set(VIPS_OBJECT(op), "factor", opts->factor, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_falsecolour(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("falsecolour"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_fastcor(VipsImage * input, VipsImage * ref, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("fastcor"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "ref", ref, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_fill_nearest(VipsImage * input, VipsImage ** out_out, VipsImage ** out_distance) { - VipsOperation *op = vips_operation_new("fill_nearest"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - g_object_get(VIPS_OBJECT(op), "distance", out_distance, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_flatten(VipsImage * input, VipsImage ** out_out, GenFlattenOpts *opts) { - VipsOperation *op = vips_operation_new("flatten"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_background) { - { - VipsArrayDouble *arr = vips_array_double_new(opts->background, opts->background_n); - vips_object_set(VIPS_OBJECT(op), "background", arr, NULL); - vips_area_unref(VIPS_AREA(arr)); - } - } - if (opts->has_maxAlpha) { - vips_object_set(VIPS_OBJECT(op), "max-alpha", opts->maxAlpha, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_flip(VipsImage * input, VipsDirection direction, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("flip"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "direction", (int)direction, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_float2rad(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("float2rad"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_fractsurf(int width, int height, double fractalDimension, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("fractsurf"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "width", width, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "height", height, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "fractal-dimension", fractalDimension, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_freqmult(VipsImage * input, VipsImage * mask, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("freqmult"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "mask", mask, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_fwfft(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("fwfft"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_gamma(VipsImage * input, VipsImage ** out_out, GenGammaOpts *opts) { - VipsOperation *op = vips_operation_new("gamma"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_exponent) { - vips_object_set(VIPS_OBJECT(op), "exponent", opts->exponent, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_gaussblur(VipsImage * input, double sigma, VipsImage ** out_out, GenGaussblurOpts *opts) { - VipsOperation *op = vips_operation_new("gaussblur"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "sigma", sigma, NULL)) goto error; - - if (opts) { - if (opts->has_minAmpl) { - vips_object_set(VIPS_OBJECT(op), "min-ampl", opts->minAmpl, NULL); - } - if (opts->has_precision) { - vips_object_set(VIPS_OBJECT(op), "precision", (int)opts->precision, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_gaussmat(double sigma, double minAmpl, VipsImage ** out_out, GenGaussmatOpts *opts) { - VipsOperation *op = vips_operation_new("gaussmat"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "sigma", sigma, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "min-ampl", minAmpl, NULL)) goto error; - - if (opts) { - if (opts->has_separable) { - vips_object_set(VIPS_OBJECT(op), "separable", (gboolean)opts->separable, NULL); - } - if (opts->has_precision) { - vips_object_set(VIPS_OBJECT(op), "precision", (int)opts->precision, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_gaussnoise(int width, int height, VipsImage ** out_out, GenGaussnoiseOpts *opts) { - VipsOperation *op = vips_operation_new("gaussnoise"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "width", width, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "height", height, NULL)) goto error; - - if (opts) { - if (opts->has_sigma) { - vips_object_set(VIPS_OBJECT(op), "sigma", opts->sigma, NULL); - } - if (opts->has_mean) { - vips_object_set(VIPS_OBJECT(op), "mean", opts->mean, NULL); - } - if (opts->has_seed) { - vips_object_set(VIPS_OBJECT(op), "seed", opts->seed, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_globalbalance(VipsImage * input, VipsImage ** out_out, GenGlobalbalanceOpts *opts) { - VipsOperation *op = vips_operation_new("globalbalance"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_gamma) { - vips_object_set(VIPS_OBJECT(op), "gamma", opts->gamma, NULL); - } - if (opts->has_intOutput) { - vips_object_set(VIPS_OBJECT(op), "int-output", (gboolean)opts->intOutput, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_gravity(VipsImage * input, VipsCompassDirection direction, int width, int height, VipsImage ** out_out, GenGravityOpts *opts) { - VipsOperation *op = vips_operation_new("gravity"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "direction", (int)direction, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "width", width, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "height", height, NULL)) goto error; - - if (opts) { - if (opts->has_extend) { - vips_object_set(VIPS_OBJECT(op), "extend", (int)opts->extend, NULL); - } - if (opts->has_background) { - { - VipsArrayDouble *arr = vips_array_double_new(opts->background, opts->background_n); - vips_object_set(VIPS_OBJECT(op), "background", arr, NULL); - vips_area_unref(VIPS_AREA(arr)); - } - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_grey(int width, int height, VipsImage ** out_out, GenGreyOpts *opts) { - VipsOperation *op = vips_operation_new("grey"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "width", width, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "height", height, NULL)) goto error; - - if (opts) { - if (opts->has_uchar) { - vips_object_set(VIPS_OBJECT(op), "uchar", (gboolean)opts->uchar, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_grid(VipsImage * input, int tileHeight, int across, int down, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("grid"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "tile-height", tileHeight, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "across", across, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "down", down, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_hist_cum(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("hist_cum"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_hist_entropy(VipsImage * input, double * out_out) { - VipsOperation *op = vips_operation_new("hist_entropy"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_hist_equal(VipsImage * input, VipsImage ** out_out, GenHistEqualOpts *opts) { - VipsOperation *op = vips_operation_new("hist_equal"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_band) { - vips_object_set(VIPS_OBJECT(op), "band", opts->band, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_hist_find(VipsImage * input, VipsImage ** out_out, GenHistFindOpts *opts) { - VipsOperation *op = vips_operation_new("hist_find"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_band) { - vips_object_set(VIPS_OBJECT(op), "band", opts->band, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_hist_find_indexed(VipsImage * input, VipsImage * index, VipsImage ** out_out, GenHistFindIndexedOpts *opts) { - VipsOperation *op = vips_operation_new("hist_find_indexed"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "index", index, NULL)) goto error; - - if (opts) { - if (opts->has_combine) { - vips_object_set(VIPS_OBJECT(op), "combine", (int)opts->combine, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_hist_find_ndim(VipsImage * input, VipsImage ** out_out, GenHistFindNdimOpts *opts) { - VipsOperation *op = vips_operation_new("hist_find_ndim"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_bins) { - vips_object_set(VIPS_OBJECT(op), "bins", opts->bins, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_hist_ismonotonic(VipsImage * input, int * out_monotonic) { - VipsOperation *op = vips_operation_new("hist_ismonotonic"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "monotonic", out_monotonic, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_hist_local(VipsImage * input, int width, int height, VipsImage ** out_out, GenHistLocalOpts *opts) { - VipsOperation *op = vips_operation_new("hist_local"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "width", width, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "height", height, NULL)) goto error; - - if (opts) { - if (opts->has_maxSlope) { - vips_object_set(VIPS_OBJECT(op), "max-slope", opts->maxSlope, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_hist_match(VipsImage * input, VipsImage * ref, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("hist_match"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "ref", ref, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_hist_norm(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("hist_norm"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_hist_plot(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("hist_plot"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_hough_circle(VipsImage * input, VipsImage ** out_out, GenHoughCircleOpts *opts) { - VipsOperation *op = vips_operation_new("hough_circle"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_scale) { - vips_object_set(VIPS_OBJECT(op), "scale", opts->scale, NULL); - } - if (opts->has_minRadius) { - vips_object_set(VIPS_OBJECT(op), "min-radius", opts->minRadius, NULL); - } - if (opts->has_maxRadius) { - vips_object_set(VIPS_OBJECT(op), "max-radius", opts->maxRadius, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_hough_line(VipsImage * input, VipsImage ** out_out, GenHoughLineOpts *opts) { - VipsOperation *op = vips_operation_new("hough_line"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_width) { - vips_object_set(VIPS_OBJECT(op), "width", opts->width, NULL); - } - if (opts->has_height) { - vips_object_set(VIPS_OBJECT(op), "height", opts->height, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_icc_export(VipsImage * input, VipsImage ** out_out, GenIccExportOpts *opts) { - VipsOperation *op = vips_operation_new("icc_export"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_pcs) { - vips_object_set(VIPS_OBJECT(op), "pcs", (int)opts->pcs, NULL); - } - if (opts->has_intent) { - vips_object_set(VIPS_OBJECT(op), "intent", (int)opts->intent, NULL); - } - if (opts->has_blackPointCompensation) { - vips_object_set(VIPS_OBJECT(op), "black-point-compensation", (gboolean)opts->blackPointCompensation, NULL); - } - if (opts->has_outputProfile) { - vips_object_set(VIPS_OBJECT(op), "output-profile", opts->outputProfile, NULL); - } - if (opts->has_depth) { - vips_object_set(VIPS_OBJECT(op), "depth", opts->depth, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_icc_import(VipsImage * input, VipsImage ** out_out, GenIccImportOpts *opts) { - VipsOperation *op = vips_operation_new("icc_import"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_pcs) { - vips_object_set(VIPS_OBJECT(op), "pcs", (int)opts->pcs, NULL); - } - if (opts->has_intent) { - vips_object_set(VIPS_OBJECT(op), "intent", (int)opts->intent, NULL); - } - if (opts->has_blackPointCompensation) { - vips_object_set(VIPS_OBJECT(op), "black-point-compensation", (gboolean)opts->blackPointCompensation, NULL); - } - if (opts->has_embedded) { - vips_object_set(VIPS_OBJECT(op), "embedded", (gboolean)opts->embedded, NULL); - } - if (opts->has_inputProfile) { - vips_object_set(VIPS_OBJECT(op), "input-profile", opts->inputProfile, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_identity(VipsImage ** out_out, GenIdentityOpts *opts) { - VipsOperation *op = vips_operation_new("identity"); - if (!op) return -1; - - - if (opts) { - if (opts->has_bands) { - vips_object_set(VIPS_OBJECT(op), "bands", opts->bands, NULL); - } - if (opts->has_ushort) { - vips_object_set(VIPS_OBJECT(op), "ushort", (gboolean)opts->ushort, NULL); - } - if (opts->has_size) { - vips_object_set(VIPS_OBJECT(op), "size", opts->size, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_ifthenelse(VipsImage * cond, VipsImage * in1, VipsImage * in2, VipsImage ** out_out, GenIfthenelseOpts *opts) { - VipsOperation *op = vips_operation_new("ifthenelse"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "cond", cond, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "in1", in1, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "in2", in2, NULL)) goto error; - - if (opts) { - if (opts->has_blend) { - vips_object_set(VIPS_OBJECT(op), "blend", (gboolean)opts->blend, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_insert(VipsImage * main, VipsImage * sub, int x, int y, VipsImage ** out_out, GenInsertOpts *opts) { - VipsOperation *op = vips_operation_new("insert"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "main", main, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "sub", sub, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "x", x, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "y", y, NULL)) goto error; - - if (opts) { - if (opts->has_expand) { - vips_object_set(VIPS_OBJECT(op), "expand", (gboolean)opts->expand, NULL); - } - if (opts->has_background) { - { - VipsArrayDouble *arr = vips_array_double_new(opts->background, opts->background_n); - vips_object_set(VIPS_OBJECT(op), "background", arr, NULL); - vips_area_unref(VIPS_AREA(arr)); - } - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_invert(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("invert"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_invertlut(VipsImage * input, VipsImage ** out_out, GenInvertlutOpts *opts) { - VipsOperation *op = vips_operation_new("invertlut"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_size) { - vips_object_set(VIPS_OBJECT(op), "size", opts->size, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_invfft(VipsImage * input, VipsImage ** out_out, GenInvfftOpts *opts) { - VipsOperation *op = vips_operation_new("invfft"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_real) { - vips_object_set(VIPS_OBJECT(op), "real", (gboolean)opts->real, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_join(VipsImage * in1, VipsImage * in2, VipsDirection direction, VipsImage ** out_out, GenJoinOpts *opts) { - VipsOperation *op = vips_operation_new("join"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in1", in1, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "in2", in2, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "direction", (int)direction, NULL)) goto error; - - if (opts) { - if (opts->has_expand) { - vips_object_set(VIPS_OBJECT(op), "expand", (gboolean)opts->expand, NULL); - } - if (opts->has_shim) { - vips_object_set(VIPS_OBJECT(op), "shim", opts->shim, NULL); - } - if (opts->has_background) { - { - VipsArrayDouble *arr = vips_array_double_new(opts->background, opts->background_n); - vips_object_set(VIPS_OBJECT(op), "background", arr, NULL); - vips_area_unref(VIPS_AREA(arr)); - } - } - if (opts->has_align) { - vips_object_set(VIPS_OBJECT(op), "align", (int)opts->align, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_labelregions(VipsImage * input, VipsImage ** out_mask, int * out_segments) { - VipsOperation *op = vips_operation_new("labelregions"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "mask", out_mask, NULL); - g_object_get(VIPS_OBJECT(op), "segments", out_segments, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_linear(VipsImage * input, double * a, int a_n, double * b, int b_n, VipsImage ** out_out, GenLinearOpts *opts) { - VipsOperation *op = vips_operation_new("linear"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - { - VipsArrayDouble *arr = vips_array_double_new(a, a_n); - int ret = vips_object_set(VIPS_OBJECT(op), "a", arr, NULL); - vips_area_unref(VIPS_AREA(arr)); - if (ret) goto error; - } - { - VipsArrayDouble *arr = vips_array_double_new(b, b_n); - int ret = vips_object_set(VIPS_OBJECT(op), "b", arr, NULL); - vips_area_unref(VIPS_AREA(arr)); - if (ret) goto error; - } - - if (opts) { - if (opts->has_uchar) { - vips_object_set(VIPS_OBJECT(op), "uchar", (gboolean)opts->uchar, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_linecache(VipsImage * input, VipsImage ** out_out, GenLinecacheOpts *opts) { - VipsOperation *op = vips_operation_new("linecache"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_tileHeight) { - vips_object_set(VIPS_OBJECT(op), "tile-height", opts->tileHeight, NULL); - } - if (opts->has_access) { - vips_object_set(VIPS_OBJECT(op), "access", (int)opts->access, NULL); - } - if (opts->has_threaded) { - vips_object_set(VIPS_OBJECT(op), "threaded", (gboolean)opts->threaded, NULL); - } - if (opts->has_persistent) { - vips_object_set(VIPS_OBJECT(op), "persistent", (gboolean)opts->persistent, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_logmat(double sigma, double minAmpl, VipsImage ** out_out, GenLogmatOpts *opts) { - VipsOperation *op = vips_operation_new("logmat"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "sigma", sigma, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "min-ampl", minAmpl, NULL)) goto error; - - if (opts) { - if (opts->has_separable) { - vips_object_set(VIPS_OBJECT(op), "separable", (gboolean)opts->separable, NULL); - } - if (opts->has_precision) { - vips_object_set(VIPS_OBJECT(op), "precision", (int)opts->precision, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_mapim(VipsImage * input, VipsImage * index, VipsImage ** out_out, GenMapimOpts *opts) { - VipsOperation *op = vips_operation_new("mapim"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "index", index, NULL)) goto error; - - if (opts) { - if (opts->has_interpolate) { - vips_object_set(VIPS_OBJECT(op), "interpolate", opts->interpolate, NULL); - } - if (opts->has_background) { - { - VipsArrayDouble *arr = vips_array_double_new(opts->background, opts->background_n); - vips_object_set(VIPS_OBJECT(op), "background", arr, NULL); - vips_area_unref(VIPS_AREA(arr)); - } - } - if (opts->has_premultiplied) { - vips_object_set(VIPS_OBJECT(op), "premultiplied", (gboolean)opts->premultiplied, NULL); - } - if (opts->has_extend) { - vips_object_set(VIPS_OBJECT(op), "extend", (int)opts->extend, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_maplut(VipsImage * input, VipsImage * lut, VipsImage ** out_out, GenMaplutOpts *opts) { - VipsOperation *op = vips_operation_new("maplut"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "lut", lut, NULL)) goto error; - - if (opts) { - if (opts->has_band) { - vips_object_set(VIPS_OBJECT(op), "band", opts->band, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_mask_butterworth(int width, int height, double order, double frequencyCutoff, double amplitudeCutoff, VipsImage ** out_out, GenMaskButterworthOpts *opts) { - VipsOperation *op = vips_operation_new("mask_butterworth"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "width", width, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "height", height, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "order", order, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "frequency-cutoff", frequencyCutoff, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "amplitude-cutoff", amplitudeCutoff, NULL)) goto error; - - if (opts) { - if (opts->has_uchar) { - vips_object_set(VIPS_OBJECT(op), "uchar", (gboolean)opts->uchar, NULL); - } - if (opts->has_nodc) { - vips_object_set(VIPS_OBJECT(op), "nodc", (gboolean)opts->nodc, NULL); - } - if (opts->has_reject) { - vips_object_set(VIPS_OBJECT(op), "reject", (gboolean)opts->reject, NULL); - } - if (opts->has_optical) { - vips_object_set(VIPS_OBJECT(op), "optical", (gboolean)opts->optical, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_mask_butterworth_band(int width, int height, double order, double frequencyCutoffX, double frequencyCutoffY, double radius, double amplitudeCutoff, VipsImage ** out_out, GenMaskButterworthBandOpts *opts) { - VipsOperation *op = vips_operation_new("mask_butterworth_band"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "width", width, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "height", height, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "order", order, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "frequency-cutoff-x", frequencyCutoffX, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "frequency-cutoff-y", frequencyCutoffY, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "radius", radius, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "amplitude-cutoff", amplitudeCutoff, NULL)) goto error; - - if (opts) { - if (opts->has_uchar) { - vips_object_set(VIPS_OBJECT(op), "uchar", (gboolean)opts->uchar, NULL); - } - if (opts->has_nodc) { - vips_object_set(VIPS_OBJECT(op), "nodc", (gboolean)opts->nodc, NULL); - } - if (opts->has_reject) { - vips_object_set(VIPS_OBJECT(op), "reject", (gboolean)opts->reject, NULL); - } - if (opts->has_optical) { - vips_object_set(VIPS_OBJECT(op), "optical", (gboolean)opts->optical, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_mask_butterworth_ring(int width, int height, double order, double frequencyCutoff, double amplitudeCutoff, double ringwidth, VipsImage ** out_out, GenMaskButterworthRingOpts *opts) { - VipsOperation *op = vips_operation_new("mask_butterworth_ring"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "width", width, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "height", height, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "order", order, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "frequency-cutoff", frequencyCutoff, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "amplitude-cutoff", amplitudeCutoff, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "ringwidth", ringwidth, NULL)) goto error; - - if (opts) { - if (opts->has_uchar) { - vips_object_set(VIPS_OBJECT(op), "uchar", (gboolean)opts->uchar, NULL); - } - if (opts->has_nodc) { - vips_object_set(VIPS_OBJECT(op), "nodc", (gboolean)opts->nodc, NULL); - } - if (opts->has_reject) { - vips_object_set(VIPS_OBJECT(op), "reject", (gboolean)opts->reject, NULL); - } - if (opts->has_optical) { - vips_object_set(VIPS_OBJECT(op), "optical", (gboolean)opts->optical, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_mask_fractal(int width, int height, double fractalDimension, VipsImage ** out_out, GenMaskFractalOpts *opts) { - VipsOperation *op = vips_operation_new("mask_fractal"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "width", width, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "height", height, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "fractal-dimension", fractalDimension, NULL)) goto error; - - if (opts) { - if (opts->has_uchar) { - vips_object_set(VIPS_OBJECT(op), "uchar", (gboolean)opts->uchar, NULL); - } - if (opts->has_nodc) { - vips_object_set(VIPS_OBJECT(op), "nodc", (gboolean)opts->nodc, NULL); - } - if (opts->has_reject) { - vips_object_set(VIPS_OBJECT(op), "reject", (gboolean)opts->reject, NULL); - } - if (opts->has_optical) { - vips_object_set(VIPS_OBJECT(op), "optical", (gboolean)opts->optical, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_mask_gaussian(int width, int height, double frequencyCutoff, double amplitudeCutoff, VipsImage ** out_out, GenMaskGaussianOpts *opts) { - VipsOperation *op = vips_operation_new("mask_gaussian"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "width", width, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "height", height, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "frequency-cutoff", frequencyCutoff, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "amplitude-cutoff", amplitudeCutoff, NULL)) goto error; - - if (opts) { - if (opts->has_uchar) { - vips_object_set(VIPS_OBJECT(op), "uchar", (gboolean)opts->uchar, NULL); - } - if (opts->has_nodc) { - vips_object_set(VIPS_OBJECT(op), "nodc", (gboolean)opts->nodc, NULL); - } - if (opts->has_reject) { - vips_object_set(VIPS_OBJECT(op), "reject", (gboolean)opts->reject, NULL); - } - if (opts->has_optical) { - vips_object_set(VIPS_OBJECT(op), "optical", (gboolean)opts->optical, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_mask_gaussian_band(int width, int height, double frequencyCutoffX, double frequencyCutoffY, double radius, double amplitudeCutoff, VipsImage ** out_out, GenMaskGaussianBandOpts *opts) { - VipsOperation *op = vips_operation_new("mask_gaussian_band"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "width", width, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "height", height, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "frequency-cutoff-x", frequencyCutoffX, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "frequency-cutoff-y", frequencyCutoffY, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "radius", radius, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "amplitude-cutoff", amplitudeCutoff, NULL)) goto error; - - if (opts) { - if (opts->has_uchar) { - vips_object_set(VIPS_OBJECT(op), "uchar", (gboolean)opts->uchar, NULL); - } - if (opts->has_nodc) { - vips_object_set(VIPS_OBJECT(op), "nodc", (gboolean)opts->nodc, NULL); - } - if (opts->has_reject) { - vips_object_set(VIPS_OBJECT(op), "reject", (gboolean)opts->reject, NULL); - } - if (opts->has_optical) { - vips_object_set(VIPS_OBJECT(op), "optical", (gboolean)opts->optical, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_mask_gaussian_ring(int width, int height, double frequencyCutoff, double amplitudeCutoff, double ringwidth, VipsImage ** out_out, GenMaskGaussianRingOpts *opts) { - VipsOperation *op = vips_operation_new("mask_gaussian_ring"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "width", width, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "height", height, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "frequency-cutoff", frequencyCutoff, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "amplitude-cutoff", amplitudeCutoff, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "ringwidth", ringwidth, NULL)) goto error; - - if (opts) { - if (opts->has_uchar) { - vips_object_set(VIPS_OBJECT(op), "uchar", (gboolean)opts->uchar, NULL); - } - if (opts->has_nodc) { - vips_object_set(VIPS_OBJECT(op), "nodc", (gboolean)opts->nodc, NULL); - } - if (opts->has_reject) { - vips_object_set(VIPS_OBJECT(op), "reject", (gboolean)opts->reject, NULL); - } - if (opts->has_optical) { - vips_object_set(VIPS_OBJECT(op), "optical", (gboolean)opts->optical, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_mask_ideal(int width, int height, double frequencyCutoff, VipsImage ** out_out, GenMaskIdealOpts *opts) { - VipsOperation *op = vips_operation_new("mask_ideal"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "width", width, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "height", height, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "frequency-cutoff", frequencyCutoff, NULL)) goto error; - - if (opts) { - if (opts->has_uchar) { - vips_object_set(VIPS_OBJECT(op), "uchar", (gboolean)opts->uchar, NULL); - } - if (opts->has_nodc) { - vips_object_set(VIPS_OBJECT(op), "nodc", (gboolean)opts->nodc, NULL); - } - if (opts->has_reject) { - vips_object_set(VIPS_OBJECT(op), "reject", (gboolean)opts->reject, NULL); - } - if (opts->has_optical) { - vips_object_set(VIPS_OBJECT(op), "optical", (gboolean)opts->optical, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_mask_ideal_band(int width, int height, double frequencyCutoffX, double frequencyCutoffY, double radius, VipsImage ** out_out, GenMaskIdealBandOpts *opts) { - VipsOperation *op = vips_operation_new("mask_ideal_band"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "width", width, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "height", height, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "frequency-cutoff-x", frequencyCutoffX, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "frequency-cutoff-y", frequencyCutoffY, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "radius", radius, NULL)) goto error; - - if (opts) { - if (opts->has_uchar) { - vips_object_set(VIPS_OBJECT(op), "uchar", (gboolean)opts->uchar, NULL); - } - if (opts->has_nodc) { - vips_object_set(VIPS_OBJECT(op), "nodc", (gboolean)opts->nodc, NULL); - } - if (opts->has_reject) { - vips_object_set(VIPS_OBJECT(op), "reject", (gboolean)opts->reject, NULL); - } - if (opts->has_optical) { - vips_object_set(VIPS_OBJECT(op), "optical", (gboolean)opts->optical, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_mask_ideal_ring(int width, int height, double frequencyCutoff, double ringwidth, VipsImage ** out_out, GenMaskIdealRingOpts *opts) { - VipsOperation *op = vips_operation_new("mask_ideal_ring"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "width", width, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "height", height, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "frequency-cutoff", frequencyCutoff, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "ringwidth", ringwidth, NULL)) goto error; - - if (opts) { - if (opts->has_uchar) { - vips_object_set(VIPS_OBJECT(op), "uchar", (gboolean)opts->uchar, NULL); - } - if (opts->has_nodc) { - vips_object_set(VIPS_OBJECT(op), "nodc", (gboolean)opts->nodc, NULL); - } - if (opts->has_reject) { - vips_object_set(VIPS_OBJECT(op), "reject", (gboolean)opts->reject, NULL); - } - if (opts->has_optical) { - vips_object_set(VIPS_OBJECT(op), "optical", (gboolean)opts->optical, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_match(VipsImage * ref, VipsImage * sec, int xr1, int yr1, int xs1, int ys1, int xr2, int yr2, int xs2, int ys2, VipsImage ** out_out, GenMatchOpts *opts) { - VipsOperation *op = vips_operation_new("match"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "ref", ref, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "sec", sec, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "xr1", xr1, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "yr1", yr1, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "xs1", xs1, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "ys1", ys1, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "xr2", xr2, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "yr2", yr2, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "xs2", xs2, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "ys2", ys2, NULL)) goto error; - - if (opts) { - if (opts->has_hwindow) { - vips_object_set(VIPS_OBJECT(op), "hwindow", opts->hwindow, NULL); - } - if (opts->has_harea) { - vips_object_set(VIPS_OBJECT(op), "harea", opts->harea, NULL); - } - if (opts->has_search) { - vips_object_set(VIPS_OBJECT(op), "search", (gboolean)opts->search, NULL); - } - if (opts->has_interpolate) { - vips_object_set(VIPS_OBJECT(op), "interpolate", opts->interpolate, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_math(VipsImage * input, VipsOperationMath math, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("math"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "math", (int)math, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_math2(VipsImage * left, VipsImage * right, VipsOperationMath2 math2, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("math2"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "left", left, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "right", right, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "math2", (int)math2, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_math2_const(VipsImage * input, VipsOperationMath2 math2, double * c, int c_n, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("math2_const"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "math2", (int)math2, NULL)) goto error; - { - VipsArrayDouble *arr = vips_array_double_new(c, c_n); - int ret = vips_object_set(VIPS_OBJECT(op), "c", arr, NULL); - vips_area_unref(VIPS_AREA(arr)); - if (ret) goto error; - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_matrixinvert(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("matrixinvert"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_matrixmultiply(VipsImage * left, VipsImage * right, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("matrixmultiply"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "left", left, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "right", right, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_maxpair(VipsImage * left, VipsImage * right, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("maxpair"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "left", left, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "right", right, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_merge(VipsImage * ref, VipsImage * sec, VipsDirection direction, int dx, int dy, VipsImage ** out_out, GenMergeOpts *opts) { - VipsOperation *op = vips_operation_new("merge"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "ref", ref, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "sec", sec, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "direction", (int)direction, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "dx", dx, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "dy", dy, NULL)) goto error; - - if (opts) { - if (opts->has_mblend) { - vips_object_set(VIPS_OBJECT(op), "mblend", opts->mblend, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_minpair(VipsImage * left, VipsImage * right, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("minpair"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "left", left, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "right", right, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_morph(VipsImage * input, VipsImage * mask, VipsOperationMorphology morph, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("morph"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "mask", mask, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "morph", (int)morph, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_mosaic(VipsImage * ref, VipsImage * sec, VipsDirection direction, int xref, int yref, int xsec, int ysec, VipsImage ** out_out, int * out_dx0, int * out_dy0, double * out_scale1, double * out_angle1, double * out_dy1, double * out_dx1, GenMosaicOpts *opts) { - VipsOperation *op = vips_operation_new("mosaic"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "ref", ref, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "sec", sec, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "direction", (int)direction, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "xref", xref, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "yref", yref, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "xsec", xsec, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "ysec", ysec, NULL)) goto error; - - if (opts) { - if (opts->has_hwindow) { - vips_object_set(VIPS_OBJECT(op), "hwindow", opts->hwindow, NULL); - } - if (opts->has_harea) { - vips_object_set(VIPS_OBJECT(op), "harea", opts->harea, NULL); - } - if (opts->has_mblend) { - vips_object_set(VIPS_OBJECT(op), "mblend", opts->mblend, NULL); - } - if (opts->has_bandno) { - vips_object_set(VIPS_OBJECT(op), "bandno", opts->bandno, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - g_object_get(VIPS_OBJECT(op), "dx0", out_dx0, NULL); - g_object_get(VIPS_OBJECT(op), "dy0", out_dy0, NULL); - g_object_get(VIPS_OBJECT(op), "scale1", out_scale1, NULL); - g_object_get(VIPS_OBJECT(op), "angle1", out_angle1, NULL); - g_object_get(VIPS_OBJECT(op), "dy1", out_dy1, NULL); - g_object_get(VIPS_OBJECT(op), "dx1", out_dx1, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_mosaic1(VipsImage * ref, VipsImage * sec, VipsDirection direction, int xr1, int yr1, int xs1, int ys1, int xr2, int yr2, int xs2, int ys2, VipsImage ** out_out, GenMosaic1Opts *opts) { - VipsOperation *op = vips_operation_new("mosaic1"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "ref", ref, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "sec", sec, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "direction", (int)direction, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "xr1", xr1, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "yr1", yr1, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "xs1", xs1, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "ys1", ys1, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "xr2", xr2, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "yr2", yr2, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "xs2", xs2, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "ys2", ys2, NULL)) goto error; - - if (opts) { - if (opts->has_hwindow) { - vips_object_set(VIPS_OBJECT(op), "hwindow", opts->hwindow, NULL); - } - if (opts->has_harea) { - vips_object_set(VIPS_OBJECT(op), "harea", opts->harea, NULL); - } - if (opts->has_search) { - vips_object_set(VIPS_OBJECT(op), "search", (gboolean)opts->search, NULL); - } - if (opts->has_interpolate) { - vips_object_set(VIPS_OBJECT(op), "interpolate", opts->interpolate, NULL); - } - if (opts->has_mblend) { - vips_object_set(VIPS_OBJECT(op), "mblend", opts->mblend, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_msb(VipsImage * input, VipsImage ** out_out, GenMsbOpts *opts) { - VipsOperation *op = vips_operation_new("msb"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_band) { - vips_object_set(VIPS_OBJECT(op), "band", opts->band, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_multiply(VipsImage * left, VipsImage * right, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("multiply"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "left", left, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "right", right, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_percent(VipsImage * input, double percent, int * out_threshold) { - VipsOperation *op = vips_operation_new("percent"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "percent", percent, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "threshold", out_threshold, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_perlin(int width, int height, VipsImage ** out_out, GenPerlinOpts *opts) { - VipsOperation *op = vips_operation_new("perlin"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "width", width, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "height", height, NULL)) goto error; - - if (opts) { - if (opts->has_cellSize) { - vips_object_set(VIPS_OBJECT(op), "cell-size", opts->cellSize, NULL); - } - if (opts->has_uchar) { - vips_object_set(VIPS_OBJECT(op), "uchar", (gboolean)opts->uchar, NULL); - } - if (opts->has_seed) { - vips_object_set(VIPS_OBJECT(op), "seed", opts->seed, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_phasecor(VipsImage * input, VipsImage * in2, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("phasecor"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "in2", in2, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_premultiply(VipsImage * input, VipsImage ** out_out, GenPremultiplyOpts *opts) { - VipsOperation *op = vips_operation_new("premultiply"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_maxAlpha) { - vips_object_set(VIPS_OBJECT(op), "max-alpha", opts->maxAlpha, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_prewitt(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("prewitt"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_profile(VipsImage * input, VipsImage ** out_columns, VipsImage ** out_rows) { - VipsOperation *op = vips_operation_new("profile"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "columns", out_columns, NULL); - g_object_get(VIPS_OBJECT(op), "rows", out_rows, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_project(VipsImage * input, VipsImage ** out_columns, VipsImage ** out_rows) { - VipsOperation *op = vips_operation_new("project"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "columns", out_columns, NULL); - g_object_get(VIPS_OBJECT(op), "rows", out_rows, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_quadratic(VipsImage * input, VipsImage * coeff, VipsImage ** out_out, GenQuadraticOpts *opts) { - VipsOperation *op = vips_operation_new("quadratic"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "coeff", coeff, NULL)) goto error; - - if (opts) { - if (opts->has_interpolate) { - vips_object_set(VIPS_OBJECT(op), "interpolate", opts->interpolate, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_rad2float(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("rad2float"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_rank(VipsImage * input, int width, int height, int index, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("rank"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "width", width, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "height", height, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "index", index, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_recomb(VipsImage * input, VipsImage * m, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("recomb"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "m", m, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_reduce(VipsImage * input, double hshrink, double vshrink, VipsImage ** out_out, GenReduceOpts *opts) { - VipsOperation *op = vips_operation_new("reduce"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "hshrink", hshrink, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "vshrink", vshrink, NULL)) goto error; - - if (opts) { - if (opts->has_kernel) { - vips_object_set(VIPS_OBJECT(op), "kernel", (int)opts->kernel, NULL); - } - if (opts->has_gap) { - vips_object_set(VIPS_OBJECT(op), "gap", opts->gap, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_reduceh(VipsImage * input, double hshrink, VipsImage ** out_out, GenReducehOpts *opts) { - VipsOperation *op = vips_operation_new("reduceh"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "hshrink", hshrink, NULL)) goto error; - - if (opts) { - if (opts->has_kernel) { - vips_object_set(VIPS_OBJECT(op), "kernel", (int)opts->kernel, NULL); - } - if (opts->has_gap) { - vips_object_set(VIPS_OBJECT(op), "gap", opts->gap, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_reducev(VipsImage * input, double vshrink, VipsImage ** out_out, GenReducevOpts *opts) { - VipsOperation *op = vips_operation_new("reducev"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "vshrink", vshrink, NULL)) goto error; - - if (opts) { - if (opts->has_kernel) { - vips_object_set(VIPS_OBJECT(op), "kernel", (int)opts->kernel, NULL); - } - if (opts->has_gap) { - vips_object_set(VIPS_OBJECT(op), "gap", opts->gap, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_relational(VipsImage * left, VipsImage * right, VipsOperationRelational relational, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("relational"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "left", left, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "right", right, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "relational", (int)relational, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_relational_const(VipsImage * input, VipsOperationRelational relational, double * c, int c_n, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("relational_const"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "relational", (int)relational, NULL)) goto error; - { - VipsArrayDouble *arr = vips_array_double_new(c, c_n); - int ret = vips_object_set(VIPS_OBJECT(op), "c", arr, NULL); - vips_area_unref(VIPS_AREA(arr)); - if (ret) goto error; - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_remainder(VipsImage * left, VipsImage * right, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("remainder"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "left", left, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "right", right, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_remainder_const(VipsImage * input, double * c, int c_n, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("remainder_const"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - { - VipsArrayDouble *arr = vips_array_double_new(c, c_n); - int ret = vips_object_set(VIPS_OBJECT(op), "c", arr, NULL); - vips_area_unref(VIPS_AREA(arr)); - if (ret) goto error; - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_remosaic(VipsImage * input, const char * oldStr, const char * newStr, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("remosaic"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "old-str", oldStr, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "new-str", newStr, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_replicate(VipsImage * input, int across, int down, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("replicate"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "across", across, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "down", down, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_rot(VipsImage * input, VipsAngle angle, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("rot"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "angle", (int)angle, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_rot45(VipsImage * input, VipsImage ** out_out, GenRot45Opts *opts) { - VipsOperation *op = vips_operation_new("rot45"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_angle) { - vips_object_set(VIPS_OBJECT(op), "angle", (int)opts->angle, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_rotate(VipsImage * input, double angle, VipsImage ** out_out, GenRotateOpts *opts) { - VipsOperation *op = vips_operation_new("rotate"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "angle", angle, NULL)) goto error; - - if (opts) { - if (opts->has_interpolate) { - vips_object_set(VIPS_OBJECT(op), "interpolate", opts->interpolate, NULL); - } - if (opts->has_background) { - { - VipsArrayDouble *arr = vips_array_double_new(opts->background, opts->background_n); - vips_object_set(VIPS_OBJECT(op), "background", arr, NULL); - vips_area_unref(VIPS_AREA(arr)); - } - } - if (opts->has_odx) { - vips_object_set(VIPS_OBJECT(op), "odx", opts->odx, NULL); - } - if (opts->has_ody) { - vips_object_set(VIPS_OBJECT(op), "ody", opts->ody, NULL); - } - if (opts->has_idx) { - vips_object_set(VIPS_OBJECT(op), "idx", opts->idx, NULL); - } - if (opts->has_idy) { - vips_object_set(VIPS_OBJECT(op), "idy", opts->idy, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_round(VipsImage * input, VipsOperationRound round, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("round"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "round", (int)round, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_sRGB2HSV(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("sRGB2HSV"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_sRGB2scRGB(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("sRGB2scRGB"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_scRGB2BW(VipsImage * input, VipsImage ** out_out, GenScRGB2BWOpts *opts) { - VipsOperation *op = vips_operation_new("scRGB2BW"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_depth) { - vips_object_set(VIPS_OBJECT(op), "depth", opts->depth, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_scRGB2XYZ(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("scRGB2XYZ"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_scRGB2sRGB(VipsImage * input, VipsImage ** out_out, GenScRGB2sRGBOpts *opts) { - VipsOperation *op = vips_operation_new("scRGB2sRGB"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_depth) { - vips_object_set(VIPS_OBJECT(op), "depth", opts->depth, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_scale(VipsImage * input, VipsImage ** out_out, GenScaleOpts *opts) { - VipsOperation *op = vips_operation_new("scale"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_exp) { - vips_object_set(VIPS_OBJECT(op), "exp", opts->exp, NULL); - } - if (opts->has_log) { - vips_object_set(VIPS_OBJECT(op), "log", (gboolean)opts->log, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_scharr(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("scharr"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_sequential(VipsImage * input, VipsImage ** out_out, GenSequentialOpts *opts) { - VipsOperation *op = vips_operation_new("sequential"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_tileHeight) { - vips_object_set(VIPS_OBJECT(op), "tile-height", opts->tileHeight, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_sharpen(VipsImage * input, VipsImage ** out_out, GenSharpenOpts *opts) { - VipsOperation *op = vips_operation_new("sharpen"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_sigma) { - vips_object_set(VIPS_OBJECT(op), "sigma", opts->sigma, NULL); - } - if (opts->has_x1) { - vips_object_set(VIPS_OBJECT(op), "x1", opts->x1, NULL); - } - if (opts->has_y2) { - vips_object_set(VIPS_OBJECT(op), "y2", opts->y2, NULL); - } - if (opts->has_y3) { - vips_object_set(VIPS_OBJECT(op), "y3", opts->y3, NULL); - } - if (opts->has_m1) { - vips_object_set(VIPS_OBJECT(op), "m1", opts->m1, NULL); - } - if (opts->has_m2) { - vips_object_set(VIPS_OBJECT(op), "m2", opts->m2, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_shrink(VipsImage * input, double hshrink, double vshrink, VipsImage ** out_out, GenShrinkOpts *opts) { - VipsOperation *op = vips_operation_new("shrink"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "hshrink", hshrink, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "vshrink", vshrink, NULL)) goto error; - - if (opts) { - if (opts->has_ceil) { - vips_object_set(VIPS_OBJECT(op), "ceil", (gboolean)opts->ceil, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_shrinkh(VipsImage * input, int hshrink, VipsImage ** out_out, GenShrinkhOpts *opts) { - VipsOperation *op = vips_operation_new("shrinkh"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "hshrink", hshrink, NULL)) goto error; - - if (opts) { - if (opts->has_ceil) { - vips_object_set(VIPS_OBJECT(op), "ceil", (gboolean)opts->ceil, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_shrinkv(VipsImage * input, int vshrink, VipsImage ** out_out, GenShrinkvOpts *opts) { - VipsOperation *op = vips_operation_new("shrinkv"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "vshrink", vshrink, NULL)) goto error; - - if (opts) { - if (opts->has_ceil) { - vips_object_set(VIPS_OBJECT(op), "ceil", (gboolean)opts->ceil, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_sign(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("sign"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_similarity(VipsImage * input, VipsImage ** out_out, GenSimilarityOpts *opts) { - VipsOperation *op = vips_operation_new("similarity"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_scale) { - vips_object_set(VIPS_OBJECT(op), "scale", opts->scale, NULL); - } - if (opts->has_angle) { - vips_object_set(VIPS_OBJECT(op), "angle", opts->angle, NULL); - } - if (opts->has_interpolate) { - vips_object_set(VIPS_OBJECT(op), "interpolate", opts->interpolate, NULL); - } - if (opts->has_background) { - { - VipsArrayDouble *arr = vips_array_double_new(opts->background, opts->background_n); - vips_object_set(VIPS_OBJECT(op), "background", arr, NULL); - vips_area_unref(VIPS_AREA(arr)); - } - } - if (opts->has_odx) { - vips_object_set(VIPS_OBJECT(op), "odx", opts->odx, NULL); - } - if (opts->has_ody) { - vips_object_set(VIPS_OBJECT(op), "ody", opts->ody, NULL); - } - if (opts->has_idx) { - vips_object_set(VIPS_OBJECT(op), "idx", opts->idx, NULL); - } - if (opts->has_idy) { - vips_object_set(VIPS_OBJECT(op), "idy", opts->idy, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_sines(int width, int height, VipsImage ** out_out, GenSinesOpts *opts) { - VipsOperation *op = vips_operation_new("sines"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "width", width, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "height", height, NULL)) goto error; - - if (opts) { - if (opts->has_uchar) { - vips_object_set(VIPS_OBJECT(op), "uchar", (gboolean)opts->uchar, NULL); - } - if (opts->has_hfreq) { - vips_object_set(VIPS_OBJECT(op), "hfreq", opts->hfreq, NULL); - } - if (opts->has_vfreq) { - vips_object_set(VIPS_OBJECT(op), "vfreq", opts->vfreq, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_smartcrop(VipsImage * input, int width, int height, int * out_attentionX, VipsImage ** out_out, int * out_attentionY, GenSmartcropOpts *opts) { - VipsOperation *op = vips_operation_new("smartcrop"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "input", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "width", width, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "height", height, NULL)) goto error; - - if (opts) { - if (opts->has_interesting) { - vips_object_set(VIPS_OBJECT(op), "interesting", (int)opts->interesting, NULL); - } - if (opts->has_premultiplied) { - vips_object_set(VIPS_OBJECT(op), "premultiplied", (gboolean)opts->premultiplied, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "attention-x", out_attentionX, NULL); - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - g_object_get(VIPS_OBJECT(op), "attention-y", out_attentionY, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_sobel(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("sobel"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_spcor(VipsImage * input, VipsImage * ref, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("spcor"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "ref", ref, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_spectrum(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("spectrum"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_stats(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("stats"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_stdif(VipsImage * input, int width, int height, VipsImage ** out_out, GenStdifOpts *opts) { - VipsOperation *op = vips_operation_new("stdif"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "width", width, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "height", height, NULL)) goto error; - - if (opts) { - if (opts->has_s0) { - vips_object_set(VIPS_OBJECT(op), "s0", opts->s0, NULL); - } - if (opts->has_b) { - vips_object_set(VIPS_OBJECT(op), "b", opts->b, NULL); - } - if (opts->has_m0) { - vips_object_set(VIPS_OBJECT(op), "m0", opts->m0, NULL); - } - if (opts->has_a) { - vips_object_set(VIPS_OBJECT(op), "a", opts->a, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_subsample(VipsImage * input, int xfac, int yfac, VipsImage ** out_out, GenSubsampleOpts *opts) { - VipsOperation *op = vips_operation_new("subsample"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "input", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "xfac", xfac, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "yfac", yfac, NULL)) goto error; - - if (opts) { - if (opts->has_point) { - vips_object_set(VIPS_OBJECT(op), "point", (gboolean)opts->point, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_subtract(VipsImage * left, VipsImage * right, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("subtract"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "left", left, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "right", right, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_sum(VipsImage **input, int input_n, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("sum"); - if (!op) return -1; - - { - VipsArrayImage *arr = vips_array_image_new(input, input_n); - int ret = vips_object_set(VIPS_OBJECT(op), "in", arr, NULL); - vips_area_unref(VIPS_AREA(arr)); - if (ret) goto error; - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_tilecache(VipsImage * input, VipsImage ** out_out, GenTilecacheOpts *opts) { - VipsOperation *op = vips_operation_new("tilecache"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_tileWidth) { - vips_object_set(VIPS_OBJECT(op), "tile-width", opts->tileWidth, NULL); - } - if (opts->has_tileHeight) { - vips_object_set(VIPS_OBJECT(op), "tile-height", opts->tileHeight, NULL); - } - if (opts->has_maxTiles) { - vips_object_set(VIPS_OBJECT(op), "max-tiles", opts->maxTiles, NULL); - } - if (opts->has_access) { - vips_object_set(VIPS_OBJECT(op), "access", (int)opts->access, NULL); - } - if (opts->has_threaded) { - vips_object_set(VIPS_OBJECT(op), "threaded", (gboolean)opts->threaded, NULL); - } - if (opts->has_persistent) { - vips_object_set(VIPS_OBJECT(op), "persistent", (gboolean)opts->persistent, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_tonelut(VipsImage ** out_out, GenTonelutOpts *opts) { - VipsOperation *op = vips_operation_new("tonelut"); - if (!op) return -1; - - - if (opts) { - if (opts->has_inMax) { - vips_object_set(VIPS_OBJECT(op), "in-max", opts->inMax, NULL); - } - if (opts->has_outMax) { - vips_object_set(VIPS_OBJECT(op), "out-max", opts->outMax, NULL); - } - if (opts->has_Lb) { - vips_object_set(VIPS_OBJECT(op), "Lb", opts->Lb, NULL); - } - if (opts->has_Lw) { - vips_object_set(VIPS_OBJECT(op), "Lw", opts->Lw, NULL); - } - if (opts->has_Ps) { - vips_object_set(VIPS_OBJECT(op), "Ps", opts->Ps, NULL); - } - if (opts->has_Pm) { - vips_object_set(VIPS_OBJECT(op), "Pm", opts->Pm, NULL); - } - if (opts->has_Ph) { - vips_object_set(VIPS_OBJECT(op), "Ph", opts->Ph, NULL); - } - if (opts->has_S) { - vips_object_set(VIPS_OBJECT(op), "S", opts->S, NULL); - } - if (opts->has_M) { - vips_object_set(VIPS_OBJECT(op), "M", opts->M, NULL); - } - if (opts->has_H) { - vips_object_set(VIPS_OBJECT(op), "H", opts->H, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_transpose3d(VipsImage * input, VipsImage ** out_out, GenTranspose3dOpts *opts) { - VipsOperation *op = vips_operation_new("transpose3d"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_pageHeight) { - vips_object_set(VIPS_OBJECT(op), "page-height", opts->pageHeight, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_uhdr2scRGB(VipsImage * input, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("uhdr2scRGB"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_unpremultiply(VipsImage * input, VipsImage ** out_out, GenUnpremultiplyOpts *opts) { - VipsOperation *op = vips_operation_new("unpremultiply"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_maxAlpha) { - vips_object_set(VIPS_OBJECT(op), "max-alpha", opts->maxAlpha, NULL); - } - if (opts->has_alphaBand) { - vips_object_set(VIPS_OBJECT(op), "alpha-band", opts->alphaBand, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_worley(int width, int height, VipsImage ** out_out, GenWorleyOpts *opts) { - VipsOperation *op = vips_operation_new("worley"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "width", width, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "height", height, NULL)) goto error; - - if (opts) { - if (opts->has_cellSize) { - vips_object_set(VIPS_OBJECT(op), "cell-size", opts->cellSize, NULL); - } - if (opts->has_seed) { - vips_object_set(VIPS_OBJECT(op), "seed", opts->seed, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_wrap(VipsImage * input, VipsImage ** out_out, GenWrapOpts *opts) { - VipsOperation *op = vips_operation_new("wrap"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "in", input, NULL)) goto error; - - if (opts) { - if (opts->has_x) { - vips_object_set(VIPS_OBJECT(op), "x", opts->x, NULL); - } - if (opts->has_y) { - vips_object_set(VIPS_OBJECT(op), "y", opts->y, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_xyz(int width, int height, VipsImage ** out_out, GenXyzOpts *opts) { - VipsOperation *op = vips_operation_new("xyz"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "width", width, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "height", height, NULL)) goto error; - - if (opts) { - if (opts->has_csize) { - vips_object_set(VIPS_OBJECT(op), "csize", opts->csize, NULL); - } - if (opts->has_dsize) { - vips_object_set(VIPS_OBJECT(op), "dsize", opts->dsize, NULL); - } - if (opts->has_esize) { - vips_object_set(VIPS_OBJECT(op), "esize", opts->esize, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_zone(int width, int height, VipsImage ** out_out, GenZoneOpts *opts) { - VipsOperation *op = vips_operation_new("zone"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "width", width, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "height", height, NULL)) goto error; - - if (opts) { - if (opts->has_uchar) { - vips_object_set(VIPS_OBJECT(op), "uchar", (gboolean)opts->uchar, NULL); - } - } - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - -int gen_vips_zoom(VipsImage * input, int xfac, int yfac, VipsImage ** out_out) { - VipsOperation *op = vips_operation_new("zoom"); - if (!op) return -1; - - if (vips_object_set(VIPS_OBJECT(op), "input", input, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "xfac", xfac, NULL)) goto error; - if (vips_object_set(VIPS_OBJECT(op), "yfac", yfac, NULL)) goto error; - - if (vips_cache_operation_buildp(&op)) goto error; - - g_object_get(VIPS_OBJECT(op), "out", out_out, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return 0; - -error: - vips_object_unref_outputs(VIPS_OBJECT(op)); - g_object_unref(op); - return -1; -} - diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/generated.go b/vendor/github.com/davidbyttow/govips/v2/vips/generated.go deleted file mode 100644 index 03237add33..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/generated.go +++ /dev/null @@ -1,5001 +0,0 @@ -// Code generated by vipsgen. DO NOT EDIT. -package vips - -// #include "generated.h" -import "C" - -import ( - "runtime" - "unsafe" -) - -// Ensure imports are used. -var _ = unsafe.Pointer(nil) - -// vipsGenCMC2LCh calls the vips CMC2LCh operation. -// transform LCh to CMC -func vipsGenCMC2LCh(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("CMC2LCh") - - var out_out *C.VipsImage - - ret := C.gen_vips_CMC2LCh(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenCMYK2XYZ calls the vips CMYK2XYZ operation. -// transform CMYK to XYZ -func vipsGenCMYK2XYZ(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("CMYK2XYZ") - - var out_out *C.VipsImage - - ret := C.gen_vips_CMYK2XYZ(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenHSV2sRGB calls the vips HSV2sRGB operation. -// transform HSV to sRGB -func vipsGenHSV2sRGB(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("HSV2sRGB") - - var out_out *C.VipsImage - - ret := C.gen_vips_HSV2sRGB(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenLCh2CMC calls the vips LCh2CMC operation. -// transform LCh to CMC -func vipsGenLCh2CMC(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("LCh2CMC") - - var out_out *C.VipsImage - - ret := C.gen_vips_LCh2CMC(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenLCh2Lab calls the vips LCh2Lab operation. -// transform LCh to Lab -func vipsGenLCh2Lab(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("LCh2Lab") - - var out_out *C.VipsImage - - ret := C.gen_vips_LCh2Lab(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenLab2LCh calls the vips Lab2LCh operation. -// transform Lab to LCh -func vipsGenLab2LCh(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("Lab2LCh") - - var out_out *C.VipsImage - - ret := C.gen_vips_Lab2LCh(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenLab2LabQ calls the vips Lab2LabQ operation. -// transform float Lab to LabQ coding -func vipsGenLab2LabQ(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("Lab2LabQ") - - var out_out *C.VipsImage - - ret := C.gen_vips_Lab2LabQ(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenLab2LabS calls the vips Lab2LabS operation. -// transform float Lab to signed short -func vipsGenLab2LabS(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("Lab2LabS") - - var out_out *C.VipsImage - - ret := C.gen_vips_Lab2LabS(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// Lab2XYZOptions are optional parameters for Lab2XYZ. -type Lab2XYZOptions struct { - Temp []float64 -} - -// vipsGenLab2XYZ calls the vips Lab2XYZ operation. -// transform CIELAB to XYZ -func vipsGenLab2XYZ(input *C.VipsImage, opts *Lab2XYZOptions) (*C.VipsImage, error) { - incOpCounter("Lab2XYZ") - - var out_out *C.VipsImage - - var cOpts C.GenLab2XYZOpts - var pinner runtime.Pinner - defer pinner.Unpin() - if opts != nil { - if opts.Temp != nil { - cOpts.has_temp = 1 - pinner.Pin(&opts.Temp[0]) - cOpts.temp = (*C.double)(unsafe.Pointer(&opts.Temp[0])) - cOpts.temp_n = C.int(len(opts.Temp)) - } - } - - ret := C.gen_vips_Lab2XYZ(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenLabQ2Lab calls the vips LabQ2Lab operation. -// unpack a LabQ image to float Lab -func vipsGenLabQ2Lab(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("LabQ2Lab") - - var out_out *C.VipsImage - - ret := C.gen_vips_LabQ2Lab(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenLabQ2LabS calls the vips LabQ2LabS operation. -// unpack a LabQ image to short Lab -func vipsGenLabQ2LabS(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("LabQ2LabS") - - var out_out *C.VipsImage - - ret := C.gen_vips_LabQ2LabS(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenLabQ2sRGB calls the vips LabQ2sRGB operation. -// convert a LabQ image to sRGB -func vipsGenLabQ2sRGB(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("LabQ2sRGB") - - var out_out *C.VipsImage - - ret := C.gen_vips_LabQ2sRGB(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenLabS2Lab calls the vips LabS2Lab operation. -// transform signed short Lab to float -func vipsGenLabS2Lab(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("LabS2Lab") - - var out_out *C.VipsImage - - ret := C.gen_vips_LabS2Lab(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenLabS2LabQ calls the vips LabS2LabQ operation. -// transform short Lab to LabQ coding -func vipsGenLabS2LabQ(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("LabS2LabQ") - - var out_out *C.VipsImage - - ret := C.gen_vips_LabS2LabQ(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenOklab2Oklch calls the vips Oklab2Oklch operation. -// transform Oklab to Oklch -func vipsGenOklab2Oklch(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("Oklab2Oklch") - - var out_out *C.VipsImage - - ret := C.gen_vips_Oklab2Oklch(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenOklab2XYZ calls the vips Oklab2XYZ operation. -// transform Oklab to XYZ -func vipsGenOklab2XYZ(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("Oklab2XYZ") - - var out_out *C.VipsImage - - ret := C.gen_vips_Oklab2XYZ(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenOklch2Oklab calls the vips Oklch2Oklab operation. -// transform Oklch to Oklab -func vipsGenOklch2Oklab(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("Oklch2Oklab") - - var out_out *C.VipsImage - - ret := C.gen_vips_Oklch2Oklab(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenXYZ2CMYK calls the vips XYZ2CMYK operation. -// transform XYZ to CMYK -func vipsGenXYZ2CMYK(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("XYZ2CMYK") - - var out_out *C.VipsImage - - ret := C.gen_vips_XYZ2CMYK(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// XYZ2LabOptions are optional parameters for XYZ2Lab. -type XYZ2LabOptions struct { - Temp []float64 -} - -// vipsGenXYZ2Lab calls the vips XYZ2Lab operation. -// transform XYZ to Lab -func vipsGenXYZ2Lab(input *C.VipsImage, opts *XYZ2LabOptions) (*C.VipsImage, error) { - incOpCounter("XYZ2Lab") - - var out_out *C.VipsImage - - var cOpts C.GenXYZ2LabOpts - var pinner runtime.Pinner - defer pinner.Unpin() - if opts != nil { - if opts.Temp != nil { - cOpts.has_temp = 1 - pinner.Pin(&opts.Temp[0]) - cOpts.temp = (*C.double)(unsafe.Pointer(&opts.Temp[0])) - cOpts.temp_n = C.int(len(opts.Temp)) - } - } - - ret := C.gen_vips_XYZ2Lab(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenXYZ2Oklab calls the vips XYZ2Oklab operation. -// transform XYZ to Oklab -func vipsGenXYZ2Oklab(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("XYZ2Oklab") - - var out_out *C.VipsImage - - ret := C.gen_vips_XYZ2Oklab(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenXYZ2Yxy calls the vips XYZ2Yxy operation. -// transform XYZ to Yxy -func vipsGenXYZ2Yxy(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("XYZ2Yxy") - - var out_out *C.VipsImage - - ret := C.gen_vips_XYZ2Yxy(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenXYZ2scRGB calls the vips XYZ2scRGB operation. -// transform XYZ to scRGB -func vipsGenXYZ2scRGB(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("XYZ2scRGB") - - var out_out *C.VipsImage - - ret := C.gen_vips_XYZ2scRGB(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenYxy2XYZ calls the vips Yxy2XYZ operation. -// transform Yxy to XYZ -func vipsGenYxy2XYZ(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("Yxy2XYZ") - - var out_out *C.VipsImage - - ret := C.gen_vips_Yxy2XYZ(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenAbs calls the vips abs operation. -// absolute value of an image -func vipsGenAbs(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("abs") - - var out_out *C.VipsImage - - ret := C.gen_vips_abs(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenAdd calls the vips add operation. -// add two images -func vipsGenAdd(left *C.VipsImage, right *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("add") - - var out_out *C.VipsImage - - ret := C.gen_vips_add(left, right, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// AffineOptions are optional parameters for affine. -type AffineOptions struct { - Interpolate *C.VipsInterpolate - Oarea []int - Odx *float64 - Ody *float64 - Idx *float64 - Idy *float64 - Background []float64 - Premultiplied *bool - Extend *ExtendStrategy -} - -// vipsGenAffine calls the vips affine operation. -// affine transform of an image -func vipsGenAffine(input *C.VipsImage, matrix []float64, opts *AffineOptions) (*C.VipsImage, error) { - incOpCounter("affine") - - var out_out *C.VipsImage - - var cOpts C.GenAffineOpts - var pinner runtime.Pinner - defer pinner.Unpin() - if opts != nil { - if opts.Interpolate != nil { - cOpts.has_interpolate = 1 - cOpts.interpolate = opts.Interpolate - } - if opts.Oarea != nil { - cOpts.has_oarea = 1 - pinner.Pin(&opts.Oarea[0]) - cOpts.oarea = (*C.int)(unsafe.Pointer(&opts.Oarea[0])) - cOpts.oarea_n = C.int(len(opts.Oarea)) - } - if opts.Odx != nil { - cOpts.has_odx = 1 - cOpts.odx = C.double(*opts.Odx) - } - if opts.Ody != nil { - cOpts.has_ody = 1 - cOpts.ody = C.double(*opts.Ody) - } - if opts.Idx != nil { - cOpts.has_idx = 1 - cOpts.idx = C.double(*opts.Idx) - } - if opts.Idy != nil { - cOpts.has_idy = 1 - cOpts.idy = C.double(*opts.Idy) - } - if opts.Background != nil { - cOpts.has_background = 1 - pinner.Pin(&opts.Background[0]) - cOpts.background = (*C.double)(unsafe.Pointer(&opts.Background[0])) - cOpts.background_n = C.int(len(opts.Background)) - } - if opts.Premultiplied != nil { - cOpts.has_premultiplied = 1 - cOpts.premultiplied = C.int(boolToInt(*opts.Premultiplied)) - } - if opts.Extend != nil { - cOpts.has_extend = 1 - cOpts.extend = C.VipsExtend(*opts.Extend) - } - } - - ret := C.gen_vips_affine(input, (*C.double)(unsafe.Pointer(&matrix[0])), C.int(len(matrix)), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// ArrayjoinOptions are optional parameters for arrayjoin. -type ArrayjoinOptions struct { - Across *int - Shim *int - Background []float64 - Halign *Align - Valign *Align - Hspacing *int - Vspacing *int -} - -// vipsGenArrayjoin calls the vips arrayjoin operation. -// join an array of images -func vipsGenArrayjoin(input []*C.VipsImage, opts *ArrayjoinOptions) (*C.VipsImage, error) { - incOpCounter("arrayjoin") - - var out_out *C.VipsImage - - var cOpts C.GenArrayjoinOpts - var pinner runtime.Pinner - defer pinner.Unpin() - if opts != nil { - if opts.Across != nil { - cOpts.has_across = 1 - cOpts.across = C.int(*opts.Across) - } - if opts.Shim != nil { - cOpts.has_shim = 1 - cOpts.shim = C.int(*opts.Shim) - } - if opts.Background != nil { - cOpts.has_background = 1 - pinner.Pin(&opts.Background[0]) - cOpts.background = (*C.double)(unsafe.Pointer(&opts.Background[0])) - cOpts.background_n = C.int(len(opts.Background)) - } - if opts.Halign != nil { - cOpts.has_halign = 1 - cOpts.halign = C.VipsAlign(*opts.Halign) - } - if opts.Valign != nil { - cOpts.has_valign = 1 - cOpts.valign = C.VipsAlign(*opts.Valign) - } - if opts.Hspacing != nil { - cOpts.has_hspacing = 1 - cOpts.hspacing = C.int(*opts.Hspacing) - } - if opts.Vspacing != nil { - cOpts.has_vspacing = 1 - cOpts.vspacing = C.int(*opts.Vspacing) - } - } - - ret := C.gen_vips_arrayjoin((**C.VipsImage)(unsafe.Pointer(&input[0])), C.int(len(input)), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenAutorot calls the vips autorot operation. -// autorotate image by exif tag -func vipsGenAutorot(input *C.VipsImage) (*C.VipsImage, Angle, bool, error) { - incOpCounter("autorot") - - var out_out *C.VipsImage - var out_angle C.int - var out_flip C.int - - ret := C.gen_vips_autorot(input, &out_out, &out_angle, &out_flip) - if ret != 0 { - return nil, 0, false, handleImageError(out_out) - } - - return out_out, Angle(out_angle), out_flip != 0, nil -} - -// vipsGenAvg calls the vips avg operation. -// find image average -func vipsGenAvg(input *C.VipsImage) (float64, error) { - incOpCounter("avg") - - var out_out C.double - - ret := C.gen_vips_avg(input, &out_out) - if ret != 0 { - return 0, handleVipsError() - } - - return float64(out_out), nil -} - -// vipsGenBandbool calls the vips bandbool operation. -// boolean operation across image bands -func vipsGenBandbool(input *C.VipsImage, boolean OperationBoolean) (*C.VipsImage, error) { - incOpCounter("bandbool") - - var out_out *C.VipsImage - - ret := C.gen_vips_bandbool(input, C.VipsOperationBoolean(boolean), &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// BandfoldOptions are optional parameters for bandfold. -type BandfoldOptions struct { - Factor *int -} - -// vipsGenBandfold calls the vips bandfold operation. -// fold up x axis into bands -func vipsGenBandfold(input *C.VipsImage, opts *BandfoldOptions) (*C.VipsImage, error) { - incOpCounter("bandfold") - - var out_out *C.VipsImage - - var cOpts C.GenBandfoldOpts - if opts != nil { - if opts.Factor != nil { - cOpts.has_factor = 1 - cOpts.factor = C.int(*opts.Factor) - } - } - - ret := C.gen_vips_bandfold(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenBandjoin calls the vips bandjoin operation. -// bandwise join a set of images -func vipsGenBandjoin(input []*C.VipsImage) (*C.VipsImage, error) { - incOpCounter("bandjoin") - - var out_out *C.VipsImage - - ret := C.gen_vips_bandjoin((**C.VipsImage)(unsafe.Pointer(&input[0])), C.int(len(input)), &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenBandjoinConst calls the vips bandjoin_const operation. -// append a constant band to an image -func vipsGenBandjoinConst(input *C.VipsImage, c []float64) (*C.VipsImage, error) { - incOpCounter("bandjoin_const") - - var out_out *C.VipsImage - - ret := C.gen_vips_bandjoin_const(input, (*C.double)(unsafe.Pointer(&c[0])), C.int(len(c)), &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenBandmean calls the vips bandmean operation. -// band-wise average -func vipsGenBandmean(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("bandmean") - - var out_out *C.VipsImage - - ret := C.gen_vips_bandmean(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// BandrankOptions are optional parameters for bandrank. -type BandrankOptions struct { - Index *int -} - -// vipsGenBandrank calls the vips bandrank operation. -// band-wise rank of a set of images -func vipsGenBandrank(input []*C.VipsImage, opts *BandrankOptions) (*C.VipsImage, error) { - incOpCounter("bandrank") - - var out_out *C.VipsImage - - var cOpts C.GenBandrankOpts - if opts != nil { - if opts.Index != nil { - cOpts.has_index = 1 - cOpts.index = C.int(*opts.Index) - } - } - - ret := C.gen_vips_bandrank((**C.VipsImage)(unsafe.Pointer(&input[0])), C.int(len(input)), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// BandunfoldOptions are optional parameters for bandunfold. -type BandunfoldOptions struct { - Factor *int -} - -// vipsGenBandunfold calls the vips bandunfold operation. -// unfold image bands into x axis -func vipsGenBandunfold(input *C.VipsImage, opts *BandunfoldOptions) (*C.VipsImage, error) { - incOpCounter("bandunfold") - - var out_out *C.VipsImage - - var cOpts C.GenBandunfoldOpts - if opts != nil { - if opts.Factor != nil { - cOpts.has_factor = 1 - cOpts.factor = C.int(*opts.Factor) - } - } - - ret := C.gen_vips_bandunfold(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// BlackOptions are optional parameters for black. -type BlackOptions struct { - Bands *int -} - -// vipsGenBlack calls the vips black operation. -// make a black image -func vipsGenBlack(width int, height int, opts *BlackOptions) (*C.VipsImage, error) { - incOpCounter("black") - - var out_out *C.VipsImage - - var cOpts C.GenBlackOpts - if opts != nil { - if opts.Bands != nil { - cOpts.has_bands = 1 - cOpts.bands = C.int(*opts.Bands) - } - } - - ret := C.gen_vips_black(C.int(width), C.int(height), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenBoolean calls the vips boolean operation. -// boolean operation on two images -func vipsGenBoolean(left *C.VipsImage, right *C.VipsImage, boolean OperationBoolean) (*C.VipsImage, error) { - incOpCounter("boolean") - - var out_out *C.VipsImage - - ret := C.gen_vips_boolean(left, right, C.VipsOperationBoolean(boolean), &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenBooleanConst calls the vips boolean_const operation. -// boolean operations against a constant -func vipsGenBooleanConst(input *C.VipsImage, boolean OperationBoolean, c []float64) (*C.VipsImage, error) { - incOpCounter("boolean_const") - - var out_out *C.VipsImage - - ret := C.gen_vips_boolean_const(input, C.VipsOperationBoolean(boolean), (*C.double)(unsafe.Pointer(&c[0])), C.int(len(c)), &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenBuildlut calls the vips buildlut operation. -// build a look-up table -func vipsGenBuildlut(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("buildlut") - - var out_out *C.VipsImage - - ret := C.gen_vips_buildlut(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenByteswap calls the vips byteswap operation. -// byteswap an image -func vipsGenByteswap(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("byteswap") - - var out_out *C.VipsImage - - ret := C.gen_vips_byteswap(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// CacheOptions are optional parameters for cache. -type CacheOptions struct { - MaxTiles *int - TileHeight *int - TileWidth *int -} - -// vipsGenCache calls the vips cache operation. -// cache an image -func vipsGenCache(input *C.VipsImage, opts *CacheOptions) (*C.VipsImage, error) { - incOpCounter("cache") - - var out_out *C.VipsImage - - var cOpts C.GenCacheOpts - if opts != nil { - if opts.MaxTiles != nil { - cOpts.has_maxTiles = 1 - cOpts.maxTiles = C.int(*opts.MaxTiles) - } - if opts.TileHeight != nil { - cOpts.has_tileHeight = 1 - cOpts.tileHeight = C.int(*opts.TileHeight) - } - if opts.TileWidth != nil { - cOpts.has_tileWidth = 1 - cOpts.tileWidth = C.int(*opts.TileWidth) - } - } - - ret := C.gen_vips_cache(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// CannyOptions are optional parameters for canny. -type CannyOptions struct { - Sigma *float64 - Precision *Precision -} - -// vipsGenCanny calls the vips canny operation. -// Canny edge detector -func vipsGenCanny(input *C.VipsImage, opts *CannyOptions) (*C.VipsImage, error) { - incOpCounter("canny") - - var out_out *C.VipsImage - - var cOpts C.GenCannyOpts - if opts != nil { - if opts.Sigma != nil { - cOpts.has_sigma = 1 - cOpts.sigma = C.double(*opts.Sigma) - } - if opts.Precision != nil { - cOpts.has_precision = 1 - cOpts.precision = C.VipsPrecision(*opts.Precision) - } - } - - ret := C.gen_vips_canny(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// CastOptions are optional parameters for cast. -type CastOptions struct { - Shift *bool -} - -// vipsGenCast calls the vips cast operation. -// cast an image -func vipsGenCast(input *C.VipsImage, format BandFormat, opts *CastOptions) (*C.VipsImage, error) { - incOpCounter("cast") - - var out_out *C.VipsImage - - var cOpts C.GenCastOpts - if opts != nil { - if opts.Shift != nil { - cOpts.has_shift = 1 - cOpts.shift = C.int(boolToInt(*opts.Shift)) - } - } - - ret := C.gen_vips_cast(input, C.VipsBandFormat(format), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// ClampOptions are optional parameters for clamp. -type ClampOptions struct { - Min *float64 - Max *float64 -} - -// vipsGenClamp calls the vips clamp operation. -// clamp values of an image -func vipsGenClamp(input *C.VipsImage, opts *ClampOptions) (*C.VipsImage, error) { - incOpCounter("clamp") - - var out_out *C.VipsImage - - var cOpts C.GenClampOpts - if opts != nil { - if opts.Min != nil { - cOpts.has_min = 1 - cOpts.min = C.double(*opts.Min) - } - if opts.Max != nil { - cOpts.has_max = 1 - cOpts.max = C.double(*opts.Max) - } - } - - ret := C.gen_vips_clamp(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// CompassOptions are optional parameters for compass. -type CompassOptions struct { - Times *int - Angle *Angle45 - Combine *Combine - Precision *Precision - Layers *int - Cluster *int -} - -// vipsGenCompass calls the vips compass operation. -// convolve with rotating mask -func vipsGenCompass(input *C.VipsImage, mask *C.VipsImage, opts *CompassOptions) (*C.VipsImage, error) { - incOpCounter("compass") - - var out_out *C.VipsImage - - var cOpts C.GenCompassOpts - if opts != nil { - if opts.Times != nil { - cOpts.has_times = 1 - cOpts.times = C.int(*opts.Times) - } - if opts.Angle != nil { - cOpts.has_angle = 1 - cOpts.angle = C.VipsAngle45(*opts.Angle) - } - if opts.Combine != nil { - cOpts.has_combine = 1 - cOpts.combine = C.VipsCombine(*opts.Combine) - } - if opts.Precision != nil { - cOpts.has_precision = 1 - cOpts.precision = C.VipsPrecision(*opts.Precision) - } - if opts.Layers != nil { - cOpts.has_layers = 1 - cOpts.layers = C.int(*opts.Layers) - } - if opts.Cluster != nil { - cOpts.has_cluster = 1 - cOpts.cluster = C.int(*opts.Cluster) - } - } - - ret := C.gen_vips_compass(input, mask, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenComplex calls the vips complex operation. -// perform a complex operation on an image -func vipsGenComplex(input *C.VipsImage, cmplx OperationComplex) (*C.VipsImage, error) { - incOpCounter("complex") - - var out_out *C.VipsImage - - ret := C.gen_vips_complex(input, C.VipsOperationComplex(cmplx), &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenComplex2 calls the vips complex2 operation. -// complex binary operations on two images -func vipsGenComplex2(left *C.VipsImage, right *C.VipsImage, cmplx OperationComplex2) (*C.VipsImage, error) { - incOpCounter("complex2") - - var out_out *C.VipsImage - - ret := C.gen_vips_complex2(left, right, C.VipsOperationComplex2(cmplx), &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenComplexform calls the vips complexform operation. -// form a complex image from two real images -func vipsGenComplexform(left *C.VipsImage, right *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("complexform") - - var out_out *C.VipsImage - - ret := C.gen_vips_complexform(left, right, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenComplexget calls the vips complexget operation. -// get a component from a complex image -func vipsGenComplexget(input *C.VipsImage, get OperationComplexget) (*C.VipsImage, error) { - incOpCounter("complexget") - - var out_out *C.VipsImage - - ret := C.gen_vips_complexget(input, C.VipsOperationComplexget(get), &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// Composite2Options are optional parameters for composite2. -type Composite2Options struct { - X *int - Y *int - CompositingSpace *Interpretation - Premultiplied *bool -} - -// vipsGenComposite2 calls the vips composite2 operation. -// blend a pair of images with a blend mode -func vipsGenComposite2(base *C.VipsImage, overlay *C.VipsImage, mode BlendMode, opts *Composite2Options) (*C.VipsImage, error) { - incOpCounter("composite2") - - var out_out *C.VipsImage - - var cOpts C.GenComposite2Opts - if opts != nil { - if opts.X != nil { - cOpts.has_x = 1 - cOpts.x = C.int(*opts.X) - } - if opts.Y != nil { - cOpts.has_y = 1 - cOpts.y = C.int(*opts.Y) - } - if opts.CompositingSpace != nil { - cOpts.has_compositingSpace = 1 - cOpts.compositingSpace = C.VipsInterpretation(*opts.CompositingSpace) - } - if opts.Premultiplied != nil { - cOpts.has_premultiplied = 1 - cOpts.premultiplied = C.int(boolToInt(*opts.Premultiplied)) - } - } - - ret := C.gen_vips_composite2(base, overlay, C.VipsBlendMode(mode), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// ConvOptions are optional parameters for conv. -type ConvOptions struct { - Precision *Precision - Layers *int - Cluster *int -} - -// vipsGenConv calls the vips conv operation. -// convolution operation -func vipsGenConv(input *C.VipsImage, mask *C.VipsImage, opts *ConvOptions) (*C.VipsImage, error) { - incOpCounter("conv") - - var out_out *C.VipsImage - - var cOpts C.GenConvOpts - if opts != nil { - if opts.Precision != nil { - cOpts.has_precision = 1 - cOpts.precision = C.VipsPrecision(*opts.Precision) - } - if opts.Layers != nil { - cOpts.has_layers = 1 - cOpts.layers = C.int(*opts.Layers) - } - if opts.Cluster != nil { - cOpts.has_cluster = 1 - cOpts.cluster = C.int(*opts.Cluster) - } - } - - ret := C.gen_vips_conv(input, mask, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// ConvaOptions are optional parameters for conva. -type ConvaOptions struct { - Layers *int - Cluster *int -} - -// vipsGenConva calls the vips conva operation. -// approximate integer convolution -func vipsGenConva(input *C.VipsImage, mask *C.VipsImage, opts *ConvaOptions) (*C.VipsImage, error) { - incOpCounter("conva") - - var out_out *C.VipsImage - - var cOpts C.GenConvaOpts - if opts != nil { - if opts.Layers != nil { - cOpts.has_layers = 1 - cOpts.layers = C.int(*opts.Layers) - } - if opts.Cluster != nil { - cOpts.has_cluster = 1 - cOpts.cluster = C.int(*opts.Cluster) - } - } - - ret := C.gen_vips_conva(input, mask, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// ConvasepOptions are optional parameters for convasep. -type ConvasepOptions struct { - Layers *int -} - -// vipsGenConvasep calls the vips convasep operation. -// approximate separable integer convolution -func vipsGenConvasep(input *C.VipsImage, mask *C.VipsImage, opts *ConvasepOptions) (*C.VipsImage, error) { - incOpCounter("convasep") - - var out_out *C.VipsImage - - var cOpts C.GenConvasepOpts - if opts != nil { - if opts.Layers != nil { - cOpts.has_layers = 1 - cOpts.layers = C.int(*opts.Layers) - } - } - - ret := C.gen_vips_convasep(input, mask, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenConvf calls the vips convf operation. -// float convolution operation -func vipsGenConvf(input *C.VipsImage, mask *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("convf") - - var out_out *C.VipsImage - - ret := C.gen_vips_convf(input, mask, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenConvi calls the vips convi operation. -// int convolution operation -func vipsGenConvi(input *C.VipsImage, mask *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("convi") - - var out_out *C.VipsImage - - ret := C.gen_vips_convi(input, mask, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// ConvsepOptions are optional parameters for convsep. -type ConvsepOptions struct { - Precision *Precision - Layers *int - Cluster *int -} - -// vipsGenConvsep calls the vips convsep operation. -// separable convolution operation -func vipsGenConvsep(input *C.VipsImage, mask *C.VipsImage, opts *ConvsepOptions) (*C.VipsImage, error) { - incOpCounter("convsep") - - var out_out *C.VipsImage - - var cOpts C.GenConvsepOpts - if opts != nil { - if opts.Precision != nil { - cOpts.has_precision = 1 - cOpts.precision = C.VipsPrecision(*opts.Precision) - } - if opts.Layers != nil { - cOpts.has_layers = 1 - cOpts.layers = C.int(*opts.Layers) - } - if opts.Cluster != nil { - cOpts.has_cluster = 1 - cOpts.cluster = C.int(*opts.Cluster) - } - } - - ret := C.gen_vips_convsep(input, mask, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// CopyOptions are optional parameters for copy. -type CopyOptions struct { - Width *int - Height *int - Bands *int - Format *BandFormat - Coding *Coding - Interpretation *Interpretation - Xres *float64 - Yres *float64 - Xoffset *int - Yoffset *int -} - -// vipsGenCopy calls the vips copy operation. -// copy an image -func vipsGenCopy(input *C.VipsImage, opts *CopyOptions) (*C.VipsImage, error) { - incOpCounter("copy") - - var out_out *C.VipsImage - - var cOpts C.GenCopyOpts - if opts != nil { - if opts.Width != nil { - cOpts.has_width = 1 - cOpts.width = C.int(*opts.Width) - } - if opts.Height != nil { - cOpts.has_height = 1 - cOpts.height = C.int(*opts.Height) - } - if opts.Bands != nil { - cOpts.has_bands = 1 - cOpts.bands = C.int(*opts.Bands) - } - if opts.Format != nil { - cOpts.has_format = 1 - cOpts.format = C.VipsBandFormat(*opts.Format) - } - if opts.Coding != nil { - cOpts.has_coding = 1 - cOpts.coding = C.VipsCoding(*opts.Coding) - } - if opts.Interpretation != nil { - cOpts.has_interpretation = 1 - cOpts.interpretation = C.VipsInterpretation(*opts.Interpretation) - } - if opts.Xres != nil { - cOpts.has_xres = 1 - cOpts.xres = C.double(*opts.Xres) - } - if opts.Yres != nil { - cOpts.has_yres = 1 - cOpts.yres = C.double(*opts.Yres) - } - if opts.Xoffset != nil { - cOpts.has_xoffset = 1 - cOpts.xoffset = C.int(*opts.Xoffset) - } - if opts.Yoffset != nil { - cOpts.has_yoffset = 1 - cOpts.yoffset = C.int(*opts.Yoffset) - } - } - - ret := C.gen_vips_copy(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenCountlines calls the vips countlines operation. -// count lines in an image -func vipsGenCountlines(input *C.VipsImage, direction Direction) (float64, error) { - incOpCounter("countlines") - - var out_nolines C.double - - ret := C.gen_vips_countlines(input, C.VipsDirection(direction), &out_nolines) - if ret != 0 { - return 0, handleVipsError() - } - - return float64(out_nolines), nil -} - -// vipsGenDE00 calls the vips dE00 operation. -// calculate dE00 -func vipsGenDE00(left *C.VipsImage, right *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("dE00") - - var out_out *C.VipsImage - - ret := C.gen_vips_dE00(left, right, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenDE76 calls the vips dE76 operation. -// calculate dE76 -func vipsGenDE76(left *C.VipsImage, right *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("dE76") - - var out_out *C.VipsImage - - ret := C.gen_vips_dE76(left, right, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenDECMC calls the vips dECMC operation. -// calculate dECMC -func vipsGenDECMC(left *C.VipsImage, right *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("dECMC") - - var out_out *C.VipsImage - - ret := C.gen_vips_dECMC(left, right, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenDeviate calls the vips deviate operation. -// find image standard deviation -func vipsGenDeviate(input *C.VipsImage) (float64, error) { - incOpCounter("deviate") - - var out_out C.double - - ret := C.gen_vips_deviate(input, &out_out) - if ret != 0 { - return 0, handleVipsError() - } - - return float64(out_out), nil -} - -// vipsGenDivide calls the vips divide operation. -// divide two images -func vipsGenDivide(left *C.VipsImage, right *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("divide") - - var out_out *C.VipsImage - - ret := C.gen_vips_divide(left, right, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenExtractArea calls the vips extract_area operation. -// extract an area from an image -func vipsGenExtractArea(input *C.VipsImage, left int, top int, width int, height int) (*C.VipsImage, error) { - incOpCounter("extract_area") - - var out_out *C.VipsImage - - ret := C.gen_vips_extract_area(input, C.int(left), C.int(top), C.int(width), C.int(height), &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// ExtractBandOptions are optional parameters for extract_band. -type ExtractBandOptions struct { - N *int -} - -// vipsGenExtractBand calls the vips extract_band operation. -// extract band from an image -func vipsGenExtractBand(input *C.VipsImage, band int, opts *ExtractBandOptions) (*C.VipsImage, error) { - incOpCounter("extract_band") - - var out_out *C.VipsImage - - var cOpts C.GenExtractBandOpts - if opts != nil { - if opts.N != nil { - cOpts.has_n = 1 - cOpts.n = C.int(*opts.N) - } - } - - ret := C.gen_vips_extract_band(input, C.int(band), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// EyeOptions are optional parameters for eye. -type EyeOptions struct { - Uchar *bool - Factor *float64 -} - -// vipsGenEye calls the vips eye operation. -// make an image showing the eye's spatial response -func vipsGenEye(width int, height int, opts *EyeOptions) (*C.VipsImage, error) { - incOpCounter("eye") - - var out_out *C.VipsImage - - var cOpts C.GenEyeOpts - if opts != nil { - if opts.Uchar != nil { - cOpts.has_uchar = 1 - cOpts.uchar = C.int(boolToInt(*opts.Uchar)) - } - if opts.Factor != nil { - cOpts.has_factor = 1 - cOpts.factor = C.double(*opts.Factor) - } - } - - ret := C.gen_vips_eye(C.int(width), C.int(height), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenFalsecolour calls the vips falsecolour operation. -// false-color an image -func vipsGenFalsecolour(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("falsecolour") - - var out_out *C.VipsImage - - ret := C.gen_vips_falsecolour(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenFastcor calls the vips fastcor operation. -// fast correlation -func vipsGenFastcor(input *C.VipsImage, ref *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("fastcor") - - var out_out *C.VipsImage - - ret := C.gen_vips_fastcor(input, ref, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenFillNearest calls the vips fill_nearest operation. -// fill image zeros with nearest non-zero pixel -func vipsGenFillNearest(input *C.VipsImage) (*C.VipsImage, *C.VipsImage, error) { - incOpCounter("fill_nearest") - - var out_out *C.VipsImage - var out_distance *C.VipsImage - - ret := C.gen_vips_fill_nearest(input, &out_out, &out_distance) - if ret != 0 { - return nil, nil, handleImageError(out_out) - } - - return out_out, out_distance, nil -} - -// FlattenOptions are optional parameters for flatten. -type FlattenOptions struct { - Background []float64 - MaxAlpha *float64 -} - -// vipsGenFlatten calls the vips flatten operation. -// flatten alpha out of an image -func vipsGenFlatten(input *C.VipsImage, opts *FlattenOptions) (*C.VipsImage, error) { - incOpCounter("flatten") - - var out_out *C.VipsImage - - var cOpts C.GenFlattenOpts - var pinner runtime.Pinner - defer pinner.Unpin() - if opts != nil { - if opts.Background != nil { - cOpts.has_background = 1 - pinner.Pin(&opts.Background[0]) - cOpts.background = (*C.double)(unsafe.Pointer(&opts.Background[0])) - cOpts.background_n = C.int(len(opts.Background)) - } - if opts.MaxAlpha != nil { - cOpts.has_maxAlpha = 1 - cOpts.maxAlpha = C.double(*opts.MaxAlpha) - } - } - - ret := C.gen_vips_flatten(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenFlip calls the vips flip operation. -// flip an image -func vipsGenFlip(input *C.VipsImage, direction Direction) (*C.VipsImage, error) { - incOpCounter("flip") - - var out_out *C.VipsImage - - ret := C.gen_vips_flip(input, C.VipsDirection(direction), &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenFloat2rad calls the vips float2rad operation. -// transform float RGB to Radiance coding -func vipsGenFloat2rad(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("float2rad") - - var out_out *C.VipsImage - - ret := C.gen_vips_float2rad(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenFractsurf calls the vips fractsurf operation. -// make a fractal surface -func vipsGenFractsurf(width int, height int, fractalDimension float64) (*C.VipsImage, error) { - incOpCounter("fractsurf") - - var out_out *C.VipsImage - - ret := C.gen_vips_fractsurf(C.int(width), C.int(height), C.double(fractalDimension), &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenFreqmult calls the vips freqmult operation. -// frequency-domain filtering -func vipsGenFreqmult(input *C.VipsImage, mask *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("freqmult") - - var out_out *C.VipsImage - - ret := C.gen_vips_freqmult(input, mask, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenFwfft calls the vips fwfft operation. -// forward FFT -func vipsGenFwfft(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("fwfft") - - var out_out *C.VipsImage - - ret := C.gen_vips_fwfft(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// GammaOptions are optional parameters for gamma. -type GammaOptions struct { - Exponent *float64 -} - -// vipsGenGamma calls the vips gamma operation. -// gamma an image -func vipsGenGamma(input *C.VipsImage, opts *GammaOptions) (*C.VipsImage, error) { - incOpCounter("gamma") - - var out_out *C.VipsImage - - var cOpts C.GenGammaOpts - if opts != nil { - if opts.Exponent != nil { - cOpts.has_exponent = 1 - cOpts.exponent = C.double(*opts.Exponent) - } - } - - ret := C.gen_vips_gamma(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// GaussblurOptions are optional parameters for gaussblur. -type GaussblurOptions struct { - MinAmpl *float64 - Precision *Precision -} - -// vipsGenGaussblur calls the vips gaussblur operation. -// gaussian blur -func vipsGenGaussblur(input *C.VipsImage, sigma float64, opts *GaussblurOptions) (*C.VipsImage, error) { - incOpCounter("gaussblur") - - var out_out *C.VipsImage - - var cOpts C.GenGaussblurOpts - if opts != nil { - if opts.MinAmpl != nil { - cOpts.has_minAmpl = 1 - cOpts.minAmpl = C.double(*opts.MinAmpl) - } - if opts.Precision != nil { - cOpts.has_precision = 1 - cOpts.precision = C.VipsPrecision(*opts.Precision) - } - } - - ret := C.gen_vips_gaussblur(input, C.double(sigma), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// GaussmatOptions are optional parameters for gaussmat. -type GaussmatOptions struct { - Separable *bool - Precision *Precision -} - -// vipsGenGaussmat calls the vips gaussmat operation. -// make a gaussian image -func vipsGenGaussmat(sigma float64, minAmpl float64, opts *GaussmatOptions) (*C.VipsImage, error) { - incOpCounter("gaussmat") - - var out_out *C.VipsImage - - var cOpts C.GenGaussmatOpts - if opts != nil { - if opts.Separable != nil { - cOpts.has_separable = 1 - cOpts.separable = C.int(boolToInt(*opts.Separable)) - } - if opts.Precision != nil { - cOpts.has_precision = 1 - cOpts.precision = C.VipsPrecision(*opts.Precision) - } - } - - ret := C.gen_vips_gaussmat(C.double(sigma), C.double(minAmpl), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// GaussnoiseOptions are optional parameters for gaussnoise. -type GaussnoiseOptions struct { - Sigma *float64 - Mean *float64 - Seed *int -} - -// vipsGenGaussnoise calls the vips gaussnoise operation. -// make a gaussnoise image -func vipsGenGaussnoise(width int, height int, opts *GaussnoiseOptions) (*C.VipsImage, error) { - incOpCounter("gaussnoise") - - var out_out *C.VipsImage - - var cOpts C.GenGaussnoiseOpts - if opts != nil { - if opts.Sigma != nil { - cOpts.has_sigma = 1 - cOpts.sigma = C.double(*opts.Sigma) - } - if opts.Mean != nil { - cOpts.has_mean = 1 - cOpts.mean = C.double(*opts.Mean) - } - if opts.Seed != nil { - cOpts.has_seed = 1 - cOpts.seed = C.int(*opts.Seed) - } - } - - ret := C.gen_vips_gaussnoise(C.int(width), C.int(height), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// GlobalbalanceOptions are optional parameters for globalbalance. -type GlobalbalanceOptions struct { - Gamma *float64 - IntOutput *bool -} - -// vipsGenGlobalbalance calls the vips globalbalance operation. -// global balance an image mosaic -func vipsGenGlobalbalance(input *C.VipsImage, opts *GlobalbalanceOptions) (*C.VipsImage, error) { - incOpCounter("globalbalance") - - var out_out *C.VipsImage - - var cOpts C.GenGlobalbalanceOpts - if opts != nil { - if opts.Gamma != nil { - cOpts.has_gamma = 1 - cOpts.gamma = C.double(*opts.Gamma) - } - if opts.IntOutput != nil { - cOpts.has_intOutput = 1 - cOpts.intOutput = C.int(boolToInt(*opts.IntOutput)) - } - } - - ret := C.gen_vips_globalbalance(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// GravityOptions are optional parameters for gravity. -type GravityOptions struct { - Extend *ExtendStrategy - Background []float64 -} - -// vipsGenGravity calls the vips gravity operation. -// place an image within a larger image with a certain gravity -func vipsGenGravity(input *C.VipsImage, direction Gravity, width int, height int, opts *GravityOptions) (*C.VipsImage, error) { - incOpCounter("gravity") - - var out_out *C.VipsImage - - var cOpts C.GenGravityOpts - var pinner runtime.Pinner - defer pinner.Unpin() - if opts != nil { - if opts.Extend != nil { - cOpts.has_extend = 1 - cOpts.extend = C.VipsExtend(*opts.Extend) - } - if opts.Background != nil { - cOpts.has_background = 1 - pinner.Pin(&opts.Background[0]) - cOpts.background = (*C.double)(unsafe.Pointer(&opts.Background[0])) - cOpts.background_n = C.int(len(opts.Background)) - } - } - - ret := C.gen_vips_gravity(input, C.VipsCompassDirection(direction), C.int(width), C.int(height), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// GreyOptions are optional parameters for grey. -type GreyOptions struct { - Uchar *bool -} - -// vipsGenGrey calls the vips grey operation. -// make a grey ramp image -func vipsGenGrey(width int, height int, opts *GreyOptions) (*C.VipsImage, error) { - incOpCounter("grey") - - var out_out *C.VipsImage - - var cOpts C.GenGreyOpts - if opts != nil { - if opts.Uchar != nil { - cOpts.has_uchar = 1 - cOpts.uchar = C.int(boolToInt(*opts.Uchar)) - } - } - - ret := C.gen_vips_grey(C.int(width), C.int(height), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenGrid calls the vips grid operation. -// grid an image -func vipsGenGrid(input *C.VipsImage, tileHeight int, across int, down int) (*C.VipsImage, error) { - incOpCounter("grid") - - var out_out *C.VipsImage - - ret := C.gen_vips_grid(input, C.int(tileHeight), C.int(across), C.int(down), &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenHistCum calls the vips hist_cum operation. -// form cumulative histogram -func vipsGenHistCum(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("hist_cum") - - var out_out *C.VipsImage - - ret := C.gen_vips_hist_cum(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenHistEntropy calls the vips hist_entropy operation. -// estimate image entropy -func vipsGenHistEntropy(input *C.VipsImage) (float64, error) { - incOpCounter("hist_entropy") - - var out_out C.double - - ret := C.gen_vips_hist_entropy(input, &out_out) - if ret != 0 { - return 0, handleVipsError() - } - - return float64(out_out), nil -} - -// HistEqualOptions are optional parameters for hist_equal. -type HistEqualOptions struct { - Band *int -} - -// vipsGenHistEqual calls the vips hist_equal operation. -// histogram equalisation -func vipsGenHistEqual(input *C.VipsImage, opts *HistEqualOptions) (*C.VipsImage, error) { - incOpCounter("hist_equal") - - var out_out *C.VipsImage - - var cOpts C.GenHistEqualOpts - if opts != nil { - if opts.Band != nil { - cOpts.has_band = 1 - cOpts.band = C.int(*opts.Band) - } - } - - ret := C.gen_vips_hist_equal(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// HistFindOptions are optional parameters for hist_find. -type HistFindOptions struct { - Band *int -} - -// vipsGenHistFind calls the vips hist_find operation. -// find image histogram -func vipsGenHistFind(input *C.VipsImage, opts *HistFindOptions) (*C.VipsImage, error) { - incOpCounter("hist_find") - - var out_out *C.VipsImage - - var cOpts C.GenHistFindOpts - if opts != nil { - if opts.Band != nil { - cOpts.has_band = 1 - cOpts.band = C.int(*opts.Band) - } - } - - ret := C.gen_vips_hist_find(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// HistFindIndexedOptions are optional parameters for hist_find_indexed. -type HistFindIndexedOptions struct { - Combine *Combine -} - -// vipsGenHistFindIndexed calls the vips hist_find_indexed operation. -// find indexed image histogram -func vipsGenHistFindIndexed(input *C.VipsImage, index *C.VipsImage, opts *HistFindIndexedOptions) (*C.VipsImage, error) { - incOpCounter("hist_find_indexed") - - var out_out *C.VipsImage - - var cOpts C.GenHistFindIndexedOpts - if opts != nil { - if opts.Combine != nil { - cOpts.has_combine = 1 - cOpts.combine = C.VipsCombine(*opts.Combine) - } - } - - ret := C.gen_vips_hist_find_indexed(input, index, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// HistFindNdimOptions are optional parameters for hist_find_ndim. -type HistFindNdimOptions struct { - Bins *int -} - -// vipsGenHistFindNdim calls the vips hist_find_ndim operation. -// find n-dimensional image histogram -func vipsGenHistFindNdim(input *C.VipsImage, opts *HistFindNdimOptions) (*C.VipsImage, error) { - incOpCounter("hist_find_ndim") - - var out_out *C.VipsImage - - var cOpts C.GenHistFindNdimOpts - if opts != nil { - if opts.Bins != nil { - cOpts.has_bins = 1 - cOpts.bins = C.int(*opts.Bins) - } - } - - ret := C.gen_vips_hist_find_ndim(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenHistIsmonotonic calls the vips hist_ismonotonic operation. -// test for monotonicity -func vipsGenHistIsmonotonic(input *C.VipsImage) (bool, error) { - incOpCounter("hist_ismonotonic") - - var out_monotonic C.int - - ret := C.gen_vips_hist_ismonotonic(input, &out_monotonic) - if ret != 0 { - return false, handleVipsError() - } - - return out_monotonic != 0, nil -} - -// HistLocalOptions are optional parameters for hist_local. -type HistLocalOptions struct { - MaxSlope *int -} - -// vipsGenHistLocal calls the vips hist_local operation. -// local histogram equalisation -func vipsGenHistLocal(input *C.VipsImage, width int, height int, opts *HistLocalOptions) (*C.VipsImage, error) { - incOpCounter("hist_local") - - var out_out *C.VipsImage - - var cOpts C.GenHistLocalOpts - if opts != nil { - if opts.MaxSlope != nil { - cOpts.has_maxSlope = 1 - cOpts.maxSlope = C.int(*opts.MaxSlope) - } - } - - ret := C.gen_vips_hist_local(input, C.int(width), C.int(height), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenHistMatch calls the vips hist_match operation. -// match two histograms -func vipsGenHistMatch(input *C.VipsImage, ref *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("hist_match") - - var out_out *C.VipsImage - - ret := C.gen_vips_hist_match(input, ref, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenHistNorm calls the vips hist_norm operation. -// normalise histogram -func vipsGenHistNorm(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("hist_norm") - - var out_out *C.VipsImage - - ret := C.gen_vips_hist_norm(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenHistPlot calls the vips hist_plot operation. -// plot histogram -func vipsGenHistPlot(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("hist_plot") - - var out_out *C.VipsImage - - ret := C.gen_vips_hist_plot(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// HoughCircleOptions are optional parameters for hough_circle. -type HoughCircleOptions struct { - Scale *int - MinRadius *int - MaxRadius *int -} - -// vipsGenHoughCircle calls the vips hough_circle operation. -// find hough circle transform -func vipsGenHoughCircle(input *C.VipsImage, opts *HoughCircleOptions) (*C.VipsImage, error) { - incOpCounter("hough_circle") - - var out_out *C.VipsImage - - var cOpts C.GenHoughCircleOpts - if opts != nil { - if opts.Scale != nil { - cOpts.has_scale = 1 - cOpts.scale = C.int(*opts.Scale) - } - if opts.MinRadius != nil { - cOpts.has_minRadius = 1 - cOpts.minRadius = C.int(*opts.MinRadius) - } - if opts.MaxRadius != nil { - cOpts.has_maxRadius = 1 - cOpts.maxRadius = C.int(*opts.MaxRadius) - } - } - - ret := C.gen_vips_hough_circle(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// HoughLineOptions are optional parameters for hough_line. -type HoughLineOptions struct { - Width *int - Height *int -} - -// vipsGenHoughLine calls the vips hough_line operation. -// find hough line transform -func vipsGenHoughLine(input *C.VipsImage, opts *HoughLineOptions) (*C.VipsImage, error) { - incOpCounter("hough_line") - - var out_out *C.VipsImage - - var cOpts C.GenHoughLineOpts - if opts != nil { - if opts.Width != nil { - cOpts.has_width = 1 - cOpts.width = C.int(*opts.Width) - } - if opts.Height != nil { - cOpts.has_height = 1 - cOpts.height = C.int(*opts.Height) - } - } - - ret := C.gen_vips_hough_line(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// IccExportOptions are optional parameters for icc_export. -type IccExportOptions struct { - Pcs *int - Intent *Intent - BlackPointCompensation *bool - OutputProfile *string - Depth *int -} - -// vipsGenIccExport calls the vips icc_export operation. -// output to device with ICC profile -func vipsGenIccExport(input *C.VipsImage, opts *IccExportOptions) (*C.VipsImage, error) { - incOpCounter("icc_export") - - var out_out *C.VipsImage - - var cOpts C.GenIccExportOpts - if opts != nil { - if opts.Pcs != nil { - cOpts.has_pcs = 1 - cOpts.pcs = C.VipsPCS(*opts.Pcs) - } - if opts.Intent != nil { - cOpts.has_intent = 1 - cOpts.intent = C.VipsIntent(*opts.Intent) - } - if opts.BlackPointCompensation != nil { - cOpts.has_blackPointCompensation = 1 - cOpts.blackPointCompensation = C.int(boolToInt(*opts.BlackPointCompensation)) - } - if opts.OutputProfile != nil { - cOpts.has_outputProfile = 1 - tmp_outputProfile := C.CString(*opts.OutputProfile) - defer C.free(unsafe.Pointer(tmp_outputProfile)) - cOpts.outputProfile = tmp_outputProfile - } - if opts.Depth != nil { - cOpts.has_depth = 1 - cOpts.depth = C.int(*opts.Depth) - } - } - - ret := C.gen_vips_icc_export(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// IccImportOptions are optional parameters for icc_import. -type IccImportOptions struct { - Pcs *int - Intent *Intent - BlackPointCompensation *bool - Embedded *bool - InputProfile *string -} - -// vipsGenIccImport calls the vips icc_import operation. -// import from device with ICC profile -func vipsGenIccImport(input *C.VipsImage, opts *IccImportOptions) (*C.VipsImage, error) { - incOpCounter("icc_import") - - var out_out *C.VipsImage - - var cOpts C.GenIccImportOpts - if opts != nil { - if opts.Pcs != nil { - cOpts.has_pcs = 1 - cOpts.pcs = C.VipsPCS(*opts.Pcs) - } - if opts.Intent != nil { - cOpts.has_intent = 1 - cOpts.intent = C.VipsIntent(*opts.Intent) - } - if opts.BlackPointCompensation != nil { - cOpts.has_blackPointCompensation = 1 - cOpts.blackPointCompensation = C.int(boolToInt(*opts.BlackPointCompensation)) - } - if opts.Embedded != nil { - cOpts.has_embedded = 1 - cOpts.embedded = C.int(boolToInt(*opts.Embedded)) - } - if opts.InputProfile != nil { - cOpts.has_inputProfile = 1 - tmp_inputProfile := C.CString(*opts.InputProfile) - defer C.free(unsafe.Pointer(tmp_inputProfile)) - cOpts.inputProfile = tmp_inputProfile - } - } - - ret := C.gen_vips_icc_import(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// IdentityOptions are optional parameters for identity. -type IdentityOptions struct { - Bands *int - Ushort *bool - Size *int -} - -// vipsGenIdentity calls the vips identity operation. -// make a 1D image where pixel values are indexes -func vipsGenIdentity(opts *IdentityOptions) (*C.VipsImage, error) { - incOpCounter("identity") - - var out_out *C.VipsImage - - var cOpts C.GenIdentityOpts - if opts != nil { - if opts.Bands != nil { - cOpts.has_bands = 1 - cOpts.bands = C.int(*opts.Bands) - } - if opts.Ushort != nil { - cOpts.has_ushort = 1 - cOpts.ushort = C.int(boolToInt(*opts.Ushort)) - } - if opts.Size != nil { - cOpts.has_size = 1 - cOpts.size = C.int(*opts.Size) - } - } - - ret := C.gen_vips_identity(&out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// IfthenelseOptions are optional parameters for ifthenelse. -type IfthenelseOptions struct { - Blend *bool -} - -// vipsGenIfthenelse calls the vips ifthenelse operation. -// ifthenelse an image -func vipsGenIfthenelse(cond *C.VipsImage, in1 *C.VipsImage, in2 *C.VipsImage, opts *IfthenelseOptions) (*C.VipsImage, error) { - incOpCounter("ifthenelse") - - var out_out *C.VipsImage - - var cOpts C.GenIfthenelseOpts - if opts != nil { - if opts.Blend != nil { - cOpts.has_blend = 1 - cOpts.blend = C.int(boolToInt(*opts.Blend)) - } - } - - ret := C.gen_vips_ifthenelse(cond, in1, in2, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// InsertOptions are optional parameters for insert. -type InsertOptions struct { - Expand *bool - Background []float64 -} - -// vipsGenInsert calls the vips insert operation. -// insert image @sub into @main at @x, @y -func vipsGenInsert(main *C.VipsImage, sub *C.VipsImage, x int, y int, opts *InsertOptions) (*C.VipsImage, error) { - incOpCounter("insert") - - var out_out *C.VipsImage - - var cOpts C.GenInsertOpts - var pinner runtime.Pinner - defer pinner.Unpin() - if opts != nil { - if opts.Expand != nil { - cOpts.has_expand = 1 - cOpts.expand = C.int(boolToInt(*opts.Expand)) - } - if opts.Background != nil { - cOpts.has_background = 1 - pinner.Pin(&opts.Background[0]) - cOpts.background = (*C.double)(unsafe.Pointer(&opts.Background[0])) - cOpts.background_n = C.int(len(opts.Background)) - } - } - - ret := C.gen_vips_insert(main, sub, C.int(x), C.int(y), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenInvert calls the vips invert operation. -// invert an image -func vipsGenInvert(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("invert") - - var out_out *C.VipsImage - - ret := C.gen_vips_invert(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// InvertlutOptions are optional parameters for invertlut. -type InvertlutOptions struct { - Size *int -} - -// vipsGenInvertlut calls the vips invertlut operation. -// build an inverted look-up table -func vipsGenInvertlut(input *C.VipsImage, opts *InvertlutOptions) (*C.VipsImage, error) { - incOpCounter("invertlut") - - var out_out *C.VipsImage - - var cOpts C.GenInvertlutOpts - if opts != nil { - if opts.Size != nil { - cOpts.has_size = 1 - cOpts.size = C.int(*opts.Size) - } - } - - ret := C.gen_vips_invertlut(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// InvfftOptions are optional parameters for invfft. -type InvfftOptions struct { - Real *bool -} - -// vipsGenInvfft calls the vips invfft operation. -// inverse FFT -func vipsGenInvfft(input *C.VipsImage, opts *InvfftOptions) (*C.VipsImage, error) { - incOpCounter("invfft") - - var out_out *C.VipsImage - - var cOpts C.GenInvfftOpts - if opts != nil { - if opts.Real != nil { - cOpts.has_real = 1 - cOpts.real = C.int(boolToInt(*opts.Real)) - } - } - - ret := C.gen_vips_invfft(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// JoinOptions are optional parameters for join. -type JoinOptions struct { - Expand *bool - Shim *int - Background []float64 - Align *Align -} - -// vipsGenJoin calls the vips join operation. -// join a pair of images -func vipsGenJoin(in1 *C.VipsImage, in2 *C.VipsImage, direction Direction, opts *JoinOptions) (*C.VipsImage, error) { - incOpCounter("join") - - var out_out *C.VipsImage - - var cOpts C.GenJoinOpts - var pinner runtime.Pinner - defer pinner.Unpin() - if opts != nil { - if opts.Expand != nil { - cOpts.has_expand = 1 - cOpts.expand = C.int(boolToInt(*opts.Expand)) - } - if opts.Shim != nil { - cOpts.has_shim = 1 - cOpts.shim = C.int(*opts.Shim) - } - if opts.Background != nil { - cOpts.has_background = 1 - pinner.Pin(&opts.Background[0]) - cOpts.background = (*C.double)(unsafe.Pointer(&opts.Background[0])) - cOpts.background_n = C.int(len(opts.Background)) - } - if opts.Align != nil { - cOpts.has_align = 1 - cOpts.align = C.VipsAlign(*opts.Align) - } - } - - ret := C.gen_vips_join(in1, in2, C.VipsDirection(direction), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenLabelregions calls the vips labelregions operation. -// label regions in an image -func vipsGenLabelregions(input *C.VipsImage) (*C.VipsImage, int, error) { - incOpCounter("labelregions") - - var out_mask *C.VipsImage - var out_segments C.int - - ret := C.gen_vips_labelregions(input, &out_mask, &out_segments) - if ret != 0 { - return nil, 0, handleImageError(out_mask) - } - - return out_mask, int(out_segments), nil -} - -// LinearOptions are optional parameters for linear. -type LinearOptions struct { - Uchar *bool -} - -// vipsGenLinear calls the vips linear operation. -// calculate (a * in + b) -func vipsGenLinear(input *C.VipsImage, a []float64, b []float64, opts *LinearOptions) (*C.VipsImage, error) { - incOpCounter("linear") - - var out_out *C.VipsImage - - var cOpts C.GenLinearOpts - if opts != nil { - if opts.Uchar != nil { - cOpts.has_uchar = 1 - cOpts.uchar = C.int(boolToInt(*opts.Uchar)) - } - } - - ret := C.gen_vips_linear(input, (*C.double)(unsafe.Pointer(&a[0])), C.int(len(a)), (*C.double)(unsafe.Pointer(&b[0])), C.int(len(b)), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// LinecacheOptions are optional parameters for linecache. -type LinecacheOptions struct { - TileHeight *int - Access *int - Threaded *bool - Persistent *bool -} - -// vipsGenLinecache calls the vips linecache operation. -// cache an image as a set of lines -func vipsGenLinecache(input *C.VipsImage, opts *LinecacheOptions) (*C.VipsImage, error) { - incOpCounter("linecache") - - var out_out *C.VipsImage - - var cOpts C.GenLinecacheOpts - if opts != nil { - if opts.TileHeight != nil { - cOpts.has_tileHeight = 1 - cOpts.tileHeight = C.int(*opts.TileHeight) - } - if opts.Access != nil { - cOpts.has_access = 1 - cOpts.access = C.VipsAccess(*opts.Access) - } - if opts.Threaded != nil { - cOpts.has_threaded = 1 - cOpts.threaded = C.int(boolToInt(*opts.Threaded)) - } - if opts.Persistent != nil { - cOpts.has_persistent = 1 - cOpts.persistent = C.int(boolToInt(*opts.Persistent)) - } - } - - ret := C.gen_vips_linecache(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// LogmatOptions are optional parameters for logmat. -type LogmatOptions struct { - Separable *bool - Precision *Precision -} - -// vipsGenLogmat calls the vips logmat operation. -// make a Laplacian of Gaussian image -func vipsGenLogmat(sigma float64, minAmpl float64, opts *LogmatOptions) (*C.VipsImage, error) { - incOpCounter("logmat") - - var out_out *C.VipsImage - - var cOpts C.GenLogmatOpts - if opts != nil { - if opts.Separable != nil { - cOpts.has_separable = 1 - cOpts.separable = C.int(boolToInt(*opts.Separable)) - } - if opts.Precision != nil { - cOpts.has_precision = 1 - cOpts.precision = C.VipsPrecision(*opts.Precision) - } - } - - ret := C.gen_vips_logmat(C.double(sigma), C.double(minAmpl), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// MapimOptions are optional parameters for mapim. -type MapimOptions struct { - Interpolate *C.VipsInterpolate - Background []float64 - Premultiplied *bool - Extend *ExtendStrategy -} - -// vipsGenMapim calls the vips mapim operation. -// resample with a map image -func vipsGenMapim(input *C.VipsImage, index *C.VipsImage, opts *MapimOptions) (*C.VipsImage, error) { - incOpCounter("mapim") - - var out_out *C.VipsImage - - var cOpts C.GenMapimOpts - var pinner runtime.Pinner - defer pinner.Unpin() - if opts != nil { - if opts.Interpolate != nil { - cOpts.has_interpolate = 1 - cOpts.interpolate = opts.Interpolate - } - if opts.Background != nil { - cOpts.has_background = 1 - pinner.Pin(&opts.Background[0]) - cOpts.background = (*C.double)(unsafe.Pointer(&opts.Background[0])) - cOpts.background_n = C.int(len(opts.Background)) - } - if opts.Premultiplied != nil { - cOpts.has_premultiplied = 1 - cOpts.premultiplied = C.int(boolToInt(*opts.Premultiplied)) - } - if opts.Extend != nil { - cOpts.has_extend = 1 - cOpts.extend = C.VipsExtend(*opts.Extend) - } - } - - ret := C.gen_vips_mapim(input, index, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// MaplutOptions are optional parameters for maplut. -type MaplutOptions struct { - Band *int -} - -// vipsGenMaplut calls the vips maplut operation. -// map an image though a lut -func vipsGenMaplut(input *C.VipsImage, lut *C.VipsImage, opts *MaplutOptions) (*C.VipsImage, error) { - incOpCounter("maplut") - - var out_out *C.VipsImage - - var cOpts C.GenMaplutOpts - if opts != nil { - if opts.Band != nil { - cOpts.has_band = 1 - cOpts.band = C.int(*opts.Band) - } - } - - ret := C.gen_vips_maplut(input, lut, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// MaskButterworthOptions are optional parameters for mask_butterworth. -type MaskButterworthOptions struct { - Uchar *bool - Nodc *bool - Reject *bool - Optical *bool -} - -// vipsGenMaskButterworth calls the vips mask_butterworth operation. -// make a butterworth filter -func vipsGenMaskButterworth(width int, height int, order float64, frequencyCutoff float64, amplitudeCutoff float64, opts *MaskButterworthOptions) (*C.VipsImage, error) { - incOpCounter("mask_butterworth") - - var out_out *C.VipsImage - - var cOpts C.GenMaskButterworthOpts - if opts != nil { - if opts.Uchar != nil { - cOpts.has_uchar = 1 - cOpts.uchar = C.int(boolToInt(*opts.Uchar)) - } - if opts.Nodc != nil { - cOpts.has_nodc = 1 - cOpts.nodc = C.int(boolToInt(*opts.Nodc)) - } - if opts.Reject != nil { - cOpts.has_reject = 1 - cOpts.reject = C.int(boolToInt(*opts.Reject)) - } - if opts.Optical != nil { - cOpts.has_optical = 1 - cOpts.optical = C.int(boolToInt(*opts.Optical)) - } - } - - ret := C.gen_vips_mask_butterworth(C.int(width), C.int(height), C.double(order), C.double(frequencyCutoff), C.double(amplitudeCutoff), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// MaskButterworthBandOptions are optional parameters for mask_butterworth_band. -type MaskButterworthBandOptions struct { - Uchar *bool - Nodc *bool - Reject *bool - Optical *bool -} - -// vipsGenMaskButterworthBand calls the vips mask_butterworth_band operation. -// make a butterworth_band filter -func vipsGenMaskButterworthBand(width int, height int, order float64, frequencyCutoffX float64, frequencyCutoffY float64, radius float64, amplitudeCutoff float64, opts *MaskButterworthBandOptions) (*C.VipsImage, error) { - incOpCounter("mask_butterworth_band") - - var out_out *C.VipsImage - - var cOpts C.GenMaskButterworthBandOpts - if opts != nil { - if opts.Uchar != nil { - cOpts.has_uchar = 1 - cOpts.uchar = C.int(boolToInt(*opts.Uchar)) - } - if opts.Nodc != nil { - cOpts.has_nodc = 1 - cOpts.nodc = C.int(boolToInt(*opts.Nodc)) - } - if opts.Reject != nil { - cOpts.has_reject = 1 - cOpts.reject = C.int(boolToInt(*opts.Reject)) - } - if opts.Optical != nil { - cOpts.has_optical = 1 - cOpts.optical = C.int(boolToInt(*opts.Optical)) - } - } - - ret := C.gen_vips_mask_butterworth_band(C.int(width), C.int(height), C.double(order), C.double(frequencyCutoffX), C.double(frequencyCutoffY), C.double(radius), C.double(amplitudeCutoff), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// MaskButterworthRingOptions are optional parameters for mask_butterworth_ring. -type MaskButterworthRingOptions struct { - Uchar *bool - Nodc *bool - Reject *bool - Optical *bool -} - -// vipsGenMaskButterworthRing calls the vips mask_butterworth_ring operation. -// make a butterworth ring filter -func vipsGenMaskButterworthRing(width int, height int, order float64, frequencyCutoff float64, amplitudeCutoff float64, ringwidth float64, opts *MaskButterworthRingOptions) (*C.VipsImage, error) { - incOpCounter("mask_butterworth_ring") - - var out_out *C.VipsImage - - var cOpts C.GenMaskButterworthRingOpts - if opts != nil { - if opts.Uchar != nil { - cOpts.has_uchar = 1 - cOpts.uchar = C.int(boolToInt(*opts.Uchar)) - } - if opts.Nodc != nil { - cOpts.has_nodc = 1 - cOpts.nodc = C.int(boolToInt(*opts.Nodc)) - } - if opts.Reject != nil { - cOpts.has_reject = 1 - cOpts.reject = C.int(boolToInt(*opts.Reject)) - } - if opts.Optical != nil { - cOpts.has_optical = 1 - cOpts.optical = C.int(boolToInt(*opts.Optical)) - } - } - - ret := C.gen_vips_mask_butterworth_ring(C.int(width), C.int(height), C.double(order), C.double(frequencyCutoff), C.double(amplitudeCutoff), C.double(ringwidth), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// MaskFractalOptions are optional parameters for mask_fractal. -type MaskFractalOptions struct { - Uchar *bool - Nodc *bool - Reject *bool - Optical *bool -} - -// vipsGenMaskFractal calls the vips mask_fractal operation. -// make fractal filter -func vipsGenMaskFractal(width int, height int, fractalDimension float64, opts *MaskFractalOptions) (*C.VipsImage, error) { - incOpCounter("mask_fractal") - - var out_out *C.VipsImage - - var cOpts C.GenMaskFractalOpts - if opts != nil { - if opts.Uchar != nil { - cOpts.has_uchar = 1 - cOpts.uchar = C.int(boolToInt(*opts.Uchar)) - } - if opts.Nodc != nil { - cOpts.has_nodc = 1 - cOpts.nodc = C.int(boolToInt(*opts.Nodc)) - } - if opts.Reject != nil { - cOpts.has_reject = 1 - cOpts.reject = C.int(boolToInt(*opts.Reject)) - } - if opts.Optical != nil { - cOpts.has_optical = 1 - cOpts.optical = C.int(boolToInt(*opts.Optical)) - } - } - - ret := C.gen_vips_mask_fractal(C.int(width), C.int(height), C.double(fractalDimension), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// MaskGaussianOptions are optional parameters for mask_gaussian. -type MaskGaussianOptions struct { - Uchar *bool - Nodc *bool - Reject *bool - Optical *bool -} - -// vipsGenMaskGaussian calls the vips mask_gaussian operation. -// make a gaussian filter -func vipsGenMaskGaussian(width int, height int, frequencyCutoff float64, amplitudeCutoff float64, opts *MaskGaussianOptions) (*C.VipsImage, error) { - incOpCounter("mask_gaussian") - - var out_out *C.VipsImage - - var cOpts C.GenMaskGaussianOpts - if opts != nil { - if opts.Uchar != nil { - cOpts.has_uchar = 1 - cOpts.uchar = C.int(boolToInt(*opts.Uchar)) - } - if opts.Nodc != nil { - cOpts.has_nodc = 1 - cOpts.nodc = C.int(boolToInt(*opts.Nodc)) - } - if opts.Reject != nil { - cOpts.has_reject = 1 - cOpts.reject = C.int(boolToInt(*opts.Reject)) - } - if opts.Optical != nil { - cOpts.has_optical = 1 - cOpts.optical = C.int(boolToInt(*opts.Optical)) - } - } - - ret := C.gen_vips_mask_gaussian(C.int(width), C.int(height), C.double(frequencyCutoff), C.double(amplitudeCutoff), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// MaskGaussianBandOptions are optional parameters for mask_gaussian_band. -type MaskGaussianBandOptions struct { - Uchar *bool - Nodc *bool - Reject *bool - Optical *bool -} - -// vipsGenMaskGaussianBand calls the vips mask_gaussian_band operation. -// make a gaussian filter -func vipsGenMaskGaussianBand(width int, height int, frequencyCutoffX float64, frequencyCutoffY float64, radius float64, amplitudeCutoff float64, opts *MaskGaussianBandOptions) (*C.VipsImage, error) { - incOpCounter("mask_gaussian_band") - - var out_out *C.VipsImage - - var cOpts C.GenMaskGaussianBandOpts - if opts != nil { - if opts.Uchar != nil { - cOpts.has_uchar = 1 - cOpts.uchar = C.int(boolToInt(*opts.Uchar)) - } - if opts.Nodc != nil { - cOpts.has_nodc = 1 - cOpts.nodc = C.int(boolToInt(*opts.Nodc)) - } - if opts.Reject != nil { - cOpts.has_reject = 1 - cOpts.reject = C.int(boolToInt(*opts.Reject)) - } - if opts.Optical != nil { - cOpts.has_optical = 1 - cOpts.optical = C.int(boolToInt(*opts.Optical)) - } - } - - ret := C.gen_vips_mask_gaussian_band(C.int(width), C.int(height), C.double(frequencyCutoffX), C.double(frequencyCutoffY), C.double(radius), C.double(amplitudeCutoff), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// MaskGaussianRingOptions are optional parameters for mask_gaussian_ring. -type MaskGaussianRingOptions struct { - Uchar *bool - Nodc *bool - Reject *bool - Optical *bool -} - -// vipsGenMaskGaussianRing calls the vips mask_gaussian_ring operation. -// make a gaussian ring filter -func vipsGenMaskGaussianRing(width int, height int, frequencyCutoff float64, amplitudeCutoff float64, ringwidth float64, opts *MaskGaussianRingOptions) (*C.VipsImage, error) { - incOpCounter("mask_gaussian_ring") - - var out_out *C.VipsImage - - var cOpts C.GenMaskGaussianRingOpts - if opts != nil { - if opts.Uchar != nil { - cOpts.has_uchar = 1 - cOpts.uchar = C.int(boolToInt(*opts.Uchar)) - } - if opts.Nodc != nil { - cOpts.has_nodc = 1 - cOpts.nodc = C.int(boolToInt(*opts.Nodc)) - } - if opts.Reject != nil { - cOpts.has_reject = 1 - cOpts.reject = C.int(boolToInt(*opts.Reject)) - } - if opts.Optical != nil { - cOpts.has_optical = 1 - cOpts.optical = C.int(boolToInt(*opts.Optical)) - } - } - - ret := C.gen_vips_mask_gaussian_ring(C.int(width), C.int(height), C.double(frequencyCutoff), C.double(amplitudeCutoff), C.double(ringwidth), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// MaskIdealOptions are optional parameters for mask_ideal. -type MaskIdealOptions struct { - Uchar *bool - Nodc *bool - Reject *bool - Optical *bool -} - -// vipsGenMaskIdeal calls the vips mask_ideal operation. -// make an ideal filter -func vipsGenMaskIdeal(width int, height int, frequencyCutoff float64, opts *MaskIdealOptions) (*C.VipsImage, error) { - incOpCounter("mask_ideal") - - var out_out *C.VipsImage - - var cOpts C.GenMaskIdealOpts - if opts != nil { - if opts.Uchar != nil { - cOpts.has_uchar = 1 - cOpts.uchar = C.int(boolToInt(*opts.Uchar)) - } - if opts.Nodc != nil { - cOpts.has_nodc = 1 - cOpts.nodc = C.int(boolToInt(*opts.Nodc)) - } - if opts.Reject != nil { - cOpts.has_reject = 1 - cOpts.reject = C.int(boolToInt(*opts.Reject)) - } - if opts.Optical != nil { - cOpts.has_optical = 1 - cOpts.optical = C.int(boolToInt(*opts.Optical)) - } - } - - ret := C.gen_vips_mask_ideal(C.int(width), C.int(height), C.double(frequencyCutoff), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// MaskIdealBandOptions are optional parameters for mask_ideal_band. -type MaskIdealBandOptions struct { - Uchar *bool - Nodc *bool - Reject *bool - Optical *bool -} - -// vipsGenMaskIdealBand calls the vips mask_ideal_band operation. -// make an ideal band filter -func vipsGenMaskIdealBand(width int, height int, frequencyCutoffX float64, frequencyCutoffY float64, radius float64, opts *MaskIdealBandOptions) (*C.VipsImage, error) { - incOpCounter("mask_ideal_band") - - var out_out *C.VipsImage - - var cOpts C.GenMaskIdealBandOpts - if opts != nil { - if opts.Uchar != nil { - cOpts.has_uchar = 1 - cOpts.uchar = C.int(boolToInt(*opts.Uchar)) - } - if opts.Nodc != nil { - cOpts.has_nodc = 1 - cOpts.nodc = C.int(boolToInt(*opts.Nodc)) - } - if opts.Reject != nil { - cOpts.has_reject = 1 - cOpts.reject = C.int(boolToInt(*opts.Reject)) - } - if opts.Optical != nil { - cOpts.has_optical = 1 - cOpts.optical = C.int(boolToInt(*opts.Optical)) - } - } - - ret := C.gen_vips_mask_ideal_band(C.int(width), C.int(height), C.double(frequencyCutoffX), C.double(frequencyCutoffY), C.double(radius), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// MaskIdealRingOptions are optional parameters for mask_ideal_ring. -type MaskIdealRingOptions struct { - Uchar *bool - Nodc *bool - Reject *bool - Optical *bool -} - -// vipsGenMaskIdealRing calls the vips mask_ideal_ring operation. -// make an ideal ring filter -func vipsGenMaskIdealRing(width int, height int, frequencyCutoff float64, ringwidth float64, opts *MaskIdealRingOptions) (*C.VipsImage, error) { - incOpCounter("mask_ideal_ring") - - var out_out *C.VipsImage - - var cOpts C.GenMaskIdealRingOpts - if opts != nil { - if opts.Uchar != nil { - cOpts.has_uchar = 1 - cOpts.uchar = C.int(boolToInt(*opts.Uchar)) - } - if opts.Nodc != nil { - cOpts.has_nodc = 1 - cOpts.nodc = C.int(boolToInt(*opts.Nodc)) - } - if opts.Reject != nil { - cOpts.has_reject = 1 - cOpts.reject = C.int(boolToInt(*opts.Reject)) - } - if opts.Optical != nil { - cOpts.has_optical = 1 - cOpts.optical = C.int(boolToInt(*opts.Optical)) - } - } - - ret := C.gen_vips_mask_ideal_ring(C.int(width), C.int(height), C.double(frequencyCutoff), C.double(ringwidth), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// MatchOptions are optional parameters for match. -type MatchOptions struct { - Hwindow *int - Harea *int - Search *bool - Interpolate *C.VipsInterpolate -} - -// vipsGenMatch calls the vips match operation. -// first-order match of two images -func vipsGenMatch(ref *C.VipsImage, sec *C.VipsImage, xr1 int, yr1 int, xs1 int, ys1 int, xr2 int, yr2 int, xs2 int, ys2 int, opts *MatchOptions) (*C.VipsImage, error) { - incOpCounter("match") - - var out_out *C.VipsImage - - var cOpts C.GenMatchOpts - if opts != nil { - if opts.Hwindow != nil { - cOpts.has_hwindow = 1 - cOpts.hwindow = C.int(*opts.Hwindow) - } - if opts.Harea != nil { - cOpts.has_harea = 1 - cOpts.harea = C.int(*opts.Harea) - } - if opts.Search != nil { - cOpts.has_search = 1 - cOpts.search = C.int(boolToInt(*opts.Search)) - } - if opts.Interpolate != nil { - cOpts.has_interpolate = 1 - cOpts.interpolate = opts.Interpolate - } - } - - ret := C.gen_vips_match(ref, sec, C.int(xr1), C.int(yr1), C.int(xs1), C.int(ys1), C.int(xr2), C.int(yr2), C.int(xs2), C.int(ys2), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenMath calls the vips math operation. -// apply a math operation to an image -func vipsGenMath(input *C.VipsImage, math OperationMath) (*C.VipsImage, error) { - incOpCounter("math") - - var out_out *C.VipsImage - - ret := C.gen_vips_math(input, C.VipsOperationMath(math), &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenMath2 calls the vips math2 operation. -// binary math operations -func vipsGenMath2(left *C.VipsImage, right *C.VipsImage, math2 OperationMath2) (*C.VipsImage, error) { - incOpCounter("math2") - - var out_out *C.VipsImage - - ret := C.gen_vips_math2(left, right, C.VipsOperationMath2(math2), &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenMath2Const calls the vips math2_const operation. -// binary math operations with a constant -func vipsGenMath2Const(input *C.VipsImage, math2 OperationMath2, c []float64) (*C.VipsImage, error) { - incOpCounter("math2_const") - - var out_out *C.VipsImage - - ret := C.gen_vips_math2_const(input, C.VipsOperationMath2(math2), (*C.double)(unsafe.Pointer(&c[0])), C.int(len(c)), &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenMatrixinvert calls the vips matrixinvert operation. -// invert a matrix -func vipsGenMatrixinvert(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("matrixinvert") - - var out_out *C.VipsImage - - ret := C.gen_vips_matrixinvert(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenMatrixmultiply calls the vips matrixmultiply operation. -// multiply two matrices -func vipsGenMatrixmultiply(left *C.VipsImage, right *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("matrixmultiply") - - var out_out *C.VipsImage - - ret := C.gen_vips_matrixmultiply(left, right, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenMaxpair calls the vips maxpair operation. -// maximum of a pair of images -func vipsGenMaxpair(left *C.VipsImage, right *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("maxpair") - - var out_out *C.VipsImage - - ret := C.gen_vips_maxpair(left, right, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// MergeOptions are optional parameters for merge. -type MergeOptions struct { - Mblend *int -} - -// vipsGenMerge calls the vips merge operation. -// merge two images -func vipsGenMerge(ref *C.VipsImage, sec *C.VipsImage, direction Direction, dx int, dy int, opts *MergeOptions) (*C.VipsImage, error) { - incOpCounter("merge") - - var out_out *C.VipsImage - - var cOpts C.GenMergeOpts - if opts != nil { - if opts.Mblend != nil { - cOpts.has_mblend = 1 - cOpts.mblend = C.int(*opts.Mblend) - } - } - - ret := C.gen_vips_merge(ref, sec, C.VipsDirection(direction), C.int(dx), C.int(dy), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenMinpair calls the vips minpair operation. -// minimum of a pair of images -func vipsGenMinpair(left *C.VipsImage, right *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("minpair") - - var out_out *C.VipsImage - - ret := C.gen_vips_minpair(left, right, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenMorph calls the vips morph operation. -// morphology operation -func vipsGenMorph(input *C.VipsImage, mask *C.VipsImage, morph OperationMorphology) (*C.VipsImage, error) { - incOpCounter("morph") - - var out_out *C.VipsImage - - ret := C.gen_vips_morph(input, mask, C.VipsOperationMorphology(morph), &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// MosaicOptions are optional parameters for mosaic. -type MosaicOptions struct { - Hwindow *int - Harea *int - Mblend *int - Bandno *int -} - -// vipsGenMosaic calls the vips mosaic operation. -// mosaic two images -func vipsGenMosaic(ref *C.VipsImage, sec *C.VipsImage, direction Direction, xref int, yref int, xsec int, ysec int, opts *MosaicOptions) (*C.VipsImage, int, int, float64, float64, float64, float64, error) { - incOpCounter("mosaic") - - var out_out *C.VipsImage - var out_dx0 C.int - var out_dy0 C.int - var out_scale1 C.double - var out_angle1 C.double - var out_dy1 C.double - var out_dx1 C.double - - var cOpts C.GenMosaicOpts - if opts != nil { - if opts.Hwindow != nil { - cOpts.has_hwindow = 1 - cOpts.hwindow = C.int(*opts.Hwindow) - } - if opts.Harea != nil { - cOpts.has_harea = 1 - cOpts.harea = C.int(*opts.Harea) - } - if opts.Mblend != nil { - cOpts.has_mblend = 1 - cOpts.mblend = C.int(*opts.Mblend) - } - if opts.Bandno != nil { - cOpts.has_bandno = 1 - cOpts.bandno = C.int(*opts.Bandno) - } - } - - ret := C.gen_vips_mosaic(ref, sec, C.VipsDirection(direction), C.int(xref), C.int(yref), C.int(xsec), C.int(ysec), &out_out, &out_dx0, &out_dy0, &out_scale1, &out_angle1, &out_dy1, &out_dx1, &cOpts) - if ret != 0 { - return nil, 0, 0, 0, 0, 0, 0, handleImageError(out_out) - } - - return out_out, int(out_dx0), int(out_dy0), float64(out_scale1), float64(out_angle1), float64(out_dy1), float64(out_dx1), nil -} - -// Mosaic1Options are optional parameters for mosaic1. -type Mosaic1Options struct { - Hwindow *int - Harea *int - Search *bool - Interpolate *C.VipsInterpolate - Mblend *int -} - -// vipsGenMosaic1 calls the vips mosaic1 operation. -// first-order mosaic of two images -func vipsGenMosaic1(ref *C.VipsImage, sec *C.VipsImage, direction Direction, xr1 int, yr1 int, xs1 int, ys1 int, xr2 int, yr2 int, xs2 int, ys2 int, opts *Mosaic1Options) (*C.VipsImage, error) { - incOpCounter("mosaic1") - - var out_out *C.VipsImage - - var cOpts C.GenMosaic1Opts - if opts != nil { - if opts.Hwindow != nil { - cOpts.has_hwindow = 1 - cOpts.hwindow = C.int(*opts.Hwindow) - } - if opts.Harea != nil { - cOpts.has_harea = 1 - cOpts.harea = C.int(*opts.Harea) - } - if opts.Search != nil { - cOpts.has_search = 1 - cOpts.search = C.int(boolToInt(*opts.Search)) - } - if opts.Interpolate != nil { - cOpts.has_interpolate = 1 - cOpts.interpolate = opts.Interpolate - } - if opts.Mblend != nil { - cOpts.has_mblend = 1 - cOpts.mblend = C.int(*opts.Mblend) - } - } - - ret := C.gen_vips_mosaic1(ref, sec, C.VipsDirection(direction), C.int(xr1), C.int(yr1), C.int(xs1), C.int(ys1), C.int(xr2), C.int(yr2), C.int(xs2), C.int(ys2), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// MsbOptions are optional parameters for msb. -type MsbOptions struct { - Band *int -} - -// vipsGenMsb calls the vips msb operation. -// pick most-significant byte from an image -func vipsGenMsb(input *C.VipsImage, opts *MsbOptions) (*C.VipsImage, error) { - incOpCounter("msb") - - var out_out *C.VipsImage - - var cOpts C.GenMsbOpts - if opts != nil { - if opts.Band != nil { - cOpts.has_band = 1 - cOpts.band = C.int(*opts.Band) - } - } - - ret := C.gen_vips_msb(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenMultiply calls the vips multiply operation. -// multiply two images -func vipsGenMultiply(left *C.VipsImage, right *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("multiply") - - var out_out *C.VipsImage - - ret := C.gen_vips_multiply(left, right, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenPercent calls the vips percent operation. -// find threshold for percent of pixels -func vipsGenPercent(input *C.VipsImage, percent float64) (int, error) { - incOpCounter("percent") - - var out_threshold C.int - - ret := C.gen_vips_percent(input, C.double(percent), &out_threshold) - if ret != 0 { - return 0, handleVipsError() - } - - return int(out_threshold), nil -} - -// PerlinOptions are optional parameters for perlin. -type PerlinOptions struct { - CellSize *int - Uchar *bool - Seed *int -} - -// vipsGenPerlin calls the vips perlin operation. -// make a perlin noise image -func vipsGenPerlin(width int, height int, opts *PerlinOptions) (*C.VipsImage, error) { - incOpCounter("perlin") - - var out_out *C.VipsImage - - var cOpts C.GenPerlinOpts - if opts != nil { - if opts.CellSize != nil { - cOpts.has_cellSize = 1 - cOpts.cellSize = C.int(*opts.CellSize) - } - if opts.Uchar != nil { - cOpts.has_uchar = 1 - cOpts.uchar = C.int(boolToInt(*opts.Uchar)) - } - if opts.Seed != nil { - cOpts.has_seed = 1 - cOpts.seed = C.int(*opts.Seed) - } - } - - ret := C.gen_vips_perlin(C.int(width), C.int(height), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenPhasecor calls the vips phasecor operation. -// calculate phase correlation -func vipsGenPhasecor(input *C.VipsImage, in2 *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("phasecor") - - var out_out *C.VipsImage - - ret := C.gen_vips_phasecor(input, in2, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// PremultiplyOptions are optional parameters for premultiply. -type PremultiplyOptions struct { - MaxAlpha *float64 -} - -// vipsGenPremultiply calls the vips premultiply operation. -// premultiply image alpha -func vipsGenPremultiply(input *C.VipsImage, opts *PremultiplyOptions) (*C.VipsImage, error) { - incOpCounter("premultiply") - - var out_out *C.VipsImage - - var cOpts C.GenPremultiplyOpts - if opts != nil { - if opts.MaxAlpha != nil { - cOpts.has_maxAlpha = 1 - cOpts.maxAlpha = C.double(*opts.MaxAlpha) - } - } - - ret := C.gen_vips_premultiply(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenPrewitt calls the vips prewitt operation. -// Prewitt edge detector -func vipsGenPrewitt(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("prewitt") - - var out_out *C.VipsImage - - ret := C.gen_vips_prewitt(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenProfile calls the vips profile operation. -// find image profiles -func vipsGenProfile(input *C.VipsImage) (*C.VipsImage, *C.VipsImage, error) { - incOpCounter("profile") - - var out_columns *C.VipsImage - var out_rows *C.VipsImage - - ret := C.gen_vips_profile(input, &out_columns, &out_rows) - if ret != 0 { - return nil, nil, handleImageError(out_columns) - } - - return out_columns, out_rows, nil -} - -// vipsGenProject calls the vips project operation. -// find image projections -func vipsGenProject(input *C.VipsImage) (*C.VipsImage, *C.VipsImage, error) { - incOpCounter("project") - - var out_columns *C.VipsImage - var out_rows *C.VipsImage - - ret := C.gen_vips_project(input, &out_columns, &out_rows) - if ret != 0 { - return nil, nil, handleImageError(out_columns) - } - - return out_columns, out_rows, nil -} - -// QuadraticOptions are optional parameters for quadratic. -type QuadraticOptions struct { - Interpolate *C.VipsInterpolate -} - -// vipsGenQuadratic calls the vips quadratic operation. -// resample an image with a quadratic transform -func vipsGenQuadratic(input *C.VipsImage, coeff *C.VipsImage, opts *QuadraticOptions) (*C.VipsImage, error) { - incOpCounter("quadratic") - - var out_out *C.VipsImage - - var cOpts C.GenQuadraticOpts - if opts != nil { - if opts.Interpolate != nil { - cOpts.has_interpolate = 1 - cOpts.interpolate = opts.Interpolate - } - } - - ret := C.gen_vips_quadratic(input, coeff, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenRad2float calls the vips rad2float operation. -// unpack Radiance coding to float RGB -func vipsGenRad2float(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("rad2float") - - var out_out *C.VipsImage - - ret := C.gen_vips_rad2float(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenRank calls the vips rank operation. -// rank filter -func vipsGenRank(input *C.VipsImage, width int, height int, index int) (*C.VipsImage, error) { - incOpCounter("rank") - - var out_out *C.VipsImage - - ret := C.gen_vips_rank(input, C.int(width), C.int(height), C.int(index), &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenRecomb calls the vips recomb operation. -// linear recombination with matrix -func vipsGenRecomb(input *C.VipsImage, m *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("recomb") - - var out_out *C.VipsImage - - ret := C.gen_vips_recomb(input, m, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// ReduceOptions are optional parameters for reduce. -type ReduceOptions struct { - Kernel *Kernel - Gap *float64 -} - -// vipsGenReduce calls the vips reduce operation. -// reduce an image -func vipsGenReduce(input *C.VipsImage, hshrink float64, vshrink float64, opts *ReduceOptions) (*C.VipsImage, error) { - incOpCounter("reduce") - - var out_out *C.VipsImage - - var cOpts C.GenReduceOpts - if opts != nil { - if opts.Kernel != nil { - cOpts.has_kernel = 1 - cOpts.kernel = C.VipsKernel(*opts.Kernel) - } - if opts.Gap != nil { - cOpts.has_gap = 1 - cOpts.gap = C.double(*opts.Gap) - } - } - - ret := C.gen_vips_reduce(input, C.double(hshrink), C.double(vshrink), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// ReducehOptions are optional parameters for reduceh. -type ReducehOptions struct { - Kernel *Kernel - Gap *float64 -} - -// vipsGenReduceh calls the vips reduceh operation. -// shrink an image horizontally -func vipsGenReduceh(input *C.VipsImage, hshrink float64, opts *ReducehOptions) (*C.VipsImage, error) { - incOpCounter("reduceh") - - var out_out *C.VipsImage - - var cOpts C.GenReducehOpts - if opts != nil { - if opts.Kernel != nil { - cOpts.has_kernel = 1 - cOpts.kernel = C.VipsKernel(*opts.Kernel) - } - if opts.Gap != nil { - cOpts.has_gap = 1 - cOpts.gap = C.double(*opts.Gap) - } - } - - ret := C.gen_vips_reduceh(input, C.double(hshrink), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// ReducevOptions are optional parameters for reducev. -type ReducevOptions struct { - Kernel *Kernel - Gap *float64 -} - -// vipsGenReducev calls the vips reducev operation. -// shrink an image vertically -func vipsGenReducev(input *C.VipsImage, vshrink float64, opts *ReducevOptions) (*C.VipsImage, error) { - incOpCounter("reducev") - - var out_out *C.VipsImage - - var cOpts C.GenReducevOpts - if opts != nil { - if opts.Kernel != nil { - cOpts.has_kernel = 1 - cOpts.kernel = C.VipsKernel(*opts.Kernel) - } - if opts.Gap != nil { - cOpts.has_gap = 1 - cOpts.gap = C.double(*opts.Gap) - } - } - - ret := C.gen_vips_reducev(input, C.double(vshrink), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenRelational calls the vips relational operation. -// relational operation on two images -func vipsGenRelational(left *C.VipsImage, right *C.VipsImage, relational OperationRelational) (*C.VipsImage, error) { - incOpCounter("relational") - - var out_out *C.VipsImage - - ret := C.gen_vips_relational(left, right, C.VipsOperationRelational(relational), &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenRelationalConst calls the vips relational_const operation. -// relational operations against a constant -func vipsGenRelationalConst(input *C.VipsImage, relational OperationRelational, c []float64) (*C.VipsImage, error) { - incOpCounter("relational_const") - - var out_out *C.VipsImage - - ret := C.gen_vips_relational_const(input, C.VipsOperationRelational(relational), (*C.double)(unsafe.Pointer(&c[0])), C.int(len(c)), &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenRemainder calls the vips remainder operation. -// remainder after integer division of two images -func vipsGenRemainder(left *C.VipsImage, right *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("remainder") - - var out_out *C.VipsImage - - ret := C.gen_vips_remainder(left, right, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenRemainderConst calls the vips remainder_const operation. -// remainder after integer division of an image and a constant -func vipsGenRemainderConst(input *C.VipsImage, c []float64) (*C.VipsImage, error) { - incOpCounter("remainder_const") - - var out_out *C.VipsImage - - ret := C.gen_vips_remainder_const(input, (*C.double)(unsafe.Pointer(&c[0])), C.int(len(c)), &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenRemosaic calls the vips remosaic operation. -// rebuild an mosaiced image -func vipsGenRemosaic(input *C.VipsImage, oldStr string, newStr string) (*C.VipsImage, error) { - incOpCounter("remosaic") - - cStr_oldStr := C.CString(oldStr) - defer C.free(unsafe.Pointer(cStr_oldStr)) - cStr_newStr := C.CString(newStr) - defer C.free(unsafe.Pointer(cStr_newStr)) - var out_out *C.VipsImage - - ret := C.gen_vips_remosaic(input, cStr_oldStr, cStr_newStr, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenReplicate calls the vips replicate operation. -// replicate an image -func vipsGenReplicate(input *C.VipsImage, across int, down int) (*C.VipsImage, error) { - incOpCounter("replicate") - - var out_out *C.VipsImage - - ret := C.gen_vips_replicate(input, C.int(across), C.int(down), &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenRot calls the vips rot operation. -// rotate an image -func vipsGenRot(input *C.VipsImage, angle Angle) (*C.VipsImage, error) { - incOpCounter("rot") - - var out_out *C.VipsImage - - ret := C.gen_vips_rot(input, C.VipsAngle(angle), &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// Rot45Options are optional parameters for rot45. -type Rot45Options struct { - Angle *Angle45 -} - -// vipsGenRot45 calls the vips rot45 operation. -// rotate an image -func vipsGenRot45(input *C.VipsImage, opts *Rot45Options) (*C.VipsImage, error) { - incOpCounter("rot45") - - var out_out *C.VipsImage - - var cOpts C.GenRot45Opts - if opts != nil { - if opts.Angle != nil { - cOpts.has_angle = 1 - cOpts.angle = C.VipsAngle45(*opts.Angle) - } - } - - ret := C.gen_vips_rot45(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// RotateOptions are optional parameters for rotate. -type RotateOptions struct { - Interpolate *C.VipsInterpolate - Background []float64 - Odx *float64 - Ody *float64 - Idx *float64 - Idy *float64 -} - -// vipsGenRotate calls the vips rotate operation. -// rotate an image by a number of degrees -func vipsGenRotate(input *C.VipsImage, angle float64, opts *RotateOptions) (*C.VipsImage, error) { - incOpCounter("rotate") - - var out_out *C.VipsImage - - var cOpts C.GenRotateOpts - var pinner runtime.Pinner - defer pinner.Unpin() - if opts != nil { - if opts.Interpolate != nil { - cOpts.has_interpolate = 1 - cOpts.interpolate = opts.Interpolate - } - if opts.Background != nil { - cOpts.has_background = 1 - pinner.Pin(&opts.Background[0]) - cOpts.background = (*C.double)(unsafe.Pointer(&opts.Background[0])) - cOpts.background_n = C.int(len(opts.Background)) - } - if opts.Odx != nil { - cOpts.has_odx = 1 - cOpts.odx = C.double(*opts.Odx) - } - if opts.Ody != nil { - cOpts.has_ody = 1 - cOpts.ody = C.double(*opts.Ody) - } - if opts.Idx != nil { - cOpts.has_idx = 1 - cOpts.idx = C.double(*opts.Idx) - } - if opts.Idy != nil { - cOpts.has_idy = 1 - cOpts.idy = C.double(*opts.Idy) - } - } - - ret := C.gen_vips_rotate(input, C.double(angle), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenRound calls the vips round operation. -// perform a round function on an image -func vipsGenRound(input *C.VipsImage, round OperationRound) (*C.VipsImage, error) { - incOpCounter("round") - - var out_out *C.VipsImage - - ret := C.gen_vips_round(input, C.VipsOperationRound(round), &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenSRGB2HSV calls the vips sRGB2HSV operation. -// transform sRGB to HSV -func vipsGenSRGB2HSV(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("sRGB2HSV") - - var out_out *C.VipsImage - - ret := C.gen_vips_sRGB2HSV(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenSRGB2scRGB calls the vips sRGB2scRGB operation. -// convert an sRGB image to scRGB -func vipsGenSRGB2scRGB(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("sRGB2scRGB") - - var out_out *C.VipsImage - - ret := C.gen_vips_sRGB2scRGB(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// ScRGB2BWOptions are optional parameters for scRGB2BW. -type ScRGB2BWOptions struct { - Depth *int -} - -// vipsGenScRGB2BW calls the vips scRGB2BW operation. -// convert scRGB to BW -func vipsGenScRGB2BW(input *C.VipsImage, opts *ScRGB2BWOptions) (*C.VipsImage, error) { - incOpCounter("scRGB2BW") - - var out_out *C.VipsImage - - var cOpts C.GenScRGB2BWOpts - if opts != nil { - if opts.Depth != nil { - cOpts.has_depth = 1 - cOpts.depth = C.int(*opts.Depth) - } - } - - ret := C.gen_vips_scRGB2BW(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenScRGB2XYZ calls the vips scRGB2XYZ operation. -// transform scRGB to XYZ -func vipsGenScRGB2XYZ(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("scRGB2XYZ") - - var out_out *C.VipsImage - - ret := C.gen_vips_scRGB2XYZ(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// ScRGB2sRGBOptions are optional parameters for scRGB2sRGB. -type ScRGB2sRGBOptions struct { - Depth *int -} - -// vipsGenScRGB2sRGB calls the vips scRGB2sRGB operation. -// convert scRGB to sRGB -func vipsGenScRGB2sRGB(input *C.VipsImage, opts *ScRGB2sRGBOptions) (*C.VipsImage, error) { - incOpCounter("scRGB2sRGB") - - var out_out *C.VipsImage - - var cOpts C.GenScRGB2sRGBOpts - if opts != nil { - if opts.Depth != nil { - cOpts.has_depth = 1 - cOpts.depth = C.int(*opts.Depth) - } - } - - ret := C.gen_vips_scRGB2sRGB(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// ScaleOptions are optional parameters for scale. -type ScaleOptions struct { - Exp *float64 - Log *bool -} - -// vipsGenScale calls the vips scale operation. -// scale an image to uchar -func vipsGenScale(input *C.VipsImage, opts *ScaleOptions) (*C.VipsImage, error) { - incOpCounter("scale") - - var out_out *C.VipsImage - - var cOpts C.GenScaleOpts - if opts != nil { - if opts.Exp != nil { - cOpts.has_exp = 1 - cOpts.exp = C.double(*opts.Exp) - } - if opts.Log != nil { - cOpts.has_log = 1 - cOpts.log = C.int(boolToInt(*opts.Log)) - } - } - - ret := C.gen_vips_scale(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenScharr calls the vips scharr operation. -// Scharr edge detector -func vipsGenScharr(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("scharr") - - var out_out *C.VipsImage - - ret := C.gen_vips_scharr(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// SequentialOptions are optional parameters for sequential. -type SequentialOptions struct { - TileHeight *int -} - -// vipsGenSequential calls the vips sequential operation. -// check sequential access -func vipsGenSequential(input *C.VipsImage, opts *SequentialOptions) (*C.VipsImage, error) { - incOpCounter("sequential") - - var out_out *C.VipsImage - - var cOpts C.GenSequentialOpts - if opts != nil { - if opts.TileHeight != nil { - cOpts.has_tileHeight = 1 - cOpts.tileHeight = C.int(*opts.TileHeight) - } - } - - ret := C.gen_vips_sequential(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// SharpenOptions are optional parameters for sharpen. -type SharpenOptions struct { - Sigma *float64 - X1 *float64 - Y2 *float64 - Y3 *float64 - M1 *float64 - M2 *float64 -} - -// vipsGenSharpen calls the vips sharpen operation. -// unsharp masking for print -func vipsGenSharpen(input *C.VipsImage, opts *SharpenOptions) (*C.VipsImage, error) { - incOpCounter("sharpen") - - var out_out *C.VipsImage - - var cOpts C.GenSharpenOpts - if opts != nil { - if opts.Sigma != nil { - cOpts.has_sigma = 1 - cOpts.sigma = C.double(*opts.Sigma) - } - if opts.X1 != nil { - cOpts.has_x1 = 1 - cOpts.x1 = C.double(*opts.X1) - } - if opts.Y2 != nil { - cOpts.has_y2 = 1 - cOpts.y2 = C.double(*opts.Y2) - } - if opts.Y3 != nil { - cOpts.has_y3 = 1 - cOpts.y3 = C.double(*opts.Y3) - } - if opts.M1 != nil { - cOpts.has_m1 = 1 - cOpts.m1 = C.double(*opts.M1) - } - if opts.M2 != nil { - cOpts.has_m2 = 1 - cOpts.m2 = C.double(*opts.M2) - } - } - - ret := C.gen_vips_sharpen(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// ShrinkOptions are optional parameters for shrink. -type ShrinkOptions struct { - Ceil *bool -} - -// vipsGenShrink calls the vips shrink operation. -// shrink an image -func vipsGenShrink(input *C.VipsImage, hshrink float64, vshrink float64, opts *ShrinkOptions) (*C.VipsImage, error) { - incOpCounter("shrink") - - var out_out *C.VipsImage - - var cOpts C.GenShrinkOpts - if opts != nil { - if opts.Ceil != nil { - cOpts.has_ceil = 1 - cOpts.ceil = C.int(boolToInt(*opts.Ceil)) - } - } - - ret := C.gen_vips_shrink(input, C.double(hshrink), C.double(vshrink), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// ShrinkhOptions are optional parameters for shrinkh. -type ShrinkhOptions struct { - Ceil *bool -} - -// vipsGenShrinkh calls the vips shrinkh operation. -// shrink an image horizontally -func vipsGenShrinkh(input *C.VipsImage, hshrink int, opts *ShrinkhOptions) (*C.VipsImage, error) { - incOpCounter("shrinkh") - - var out_out *C.VipsImage - - var cOpts C.GenShrinkhOpts - if opts != nil { - if opts.Ceil != nil { - cOpts.has_ceil = 1 - cOpts.ceil = C.int(boolToInt(*opts.Ceil)) - } - } - - ret := C.gen_vips_shrinkh(input, C.int(hshrink), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// ShrinkvOptions are optional parameters for shrinkv. -type ShrinkvOptions struct { - Ceil *bool -} - -// vipsGenShrinkv calls the vips shrinkv operation. -// shrink an image vertically -func vipsGenShrinkv(input *C.VipsImage, vshrink int, opts *ShrinkvOptions) (*C.VipsImage, error) { - incOpCounter("shrinkv") - - var out_out *C.VipsImage - - var cOpts C.GenShrinkvOpts - if opts != nil { - if opts.Ceil != nil { - cOpts.has_ceil = 1 - cOpts.ceil = C.int(boolToInt(*opts.Ceil)) - } - } - - ret := C.gen_vips_shrinkv(input, C.int(vshrink), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenSign calls the vips sign operation. -// unit vector of pixel -func vipsGenSign(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("sign") - - var out_out *C.VipsImage - - ret := C.gen_vips_sign(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// SimilarityOptions are optional parameters for similarity. -type SimilarityOptions struct { - Scale *float64 - Angle *float64 - Interpolate *C.VipsInterpolate - Background []float64 - Odx *float64 - Ody *float64 - Idx *float64 - Idy *float64 -} - -// vipsGenSimilarity calls the vips similarity operation. -// similarity transform of an image -func vipsGenSimilarity(input *C.VipsImage, opts *SimilarityOptions) (*C.VipsImage, error) { - incOpCounter("similarity") - - var out_out *C.VipsImage - - var cOpts C.GenSimilarityOpts - var pinner runtime.Pinner - defer pinner.Unpin() - if opts != nil { - if opts.Scale != nil { - cOpts.has_scale = 1 - cOpts.scale = C.double(*opts.Scale) - } - if opts.Angle != nil { - cOpts.has_angle = 1 - cOpts.angle = C.double(*opts.Angle) - } - if opts.Interpolate != nil { - cOpts.has_interpolate = 1 - cOpts.interpolate = opts.Interpolate - } - if opts.Background != nil { - cOpts.has_background = 1 - pinner.Pin(&opts.Background[0]) - cOpts.background = (*C.double)(unsafe.Pointer(&opts.Background[0])) - cOpts.background_n = C.int(len(opts.Background)) - } - if opts.Odx != nil { - cOpts.has_odx = 1 - cOpts.odx = C.double(*opts.Odx) - } - if opts.Ody != nil { - cOpts.has_ody = 1 - cOpts.ody = C.double(*opts.Ody) - } - if opts.Idx != nil { - cOpts.has_idx = 1 - cOpts.idx = C.double(*opts.Idx) - } - if opts.Idy != nil { - cOpts.has_idy = 1 - cOpts.idy = C.double(*opts.Idy) - } - } - - ret := C.gen_vips_similarity(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// SinesOptions are optional parameters for sines. -type SinesOptions struct { - Uchar *bool - Hfreq *float64 - Vfreq *float64 -} - -// vipsGenSines calls the vips sines operation. -// make a 2D sine wave -func vipsGenSines(width int, height int, opts *SinesOptions) (*C.VipsImage, error) { - incOpCounter("sines") - - var out_out *C.VipsImage - - var cOpts C.GenSinesOpts - if opts != nil { - if opts.Uchar != nil { - cOpts.has_uchar = 1 - cOpts.uchar = C.int(boolToInt(*opts.Uchar)) - } - if opts.Hfreq != nil { - cOpts.has_hfreq = 1 - cOpts.hfreq = C.double(*opts.Hfreq) - } - if opts.Vfreq != nil { - cOpts.has_vfreq = 1 - cOpts.vfreq = C.double(*opts.Vfreq) - } - } - - ret := C.gen_vips_sines(C.int(width), C.int(height), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// SmartcropOptions are optional parameters for smartcrop. -type SmartcropOptions struct { - Interesting *Interesting - Premultiplied *bool -} - -// vipsGenSmartcrop calls the vips smartcrop operation. -// extract an area from an image -func vipsGenSmartcrop(input *C.VipsImage, width int, height int, opts *SmartcropOptions) (int, *C.VipsImage, int, error) { - incOpCounter("smartcrop") - - var out_attentionX C.int - var out_out *C.VipsImage - var out_attentionY C.int - - var cOpts C.GenSmartcropOpts - if opts != nil { - if opts.Interesting != nil { - cOpts.has_interesting = 1 - cOpts.interesting = C.VipsInteresting(*opts.Interesting) - } - if opts.Premultiplied != nil { - cOpts.has_premultiplied = 1 - cOpts.premultiplied = C.int(boolToInt(*opts.Premultiplied)) - } - } - - ret := C.gen_vips_smartcrop(input, C.int(width), C.int(height), &out_attentionX, &out_out, &out_attentionY, &cOpts) - if ret != 0 { - return 0, nil, 0, handleImageError(out_out) - } - - return int(out_attentionX), out_out, int(out_attentionY), nil -} - -// vipsGenSobel calls the vips sobel operation. -// Sobel edge detector -func vipsGenSobel(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("sobel") - - var out_out *C.VipsImage - - ret := C.gen_vips_sobel(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenSpcor calls the vips spcor operation. -// spatial correlation -func vipsGenSpcor(input *C.VipsImage, ref *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("spcor") - - var out_out *C.VipsImage - - ret := C.gen_vips_spcor(input, ref, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenSpectrum calls the vips spectrum operation. -// make displayable power spectrum -func vipsGenSpectrum(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("spectrum") - - var out_out *C.VipsImage - - ret := C.gen_vips_spectrum(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenStats calls the vips stats operation. -// find many image stats -func vipsGenStats(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("stats") - - var out_out *C.VipsImage - - ret := C.gen_vips_stats(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// StdifOptions are optional parameters for stdif. -type StdifOptions struct { - S0 *float64 - B *float64 - M0 *float64 - A *float64 -} - -// vipsGenStdif calls the vips stdif operation. -// statistical difference -func vipsGenStdif(input *C.VipsImage, width int, height int, opts *StdifOptions) (*C.VipsImage, error) { - incOpCounter("stdif") - - var out_out *C.VipsImage - - var cOpts C.GenStdifOpts - if opts != nil { - if opts.S0 != nil { - cOpts.has_s0 = 1 - cOpts.s0 = C.double(*opts.S0) - } - if opts.B != nil { - cOpts.has_b = 1 - cOpts.b = C.double(*opts.B) - } - if opts.M0 != nil { - cOpts.has_m0 = 1 - cOpts.m0 = C.double(*opts.M0) - } - if opts.A != nil { - cOpts.has_a = 1 - cOpts.a = C.double(*opts.A) - } - } - - ret := C.gen_vips_stdif(input, C.int(width), C.int(height), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// SubsampleOptions are optional parameters for subsample. -type SubsampleOptions struct { - Point *bool -} - -// vipsGenSubsample calls the vips subsample operation. -// subsample an image -func vipsGenSubsample(input *C.VipsImage, xfac int, yfac int, opts *SubsampleOptions) (*C.VipsImage, error) { - incOpCounter("subsample") - - var out_out *C.VipsImage - - var cOpts C.GenSubsampleOpts - if opts != nil { - if opts.Point != nil { - cOpts.has_point = 1 - cOpts.point = C.int(boolToInt(*opts.Point)) - } - } - - ret := C.gen_vips_subsample(input, C.int(xfac), C.int(yfac), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenSubtract calls the vips subtract operation. -// subtract two images -func vipsGenSubtract(left *C.VipsImage, right *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("subtract") - - var out_out *C.VipsImage - - ret := C.gen_vips_subtract(left, right, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenSum calls the vips sum operation. -// sum an array of images -func vipsGenSum(input []*C.VipsImage) (*C.VipsImage, error) { - incOpCounter("sum") - - var out_out *C.VipsImage - - ret := C.gen_vips_sum((**C.VipsImage)(unsafe.Pointer(&input[0])), C.int(len(input)), &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// TilecacheOptions are optional parameters for tilecache. -type TilecacheOptions struct { - TileWidth *int - TileHeight *int - MaxTiles *int - Access *int - Threaded *bool - Persistent *bool -} - -// vipsGenTilecache calls the vips tilecache operation. -// cache an image as a set of tiles -func vipsGenTilecache(input *C.VipsImage, opts *TilecacheOptions) (*C.VipsImage, error) { - incOpCounter("tilecache") - - var out_out *C.VipsImage - - var cOpts C.GenTilecacheOpts - if opts != nil { - if opts.TileWidth != nil { - cOpts.has_tileWidth = 1 - cOpts.tileWidth = C.int(*opts.TileWidth) - } - if opts.TileHeight != nil { - cOpts.has_tileHeight = 1 - cOpts.tileHeight = C.int(*opts.TileHeight) - } - if opts.MaxTiles != nil { - cOpts.has_maxTiles = 1 - cOpts.maxTiles = C.int(*opts.MaxTiles) - } - if opts.Access != nil { - cOpts.has_access = 1 - cOpts.access = C.VipsAccess(*opts.Access) - } - if opts.Threaded != nil { - cOpts.has_threaded = 1 - cOpts.threaded = C.int(boolToInt(*opts.Threaded)) - } - if opts.Persistent != nil { - cOpts.has_persistent = 1 - cOpts.persistent = C.int(boolToInt(*opts.Persistent)) - } - } - - ret := C.gen_vips_tilecache(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// TonelutOptions are optional parameters for tonelut. -type TonelutOptions struct { - InMax *int - OutMax *int - Lb *float64 - Lw *float64 - Ps *float64 - Pm *float64 - Ph *float64 - S *float64 - M *float64 - H *float64 -} - -// vipsGenTonelut calls the vips tonelut operation. -// build a look-up table -func vipsGenTonelut(opts *TonelutOptions) (*C.VipsImage, error) { - incOpCounter("tonelut") - - var out_out *C.VipsImage - - var cOpts C.GenTonelutOpts - if opts != nil { - if opts.InMax != nil { - cOpts.has_inMax = 1 - cOpts.inMax = C.int(*opts.InMax) - } - if opts.OutMax != nil { - cOpts.has_outMax = 1 - cOpts.outMax = C.int(*opts.OutMax) - } - if opts.Lb != nil { - cOpts.has_Lb = 1 - cOpts.Lb = C.double(*opts.Lb) - } - if opts.Lw != nil { - cOpts.has_Lw = 1 - cOpts.Lw = C.double(*opts.Lw) - } - if opts.Ps != nil { - cOpts.has_Ps = 1 - cOpts.Ps = C.double(*opts.Ps) - } - if opts.Pm != nil { - cOpts.has_Pm = 1 - cOpts.Pm = C.double(*opts.Pm) - } - if opts.Ph != nil { - cOpts.has_Ph = 1 - cOpts.Ph = C.double(*opts.Ph) - } - if opts.S != nil { - cOpts.has_S = 1 - cOpts.S = C.double(*opts.S) - } - if opts.M != nil { - cOpts.has_M = 1 - cOpts.M = C.double(*opts.M) - } - if opts.H != nil { - cOpts.has_H = 1 - cOpts.H = C.double(*opts.H) - } - } - - ret := C.gen_vips_tonelut(&out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// Transpose3dOptions are optional parameters for transpose3d. -type Transpose3dOptions struct { - PageHeight *int -} - -// vipsGenTranspose3d calls the vips transpose3d operation. -// transpose3d an image -func vipsGenTranspose3d(input *C.VipsImage, opts *Transpose3dOptions) (*C.VipsImage, error) { - incOpCounter("transpose3d") - - var out_out *C.VipsImage - - var cOpts C.GenTranspose3dOpts - if opts != nil { - if opts.PageHeight != nil { - cOpts.has_pageHeight = 1 - cOpts.pageHeight = C.int(*opts.PageHeight) - } - } - - ret := C.gen_vips_transpose3d(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenUhdr2scRGB calls the vips uhdr2scRGB operation. -// transform uhdr to scRGB -func vipsGenUhdr2scRGB(input *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("uhdr2scRGB") - - var out_out *C.VipsImage - - ret := C.gen_vips_uhdr2scRGB(input, &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// UnpremultiplyOptions are optional parameters for unpremultiply. -type UnpremultiplyOptions struct { - MaxAlpha *float64 - AlphaBand *int -} - -// vipsGenUnpremultiply calls the vips unpremultiply operation. -// unpremultiply image alpha -func vipsGenUnpremultiply(input *C.VipsImage, opts *UnpremultiplyOptions) (*C.VipsImage, error) { - incOpCounter("unpremultiply") - - var out_out *C.VipsImage - - var cOpts C.GenUnpremultiplyOpts - if opts != nil { - if opts.MaxAlpha != nil { - cOpts.has_maxAlpha = 1 - cOpts.maxAlpha = C.double(*opts.MaxAlpha) - } - if opts.AlphaBand != nil { - cOpts.has_alphaBand = 1 - cOpts.alphaBand = C.int(*opts.AlphaBand) - } - } - - ret := C.gen_vips_unpremultiply(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// WorleyOptions are optional parameters for worley. -type WorleyOptions struct { - CellSize *int - Seed *int -} - -// vipsGenWorley calls the vips worley operation. -// make a worley noise image -func vipsGenWorley(width int, height int, opts *WorleyOptions) (*C.VipsImage, error) { - incOpCounter("worley") - - var out_out *C.VipsImage - - var cOpts C.GenWorleyOpts - if opts != nil { - if opts.CellSize != nil { - cOpts.has_cellSize = 1 - cOpts.cellSize = C.int(*opts.CellSize) - } - if opts.Seed != nil { - cOpts.has_seed = 1 - cOpts.seed = C.int(*opts.Seed) - } - } - - ret := C.gen_vips_worley(C.int(width), C.int(height), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// WrapOptions are optional parameters for wrap. -type WrapOptions struct { - X *int - Y *int -} - -// vipsGenWrap calls the vips wrap operation. -// wrap image origin -func vipsGenWrap(input *C.VipsImage, opts *WrapOptions) (*C.VipsImage, error) { - incOpCounter("wrap") - - var out_out *C.VipsImage - - var cOpts C.GenWrapOpts - if opts != nil { - if opts.X != nil { - cOpts.has_x = 1 - cOpts.x = C.int(*opts.X) - } - if opts.Y != nil { - cOpts.has_y = 1 - cOpts.y = C.int(*opts.Y) - } - } - - ret := C.gen_vips_wrap(input, &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// XyzOptions are optional parameters for xyz. -type XyzOptions struct { - Csize *int - Dsize *int - Esize *int -} - -// vipsGenXyz calls the vips xyz operation. -// make an image where pixel values are coordinates -func vipsGenXyz(width int, height int, opts *XyzOptions) (*C.VipsImage, error) { - incOpCounter("xyz") - - var out_out *C.VipsImage - - var cOpts C.GenXyzOpts - if opts != nil { - if opts.Csize != nil { - cOpts.has_csize = 1 - cOpts.csize = C.int(*opts.Csize) - } - if opts.Dsize != nil { - cOpts.has_dsize = 1 - cOpts.dsize = C.int(*opts.Dsize) - } - if opts.Esize != nil { - cOpts.has_esize = 1 - cOpts.esize = C.int(*opts.Esize) - } - } - - ret := C.gen_vips_xyz(C.int(width), C.int(height), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// ZoneOptions are optional parameters for zone. -type ZoneOptions struct { - Uchar *bool -} - -// vipsGenZone calls the vips zone operation. -// make a zone plate -func vipsGenZone(width int, height int, opts *ZoneOptions) (*C.VipsImage, error) { - incOpCounter("zone") - - var out_out *C.VipsImage - - var cOpts C.GenZoneOpts - if opts != nil { - if opts.Uchar != nil { - cOpts.has_uchar = 1 - cOpts.uchar = C.int(boolToInt(*opts.Uchar)) - } - } - - ret := C.gen_vips_zone(C.int(width), C.int(height), &out_out, &cOpts) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - -// vipsGenZoom calls the vips zoom operation. -// zoom an image -func vipsGenZoom(input *C.VipsImage, xfac int, yfac int) (*C.VipsImage, error) { - incOpCounter("zoom") - - var out_out *C.VipsImage - - ret := C.gen_vips_zoom(input, C.int(xfac), C.int(yfac), &out_out) - if ret != 0 { - return nil, handleImageError(out_out) - } - - return out_out, nil -} - diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/generated.h b/vendor/github.com/davidbyttow/govips/v2/vips/generated.h deleted file mode 100644 index 930eccb5eb..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/generated.h +++ /dev/null @@ -1,1181 +0,0 @@ -// Code generated by vipsgen. DO NOT EDIT. -#ifndef GENERATED_H -#define GENERATED_H - -#include -#include - -int gen_vips_CMC2LCh(VipsImage * input, VipsImage ** out_out); - -int gen_vips_CMYK2XYZ(VipsImage * input, VipsImage ** out_out); - -int gen_vips_HSV2sRGB(VipsImage * input, VipsImage ** out_out); - -int gen_vips_LCh2CMC(VipsImage * input, VipsImage ** out_out); - -int gen_vips_LCh2Lab(VipsImage * input, VipsImage ** out_out); - -int gen_vips_Lab2LCh(VipsImage * input, VipsImage ** out_out); - -int gen_vips_Lab2LabQ(VipsImage * input, VipsImage ** out_out); - -int gen_vips_Lab2LabS(VipsImage * input, VipsImage ** out_out); - -typedef struct { - int has_temp; - double *temp; int temp_n; -} GenLab2XYZOpts; - -int gen_vips_Lab2XYZ(VipsImage * input, VipsImage ** out_out, GenLab2XYZOpts *opts); - -int gen_vips_LabQ2Lab(VipsImage * input, VipsImage ** out_out); - -int gen_vips_LabQ2LabS(VipsImage * input, VipsImage ** out_out); - -int gen_vips_LabQ2sRGB(VipsImage * input, VipsImage ** out_out); - -int gen_vips_LabS2Lab(VipsImage * input, VipsImage ** out_out); - -int gen_vips_LabS2LabQ(VipsImage * input, VipsImage ** out_out); - -int gen_vips_Oklab2Oklch(VipsImage * input, VipsImage ** out_out); - -int gen_vips_Oklab2XYZ(VipsImage * input, VipsImage ** out_out); - -int gen_vips_Oklch2Oklab(VipsImage * input, VipsImage ** out_out); - -int gen_vips_XYZ2CMYK(VipsImage * input, VipsImage ** out_out); - -typedef struct { - int has_temp; - double *temp; int temp_n; -} GenXYZ2LabOpts; - -int gen_vips_XYZ2Lab(VipsImage * input, VipsImage ** out_out, GenXYZ2LabOpts *opts); - -int gen_vips_XYZ2Oklab(VipsImage * input, VipsImage ** out_out); - -int gen_vips_XYZ2Yxy(VipsImage * input, VipsImage ** out_out); - -int gen_vips_XYZ2scRGB(VipsImage * input, VipsImage ** out_out); - -int gen_vips_Yxy2XYZ(VipsImage * input, VipsImage ** out_out); - -int gen_vips_abs(VipsImage * input, VipsImage ** out_out); - -int gen_vips_add(VipsImage * left, VipsImage * right, VipsImage ** out_out); - -typedef struct { - int has_interpolate; - VipsInterpolate *interpolate; - int has_oarea; - int *oarea; int oarea_n; - int has_odx; - double odx; - int has_ody; - double ody; - int has_idx; - double idx; - int has_idy; - double idy; - int has_background; - double *background; int background_n; - int has_premultiplied; - int premultiplied; - int has_extend; - VipsExtend extend; -} GenAffineOpts; - -int gen_vips_affine(VipsImage * input, double * matrix, int matrix_n, VipsImage ** out_out, GenAffineOpts *opts); - -typedef struct { - int has_across; - int across; - int has_shim; - int shim; - int has_background; - double *background; int background_n; - int has_halign; - VipsAlign halign; - int has_valign; - VipsAlign valign; - int has_hspacing; - int hspacing; - int has_vspacing; - int vspacing; -} GenArrayjoinOpts; - -int gen_vips_arrayjoin(VipsImage **input, int input_n, VipsImage ** out_out, GenArrayjoinOpts *opts); - -int gen_vips_autorot(VipsImage * input, VipsImage ** out_out, int * out_angle, int * out_flip); - -int gen_vips_avg(VipsImage * input, double * out_out); - -int gen_vips_bandbool(VipsImage * input, VipsOperationBoolean boolean, VipsImage ** out_out); - -typedef struct { - int has_factor; - int factor; -} GenBandfoldOpts; - -int gen_vips_bandfold(VipsImage * input, VipsImage ** out_out, GenBandfoldOpts *opts); - -int gen_vips_bandjoin(VipsImage **input, int input_n, VipsImage ** out_out); - -int gen_vips_bandjoin_const(VipsImage * input, double * c, int c_n, VipsImage ** out_out); - -int gen_vips_bandmean(VipsImage * input, VipsImage ** out_out); - -typedef struct { - int has_index; - int index; -} GenBandrankOpts; - -int gen_vips_bandrank(VipsImage **input, int input_n, VipsImage ** out_out, GenBandrankOpts *opts); - -typedef struct { - int has_factor; - int factor; -} GenBandunfoldOpts; - -int gen_vips_bandunfold(VipsImage * input, VipsImage ** out_out, GenBandunfoldOpts *opts); - -typedef struct { - int has_bands; - int bands; -} GenBlackOpts; - -int gen_vips_black(int width, int height, VipsImage ** out_out, GenBlackOpts *opts); - -int gen_vips_boolean(VipsImage * left, VipsImage * right, VipsOperationBoolean boolean, VipsImage ** out_out); - -int gen_vips_boolean_const(VipsImage * input, VipsOperationBoolean boolean, double * c, int c_n, VipsImage ** out_out); - -int gen_vips_buildlut(VipsImage * input, VipsImage ** out_out); - -int gen_vips_byteswap(VipsImage * input, VipsImage ** out_out); - -typedef struct { - int has_maxTiles; - int maxTiles; - int has_tileHeight; - int tileHeight; - int has_tileWidth; - int tileWidth; -} GenCacheOpts; - -int gen_vips_cache(VipsImage * input, VipsImage ** out_out, GenCacheOpts *opts); - -typedef struct { - int has_sigma; - double sigma; - int has_precision; - VipsPrecision precision; -} GenCannyOpts; - -int gen_vips_canny(VipsImage * input, VipsImage ** out_out, GenCannyOpts *opts); - -typedef struct { - int has_shift; - int shift; -} GenCastOpts; - -int gen_vips_cast(VipsImage * input, VipsBandFormat format, VipsImage ** out_out, GenCastOpts *opts); - -typedef struct { - int has_min; - double min; - int has_max; - double max; -} GenClampOpts; - -int gen_vips_clamp(VipsImage * input, VipsImage ** out_out, GenClampOpts *opts); - -typedef struct { - int has_times; - int times; - int has_angle; - VipsAngle45 angle; - int has_combine; - VipsCombine combine; - int has_precision; - VipsPrecision precision; - int has_layers; - int layers; - int has_cluster; - int cluster; -} GenCompassOpts; - -int gen_vips_compass(VipsImage * input, VipsImage * mask, VipsImage ** out_out, GenCompassOpts *opts); - -int gen_vips_complex(VipsImage * input, VipsOperationComplex cmplx, VipsImage ** out_out); - -int gen_vips_complex2(VipsImage * left, VipsImage * right, VipsOperationComplex2 cmplx, VipsImage ** out_out); - -int gen_vips_complexform(VipsImage * left, VipsImage * right, VipsImage ** out_out); - -int gen_vips_complexget(VipsImage * input, VipsOperationComplexget get, VipsImage ** out_out); - -typedef struct { - int has_x; - int x; - int has_y; - int y; - int has_compositingSpace; - VipsInterpretation compositingSpace; - int has_premultiplied; - int premultiplied; -} GenComposite2Opts; - -int gen_vips_composite2(VipsImage * base, VipsImage * overlay, VipsBlendMode mode, VipsImage ** out_out, GenComposite2Opts *opts); - -typedef struct { - int has_precision; - VipsPrecision precision; - int has_layers; - int layers; - int has_cluster; - int cluster; -} GenConvOpts; - -int gen_vips_conv(VipsImage * input, VipsImage * mask, VipsImage ** out_out, GenConvOpts *opts); - -typedef struct { - int has_layers; - int layers; - int has_cluster; - int cluster; -} GenConvaOpts; - -int gen_vips_conva(VipsImage * input, VipsImage * mask, VipsImage ** out_out, GenConvaOpts *opts); - -typedef struct { - int has_layers; - int layers; -} GenConvasepOpts; - -int gen_vips_convasep(VipsImage * input, VipsImage * mask, VipsImage ** out_out, GenConvasepOpts *opts); - -int gen_vips_convf(VipsImage * input, VipsImage * mask, VipsImage ** out_out); - -int gen_vips_convi(VipsImage * input, VipsImage * mask, VipsImage ** out_out); - -typedef struct { - int has_precision; - VipsPrecision precision; - int has_layers; - int layers; - int has_cluster; - int cluster; -} GenConvsepOpts; - -int gen_vips_convsep(VipsImage * input, VipsImage * mask, VipsImage ** out_out, GenConvsepOpts *opts); - -typedef struct { - int has_width; - int width; - int has_height; - int height; - int has_bands; - int bands; - int has_format; - VipsBandFormat format; - int has_coding; - VipsCoding coding; - int has_interpretation; - VipsInterpretation interpretation; - int has_xres; - double xres; - int has_yres; - double yres; - int has_xoffset; - int xoffset; - int has_yoffset; - int yoffset; -} GenCopyOpts; - -int gen_vips_copy(VipsImage * input, VipsImage ** out_out, GenCopyOpts *opts); - -int gen_vips_countlines(VipsImage * input, VipsDirection direction, double * out_nolines); - -int gen_vips_dE00(VipsImage * left, VipsImage * right, VipsImage ** out_out); - -int gen_vips_dE76(VipsImage * left, VipsImage * right, VipsImage ** out_out); - -int gen_vips_dECMC(VipsImage * left, VipsImage * right, VipsImage ** out_out); - -int gen_vips_deviate(VipsImage * input, double * out_out); - -int gen_vips_divide(VipsImage * left, VipsImage * right, VipsImage ** out_out); - -int gen_vips_extract_area(VipsImage * input, int left, int top, int width, int height, VipsImage ** out_out); - -typedef struct { - int has_n; - int n; -} GenExtractBandOpts; - -int gen_vips_extract_band(VipsImage * input, int band, VipsImage ** out_out, GenExtractBandOpts *opts); - -typedef struct { - int has_uchar; - int uchar; - int has_factor; - double factor; -} GenEyeOpts; - -int gen_vips_eye(int width, int height, VipsImage ** out_out, GenEyeOpts *opts); - -int gen_vips_falsecolour(VipsImage * input, VipsImage ** out_out); - -int gen_vips_fastcor(VipsImage * input, VipsImage * ref, VipsImage ** out_out); - -int gen_vips_fill_nearest(VipsImage * input, VipsImage ** out_out, VipsImage ** out_distance); - -typedef struct { - int has_background; - double *background; int background_n; - int has_maxAlpha; - double maxAlpha; -} GenFlattenOpts; - -int gen_vips_flatten(VipsImage * input, VipsImage ** out_out, GenFlattenOpts *opts); - -int gen_vips_flip(VipsImage * input, VipsDirection direction, VipsImage ** out_out); - -int gen_vips_float2rad(VipsImage * input, VipsImage ** out_out); - -int gen_vips_fractsurf(int width, int height, double fractalDimension, VipsImage ** out_out); - -int gen_vips_freqmult(VipsImage * input, VipsImage * mask, VipsImage ** out_out); - -int gen_vips_fwfft(VipsImage * input, VipsImage ** out_out); - -typedef struct { - int has_exponent; - double exponent; -} GenGammaOpts; - -int gen_vips_gamma(VipsImage * input, VipsImage ** out_out, GenGammaOpts *opts); - -typedef struct { - int has_minAmpl; - double minAmpl; - int has_precision; - VipsPrecision precision; -} GenGaussblurOpts; - -int gen_vips_gaussblur(VipsImage * input, double sigma, VipsImage ** out_out, GenGaussblurOpts *opts); - -typedef struct { - int has_separable; - int separable; - int has_precision; - VipsPrecision precision; -} GenGaussmatOpts; - -int gen_vips_gaussmat(double sigma, double minAmpl, VipsImage ** out_out, GenGaussmatOpts *opts); - -typedef struct { - int has_sigma; - double sigma; - int has_mean; - double mean; - int has_seed; - int seed; -} GenGaussnoiseOpts; - -int gen_vips_gaussnoise(int width, int height, VipsImage ** out_out, GenGaussnoiseOpts *opts); - -typedef struct { - int has_gamma; - double gamma; - int has_intOutput; - int intOutput; -} GenGlobalbalanceOpts; - -int gen_vips_globalbalance(VipsImage * input, VipsImage ** out_out, GenGlobalbalanceOpts *opts); - -typedef struct { - int has_extend; - VipsExtend extend; - int has_background; - double *background; int background_n; -} GenGravityOpts; - -int gen_vips_gravity(VipsImage * input, VipsCompassDirection direction, int width, int height, VipsImage ** out_out, GenGravityOpts *opts); - -typedef struct { - int has_uchar; - int uchar; -} GenGreyOpts; - -int gen_vips_grey(int width, int height, VipsImage ** out_out, GenGreyOpts *opts); - -int gen_vips_grid(VipsImage * input, int tileHeight, int across, int down, VipsImage ** out_out); - -int gen_vips_hist_cum(VipsImage * input, VipsImage ** out_out); - -int gen_vips_hist_entropy(VipsImage * input, double * out_out); - -typedef struct { - int has_band; - int band; -} GenHistEqualOpts; - -int gen_vips_hist_equal(VipsImage * input, VipsImage ** out_out, GenHistEqualOpts *opts); - -typedef struct { - int has_band; - int band; -} GenHistFindOpts; - -int gen_vips_hist_find(VipsImage * input, VipsImage ** out_out, GenHistFindOpts *opts); - -typedef struct { - int has_combine; - VipsCombine combine; -} GenHistFindIndexedOpts; - -int gen_vips_hist_find_indexed(VipsImage * input, VipsImage * index, VipsImage ** out_out, GenHistFindIndexedOpts *opts); - -typedef struct { - int has_bins; - int bins; -} GenHistFindNdimOpts; - -int gen_vips_hist_find_ndim(VipsImage * input, VipsImage ** out_out, GenHistFindNdimOpts *opts); - -int gen_vips_hist_ismonotonic(VipsImage * input, int * out_monotonic); - -typedef struct { - int has_maxSlope; - int maxSlope; -} GenHistLocalOpts; - -int gen_vips_hist_local(VipsImage * input, int width, int height, VipsImage ** out_out, GenHistLocalOpts *opts); - -int gen_vips_hist_match(VipsImage * input, VipsImage * ref, VipsImage ** out_out); - -int gen_vips_hist_norm(VipsImage * input, VipsImage ** out_out); - -int gen_vips_hist_plot(VipsImage * input, VipsImage ** out_out); - -typedef struct { - int has_scale; - int scale; - int has_minRadius; - int minRadius; - int has_maxRadius; - int maxRadius; -} GenHoughCircleOpts; - -int gen_vips_hough_circle(VipsImage * input, VipsImage ** out_out, GenHoughCircleOpts *opts); - -typedef struct { - int has_width; - int width; - int has_height; - int height; -} GenHoughLineOpts; - -int gen_vips_hough_line(VipsImage * input, VipsImage ** out_out, GenHoughLineOpts *opts); - -typedef struct { - int has_pcs; - VipsPCS pcs; - int has_intent; - VipsIntent intent; - int has_blackPointCompensation; - int blackPointCompensation; - int has_outputProfile; - const char *outputProfile; - int has_depth; - int depth; -} GenIccExportOpts; - -int gen_vips_icc_export(VipsImage * input, VipsImage ** out_out, GenIccExportOpts *opts); - -typedef struct { - int has_pcs; - VipsPCS pcs; - int has_intent; - VipsIntent intent; - int has_blackPointCompensation; - int blackPointCompensation; - int has_embedded; - int embedded; - int has_inputProfile; - const char *inputProfile; -} GenIccImportOpts; - -int gen_vips_icc_import(VipsImage * input, VipsImage ** out_out, GenIccImportOpts *opts); - -typedef struct { - int has_bands; - int bands; - int has_ushort; - int ushort; - int has_size; - int size; -} GenIdentityOpts; - -int gen_vips_identity(VipsImage ** out_out, GenIdentityOpts *opts); - -typedef struct { - int has_blend; - int blend; -} GenIfthenelseOpts; - -int gen_vips_ifthenelse(VipsImage * cond, VipsImage * in1, VipsImage * in2, VipsImage ** out_out, GenIfthenelseOpts *opts); - -typedef struct { - int has_expand; - int expand; - int has_background; - double *background; int background_n; -} GenInsertOpts; - -int gen_vips_insert(VipsImage * main, VipsImage * sub, int x, int y, VipsImage ** out_out, GenInsertOpts *opts); - -int gen_vips_invert(VipsImage * input, VipsImage ** out_out); - -typedef struct { - int has_size; - int size; -} GenInvertlutOpts; - -int gen_vips_invertlut(VipsImage * input, VipsImage ** out_out, GenInvertlutOpts *opts); - -typedef struct { - int has_real; - int real; -} GenInvfftOpts; - -int gen_vips_invfft(VipsImage * input, VipsImage ** out_out, GenInvfftOpts *opts); - -typedef struct { - int has_expand; - int expand; - int has_shim; - int shim; - int has_background; - double *background; int background_n; - int has_align; - VipsAlign align; -} GenJoinOpts; - -int gen_vips_join(VipsImage * in1, VipsImage * in2, VipsDirection direction, VipsImage ** out_out, GenJoinOpts *opts); - -int gen_vips_labelregions(VipsImage * input, VipsImage ** out_mask, int * out_segments); - -typedef struct { - int has_uchar; - int uchar; -} GenLinearOpts; - -int gen_vips_linear(VipsImage * input, double * a, int a_n, double * b, int b_n, VipsImage ** out_out, GenLinearOpts *opts); - -typedef struct { - int has_tileHeight; - int tileHeight; - int has_access; - VipsAccess access; - int has_threaded; - int threaded; - int has_persistent; - int persistent; -} GenLinecacheOpts; - -int gen_vips_linecache(VipsImage * input, VipsImage ** out_out, GenLinecacheOpts *opts); - -typedef struct { - int has_separable; - int separable; - int has_precision; - VipsPrecision precision; -} GenLogmatOpts; - -int gen_vips_logmat(double sigma, double minAmpl, VipsImage ** out_out, GenLogmatOpts *opts); - -typedef struct { - int has_interpolate; - VipsInterpolate *interpolate; - int has_background; - double *background; int background_n; - int has_premultiplied; - int premultiplied; - int has_extend; - VipsExtend extend; -} GenMapimOpts; - -int gen_vips_mapim(VipsImage * input, VipsImage * index, VipsImage ** out_out, GenMapimOpts *opts); - -typedef struct { - int has_band; - int band; -} GenMaplutOpts; - -int gen_vips_maplut(VipsImage * input, VipsImage * lut, VipsImage ** out_out, GenMaplutOpts *opts); - -typedef struct { - int has_uchar; - int uchar; - int has_nodc; - int nodc; - int has_reject; - int reject; - int has_optical; - int optical; -} GenMaskButterworthOpts; - -int gen_vips_mask_butterworth(int width, int height, double order, double frequencyCutoff, double amplitudeCutoff, VipsImage ** out_out, GenMaskButterworthOpts *opts); - -typedef struct { - int has_uchar; - int uchar; - int has_nodc; - int nodc; - int has_reject; - int reject; - int has_optical; - int optical; -} GenMaskButterworthBandOpts; - -int gen_vips_mask_butterworth_band(int width, int height, double order, double frequencyCutoffX, double frequencyCutoffY, double radius, double amplitudeCutoff, VipsImage ** out_out, GenMaskButterworthBandOpts *opts); - -typedef struct { - int has_uchar; - int uchar; - int has_nodc; - int nodc; - int has_reject; - int reject; - int has_optical; - int optical; -} GenMaskButterworthRingOpts; - -int gen_vips_mask_butterworth_ring(int width, int height, double order, double frequencyCutoff, double amplitudeCutoff, double ringwidth, VipsImage ** out_out, GenMaskButterworthRingOpts *opts); - -typedef struct { - int has_uchar; - int uchar; - int has_nodc; - int nodc; - int has_reject; - int reject; - int has_optical; - int optical; -} GenMaskFractalOpts; - -int gen_vips_mask_fractal(int width, int height, double fractalDimension, VipsImage ** out_out, GenMaskFractalOpts *opts); - -typedef struct { - int has_uchar; - int uchar; - int has_nodc; - int nodc; - int has_reject; - int reject; - int has_optical; - int optical; -} GenMaskGaussianOpts; - -int gen_vips_mask_gaussian(int width, int height, double frequencyCutoff, double amplitudeCutoff, VipsImage ** out_out, GenMaskGaussianOpts *opts); - -typedef struct { - int has_uchar; - int uchar; - int has_nodc; - int nodc; - int has_reject; - int reject; - int has_optical; - int optical; -} GenMaskGaussianBandOpts; - -int gen_vips_mask_gaussian_band(int width, int height, double frequencyCutoffX, double frequencyCutoffY, double radius, double amplitudeCutoff, VipsImage ** out_out, GenMaskGaussianBandOpts *opts); - -typedef struct { - int has_uchar; - int uchar; - int has_nodc; - int nodc; - int has_reject; - int reject; - int has_optical; - int optical; -} GenMaskGaussianRingOpts; - -int gen_vips_mask_gaussian_ring(int width, int height, double frequencyCutoff, double amplitudeCutoff, double ringwidth, VipsImage ** out_out, GenMaskGaussianRingOpts *opts); - -typedef struct { - int has_uchar; - int uchar; - int has_nodc; - int nodc; - int has_reject; - int reject; - int has_optical; - int optical; -} GenMaskIdealOpts; - -int gen_vips_mask_ideal(int width, int height, double frequencyCutoff, VipsImage ** out_out, GenMaskIdealOpts *opts); - -typedef struct { - int has_uchar; - int uchar; - int has_nodc; - int nodc; - int has_reject; - int reject; - int has_optical; - int optical; -} GenMaskIdealBandOpts; - -int gen_vips_mask_ideal_band(int width, int height, double frequencyCutoffX, double frequencyCutoffY, double radius, VipsImage ** out_out, GenMaskIdealBandOpts *opts); - -typedef struct { - int has_uchar; - int uchar; - int has_nodc; - int nodc; - int has_reject; - int reject; - int has_optical; - int optical; -} GenMaskIdealRingOpts; - -int gen_vips_mask_ideal_ring(int width, int height, double frequencyCutoff, double ringwidth, VipsImage ** out_out, GenMaskIdealRingOpts *opts); - -typedef struct { - int has_hwindow; - int hwindow; - int has_harea; - int harea; - int has_search; - int search; - int has_interpolate; - VipsInterpolate *interpolate; -} GenMatchOpts; - -int gen_vips_match(VipsImage * ref, VipsImage * sec, int xr1, int yr1, int xs1, int ys1, int xr2, int yr2, int xs2, int ys2, VipsImage ** out_out, GenMatchOpts *opts); - -int gen_vips_math(VipsImage * input, VipsOperationMath math, VipsImage ** out_out); - -int gen_vips_math2(VipsImage * left, VipsImage * right, VipsOperationMath2 math2, VipsImage ** out_out); - -int gen_vips_math2_const(VipsImage * input, VipsOperationMath2 math2, double * c, int c_n, VipsImage ** out_out); - -int gen_vips_matrixinvert(VipsImage * input, VipsImage ** out_out); - -int gen_vips_matrixmultiply(VipsImage * left, VipsImage * right, VipsImage ** out_out); - -int gen_vips_maxpair(VipsImage * left, VipsImage * right, VipsImage ** out_out); - -typedef struct { - int has_mblend; - int mblend; -} GenMergeOpts; - -int gen_vips_merge(VipsImage * ref, VipsImage * sec, VipsDirection direction, int dx, int dy, VipsImage ** out_out, GenMergeOpts *opts); - -int gen_vips_minpair(VipsImage * left, VipsImage * right, VipsImage ** out_out); - -int gen_vips_morph(VipsImage * input, VipsImage * mask, VipsOperationMorphology morph, VipsImage ** out_out); - -typedef struct { - int has_hwindow; - int hwindow; - int has_harea; - int harea; - int has_mblend; - int mblend; - int has_bandno; - int bandno; -} GenMosaicOpts; - -int gen_vips_mosaic(VipsImage * ref, VipsImage * sec, VipsDirection direction, int xref, int yref, int xsec, int ysec, VipsImage ** out_out, int * out_dx0, int * out_dy0, double * out_scale1, double * out_angle1, double * out_dy1, double * out_dx1, GenMosaicOpts *opts); - -typedef struct { - int has_hwindow; - int hwindow; - int has_harea; - int harea; - int has_search; - int search; - int has_interpolate; - VipsInterpolate *interpolate; - int has_mblend; - int mblend; -} GenMosaic1Opts; - -int gen_vips_mosaic1(VipsImage * ref, VipsImage * sec, VipsDirection direction, int xr1, int yr1, int xs1, int ys1, int xr2, int yr2, int xs2, int ys2, VipsImage ** out_out, GenMosaic1Opts *opts); - -typedef struct { - int has_band; - int band; -} GenMsbOpts; - -int gen_vips_msb(VipsImage * input, VipsImage ** out_out, GenMsbOpts *opts); - -int gen_vips_multiply(VipsImage * left, VipsImage * right, VipsImage ** out_out); - -int gen_vips_percent(VipsImage * input, double percent, int * out_threshold); - -typedef struct { - int has_cellSize; - int cellSize; - int has_uchar; - int uchar; - int has_seed; - int seed; -} GenPerlinOpts; - -int gen_vips_perlin(int width, int height, VipsImage ** out_out, GenPerlinOpts *opts); - -int gen_vips_phasecor(VipsImage * input, VipsImage * in2, VipsImage ** out_out); - -typedef struct { - int has_maxAlpha; - double maxAlpha; -} GenPremultiplyOpts; - -int gen_vips_premultiply(VipsImage * input, VipsImage ** out_out, GenPremultiplyOpts *opts); - -int gen_vips_prewitt(VipsImage * input, VipsImage ** out_out); - -int gen_vips_profile(VipsImage * input, VipsImage ** out_columns, VipsImage ** out_rows); - -int gen_vips_project(VipsImage * input, VipsImage ** out_columns, VipsImage ** out_rows); - -typedef struct { - int has_interpolate; - VipsInterpolate *interpolate; -} GenQuadraticOpts; - -int gen_vips_quadratic(VipsImage * input, VipsImage * coeff, VipsImage ** out_out, GenQuadraticOpts *opts); - -int gen_vips_rad2float(VipsImage * input, VipsImage ** out_out); - -int gen_vips_rank(VipsImage * input, int width, int height, int index, VipsImage ** out_out); - -int gen_vips_recomb(VipsImage * input, VipsImage * m, VipsImage ** out_out); - -typedef struct { - int has_kernel; - VipsKernel kernel; - int has_gap; - double gap; -} GenReduceOpts; - -int gen_vips_reduce(VipsImage * input, double hshrink, double vshrink, VipsImage ** out_out, GenReduceOpts *opts); - -typedef struct { - int has_kernel; - VipsKernel kernel; - int has_gap; - double gap; -} GenReducehOpts; - -int gen_vips_reduceh(VipsImage * input, double hshrink, VipsImage ** out_out, GenReducehOpts *opts); - -typedef struct { - int has_kernel; - VipsKernel kernel; - int has_gap; - double gap; -} GenReducevOpts; - -int gen_vips_reducev(VipsImage * input, double vshrink, VipsImage ** out_out, GenReducevOpts *opts); - -int gen_vips_relational(VipsImage * left, VipsImage * right, VipsOperationRelational relational, VipsImage ** out_out); - -int gen_vips_relational_const(VipsImage * input, VipsOperationRelational relational, double * c, int c_n, VipsImage ** out_out); - -int gen_vips_remainder(VipsImage * left, VipsImage * right, VipsImage ** out_out); - -int gen_vips_remainder_const(VipsImage * input, double * c, int c_n, VipsImage ** out_out); - -int gen_vips_remosaic(VipsImage * input, const char * oldStr, const char * newStr, VipsImage ** out_out); - -int gen_vips_replicate(VipsImage * input, int across, int down, VipsImage ** out_out); - -int gen_vips_rot(VipsImage * input, VipsAngle angle, VipsImage ** out_out); - -typedef struct { - int has_angle; - VipsAngle45 angle; -} GenRot45Opts; - -int gen_vips_rot45(VipsImage * input, VipsImage ** out_out, GenRot45Opts *opts); - -typedef struct { - int has_interpolate; - VipsInterpolate *interpolate; - int has_background; - double *background; int background_n; - int has_odx; - double odx; - int has_ody; - double ody; - int has_idx; - double idx; - int has_idy; - double idy; -} GenRotateOpts; - -int gen_vips_rotate(VipsImage * input, double angle, VipsImage ** out_out, GenRotateOpts *opts); - -int gen_vips_round(VipsImage * input, VipsOperationRound round, VipsImage ** out_out); - -int gen_vips_sRGB2HSV(VipsImage * input, VipsImage ** out_out); - -int gen_vips_sRGB2scRGB(VipsImage * input, VipsImage ** out_out); - -typedef struct { - int has_depth; - int depth; -} GenScRGB2BWOpts; - -int gen_vips_scRGB2BW(VipsImage * input, VipsImage ** out_out, GenScRGB2BWOpts *opts); - -int gen_vips_scRGB2XYZ(VipsImage * input, VipsImage ** out_out); - -typedef struct { - int has_depth; - int depth; -} GenScRGB2sRGBOpts; - -int gen_vips_scRGB2sRGB(VipsImage * input, VipsImage ** out_out, GenScRGB2sRGBOpts *opts); - -typedef struct { - int has_exp; - double exp; - int has_log; - int log; -} GenScaleOpts; - -int gen_vips_scale(VipsImage * input, VipsImage ** out_out, GenScaleOpts *opts); - -int gen_vips_scharr(VipsImage * input, VipsImage ** out_out); - -typedef struct { - int has_tileHeight; - int tileHeight; -} GenSequentialOpts; - -int gen_vips_sequential(VipsImage * input, VipsImage ** out_out, GenSequentialOpts *opts); - -typedef struct { - int has_sigma; - double sigma; - int has_x1; - double x1; - int has_y2; - double y2; - int has_y3; - double y3; - int has_m1; - double m1; - int has_m2; - double m2; -} GenSharpenOpts; - -int gen_vips_sharpen(VipsImage * input, VipsImage ** out_out, GenSharpenOpts *opts); - -typedef struct { - int has_ceil; - int ceil; -} GenShrinkOpts; - -int gen_vips_shrink(VipsImage * input, double hshrink, double vshrink, VipsImage ** out_out, GenShrinkOpts *opts); - -typedef struct { - int has_ceil; - int ceil; -} GenShrinkhOpts; - -int gen_vips_shrinkh(VipsImage * input, int hshrink, VipsImage ** out_out, GenShrinkhOpts *opts); - -typedef struct { - int has_ceil; - int ceil; -} GenShrinkvOpts; - -int gen_vips_shrinkv(VipsImage * input, int vshrink, VipsImage ** out_out, GenShrinkvOpts *opts); - -int gen_vips_sign(VipsImage * input, VipsImage ** out_out); - -typedef struct { - int has_scale; - double scale; - int has_angle; - double angle; - int has_interpolate; - VipsInterpolate *interpolate; - int has_background; - double *background; int background_n; - int has_odx; - double odx; - int has_ody; - double ody; - int has_idx; - double idx; - int has_idy; - double idy; -} GenSimilarityOpts; - -int gen_vips_similarity(VipsImage * input, VipsImage ** out_out, GenSimilarityOpts *opts); - -typedef struct { - int has_uchar; - int uchar; - int has_hfreq; - double hfreq; - int has_vfreq; - double vfreq; -} GenSinesOpts; - -int gen_vips_sines(int width, int height, VipsImage ** out_out, GenSinesOpts *opts); - -typedef struct { - int has_interesting; - VipsInteresting interesting; - int has_premultiplied; - int premultiplied; -} GenSmartcropOpts; - -int gen_vips_smartcrop(VipsImage * input, int width, int height, int * out_attentionX, VipsImage ** out_out, int * out_attentionY, GenSmartcropOpts *opts); - -int gen_vips_sobel(VipsImage * input, VipsImage ** out_out); - -int gen_vips_spcor(VipsImage * input, VipsImage * ref, VipsImage ** out_out); - -int gen_vips_spectrum(VipsImage * input, VipsImage ** out_out); - -int gen_vips_stats(VipsImage * input, VipsImage ** out_out); - -typedef struct { - int has_s0; - double s0; - int has_b; - double b; - int has_m0; - double m0; - int has_a; - double a; -} GenStdifOpts; - -int gen_vips_stdif(VipsImage * input, int width, int height, VipsImage ** out_out, GenStdifOpts *opts); - -typedef struct { - int has_point; - int point; -} GenSubsampleOpts; - -int gen_vips_subsample(VipsImage * input, int xfac, int yfac, VipsImage ** out_out, GenSubsampleOpts *opts); - -int gen_vips_subtract(VipsImage * left, VipsImage * right, VipsImage ** out_out); - -int gen_vips_sum(VipsImage **input, int input_n, VipsImage ** out_out); - -typedef struct { - int has_tileWidth; - int tileWidth; - int has_tileHeight; - int tileHeight; - int has_maxTiles; - int maxTiles; - int has_access; - VipsAccess access; - int has_threaded; - int threaded; - int has_persistent; - int persistent; -} GenTilecacheOpts; - -int gen_vips_tilecache(VipsImage * input, VipsImage ** out_out, GenTilecacheOpts *opts); - -typedef struct { - int has_inMax; - int inMax; - int has_outMax; - int outMax; - int has_Lb; - double Lb; - int has_Lw; - double Lw; - int has_Ps; - double Ps; - int has_Pm; - double Pm; - int has_Ph; - double Ph; - int has_S; - double S; - int has_M; - double M; - int has_H; - double H; -} GenTonelutOpts; - -int gen_vips_tonelut(VipsImage ** out_out, GenTonelutOpts *opts); - -typedef struct { - int has_pageHeight; - int pageHeight; -} GenTranspose3dOpts; - -int gen_vips_transpose3d(VipsImage * input, VipsImage ** out_out, GenTranspose3dOpts *opts); - -int gen_vips_uhdr2scRGB(VipsImage * input, VipsImage ** out_out); - -typedef struct { - int has_maxAlpha; - double maxAlpha; - int has_alphaBand; - int alphaBand; -} GenUnpremultiplyOpts; - -int gen_vips_unpremultiply(VipsImage * input, VipsImage ** out_out, GenUnpremultiplyOpts *opts); - -typedef struct { - int has_cellSize; - int cellSize; - int has_seed; - int seed; -} GenWorleyOpts; - -int gen_vips_worley(int width, int height, VipsImage ** out_out, GenWorleyOpts *opts); - -typedef struct { - int has_x; - int x; - int has_y; - int y; -} GenWrapOpts; - -int gen_vips_wrap(VipsImage * input, VipsImage ** out_out, GenWrapOpts *opts); - -typedef struct { - int has_csize; - int csize; - int has_dsize; - int dsize; - int has_esize; - int esize; -} GenXyzOpts; - -int gen_vips_xyz(int width, int height, VipsImage ** out_out, GenXyzOpts *opts); - -typedef struct { - int has_uchar; - int uchar; -} GenZoneOpts; - -int gen_vips_zone(int width, int height, VipsImage ** out_out, GenZoneOpts *opts); - -int gen_vips_zoom(VipsImage * input, int xfac, int yfac, VipsImage ** out_out); - -#endif diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/govips.c b/vendor/github.com/davidbyttow/govips/v2/vips/govips.c deleted file mode 100644 index 0b220b9ece..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/govips.c +++ /dev/null @@ -1,27 +0,0 @@ -#include "govips.h" - -static void govips_logging_handler(const gchar *log_domain, - GLogLevelFlags log_level, - const gchar *message, gpointer user_data) { - govipsLoggingHandler((char *)log_domain, (int)log_level, (char *)message); -} - -static void null_logging_handler(const gchar *log_domain, - GLogLevelFlags log_level, const gchar *message, - gpointer user_data) {} - -void vips_set_logging_handler(void) { - g_log_set_default_handler(govips_logging_handler, NULL); -} - -void vips_unset_logging_handler(void) { - g_log_set_default_handler(null_logging_handler, NULL); -} - -/* This function skips the Govips logging handler and logs - directly to stdout. To be used only for testing and debugging. - Needed for CI because of a Go macOS bug which doesn't clean cgo callbacks on - exit. */ -void vips_default_logging_handler(void) { - g_log_set_default_handler(g_log_default_handler, NULL); -} \ No newline at end of file diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/govips.go b/vendor/github.com/davidbyttow/govips/v2/vips/govips.go deleted file mode 100644 index 7a8409ddfb..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/govips.go +++ /dev/null @@ -1,299 +0,0 @@ -// Package vips provides go bindings for libvips, a fast image processing library. -package vips - -// #cgo pkg-config: vips -// #include -// #include "govips.h" -import "C" -import ( - "errors" - "fmt" - "os" - "runtime" - "strings" - "sync" - "sync/atomic" - "testing" -) - -const ( - defaultConcurrencyLevel = 1 - defaultMaxCacheMem = 50 * 1024 * 1024 - defaultMaxCacheSize = 100 - defaultMaxCacheFiles = 0 -) - -var ( - // Version is the full libvips version string (x.y.z) - Version = C.GoString(C.vips_version_string()) - - // MajorVersion is the libvips major component of the version string (x in x.y.z) - MajorVersion = int(C.vips_version(0)) - - // MinorVersion is the libvips minor component of the version string (y in x.y.z) - MinorVersion = int(C.vips_version(1)) - - // MicroVersion is the libvips micro component of the version string (z in x.y.z) - // Also known as patch version - MicroVersion = int(C.vips_version(2)) - - running = false - hasShutdown = false - initLock sync.Mutex - statCollectorDone chan struct{} - once sync.Once - typeLoaders = make(map[string]ImageType) - supportedImageTypes = make(map[ImageType]bool) -) - -// Config allows fine-tuning of libvips library -type Config struct { - ConcurrencyLevel int - MaxCacheFiles int - MaxCacheMem int - MaxCacheSize int - ReportLeaks bool - CacheTrace bool - CollectStats bool -} - -// Startup sets up the libvips support and ensures the versions are correct. Pass in nil for -// default configuration. -func Startup(config *Config) error { - if hasShutdown { - return errors.New("govips cannot be stopped and restarted") - } - - initLock.Lock() - defer initLock.Unlock() - - runtime.LockOSThread() - defer runtime.UnlockOSThread() - - if running { - govipsLog("govips", LogLevelInfo, "warning libvips already started") - return nil - } - - if MajorVersion < 8 { - return errors.New("govips requires libvips version 8.10+") - } - - if MajorVersion == 8 && MinorVersion < 10 { - return errors.New("govips requires libvips version 8.10+") - } - - cName := C.CString("govips") - defer freeCString(cName) - - // Initialize govips logging handler and verbosity filter to historical default - if !currentLoggingOverridden { - govipsLoggingSettings(nil, LogLevelInfo) - } - - // Override default glib logging handler to intercept logging messages - enableLogging() - - err := C.vips_init(cName) - if err != 0 { - return fmt.Errorf("failed to start vips code=%v", err) - } - - running = true - - if config != nil { - if config.CollectStats { - statCollectorDone = collectStats() - } - - C.vips_leak_set(toGboolean(config.ReportLeaks)) - - if config.ConcurrencyLevel >= 0 { - C.vips_concurrency_set(C.int(config.ConcurrencyLevel)) - } else { - C.vips_concurrency_set(defaultConcurrencyLevel) - } - - if config.MaxCacheFiles >= 0 { - C.vips_cache_set_max_files(C.int(config.MaxCacheFiles)) - } else { - C.vips_cache_set_max_files(defaultMaxCacheFiles) - } - - if config.MaxCacheMem >= 0 { - C.vips_cache_set_max_mem(C.size_t(config.MaxCacheMem)) - } else { - C.vips_cache_set_max_mem(defaultMaxCacheMem) - } - - if config.MaxCacheSize >= 0 { - C.vips_cache_set_max(C.int(config.MaxCacheSize)) - } else { - C.vips_cache_set_max(defaultMaxCacheSize) - } - - C.vips_cache_set_trace(toGboolean(config.CacheTrace)) - } else { - C.vips_concurrency_set(defaultConcurrencyLevel) - C.vips_cache_set_max(defaultMaxCacheSize) - C.vips_cache_set_max_mem(defaultMaxCacheMem) - C.vips_cache_set_max_files(defaultMaxCacheFiles) - C.vips_cache_set_trace(toGboolean(false)) - } - - govipsLog("govips", LogLevelInfo, fmt.Sprintf("vips %s started with concurrency=%d cache_max_files=%d cache_max_mem=%d cache_max=%d", - Version, - int(C.vips_concurrency_get()), - int(C.vips_cache_get_max_files()), - int(C.vips_cache_get_max_mem()), - int(C.vips_cache_get_max()))) - - initTypes() - return nil -} - -func enableLogging() { - C.vips_set_logging_handler() -} - -func disableLogging() { - C.vips_unset_logging_handler() -} - -// consoleLogging overrides the Govips logging handler and makes glib -// use its default logging handler which outputs everything to console. -// Needed for CI unit testing due to a macOS bug in Go (doesn't clean cgo callbacks on exit) -func consoleLogging() { - C.vips_default_logging_handler() -} - -// Shutdown libvips -func Shutdown() { - hasShutdown = true - - if statCollectorDone != nil { - statCollectorDone <- struct{}{} - } - - initLock.Lock() - defer initLock.Unlock() - - runtime.LockOSThread() - defer runtime.UnlockOSThread() - - if !running { - govipsLog("govips", LogLevelInfo, "warning libvips not started") - return - } - - if temporaryDirectory != "" { - os.RemoveAll(temporaryDirectory) - } - - C.vips_shutdown() - disableLogging() - running = false -} - -// ShutdownThread clears the cache for for the given thread. This needs to be -// called when a thread using vips exits. -func ShutdownThread() { - C.vips_thread_shutdown() -} - -// ClearCache drops the whole operation cache, handy for leak tracking. -func ClearCache() { - C.vips_cache_drop_all() -} - -// SetPipeReadLimit sets the maximum number of bytes libvips will buffer -// when loading from a non-seekable source (a reader without io.Seeker -// passed to LoadImageFromReader). The default is approximately 1 GB. -// Callers processing large non-seekable streams can lower this to bound -// memory usage. -// -// Must be called before any streaming load operations. -func SetPipeReadLimit(bytes int64) { - C.vips_pipe_read_limit_set(C.gint64(bytes)) -} - -// PrintCache prints the whole operation cache to stdout for debugging purposes. -func PrintCache() { - C.vips_cache_print() -} - -// PrintObjectReport outputs all of the current internal objects in libvips -func PrintObjectReport(label string) { - govipsLog("govips", LogLevelInfo, fmt.Sprintf("\n=======================================\nvips live objects: %s...\n", label)) - C.vips_object_print_all() - govipsLog("govips", LogLevelInfo, "=======================================\n\n") -} - -// MemoryStats is a data structure that houses various memory statistics from ReadVipsMemStats() -type MemoryStats struct { - Mem int64 - MemHigh int64 - Files int64 - Allocs int64 -} - -var openImageRefs atomic.Int64 - -// OpenImageRefs returns the number of ImageRef instances that haven't been closed. -func OpenImageRefs() int64 { - return openImageRefs.Load() -} - -// AssertNoLeaks fails the test if any ImageRef instances remain open. -// Call this at the end of tests to catch leaked images. -func AssertNoLeaks(t testing.TB) { - t.Helper() - n := openImageRefs.Load() - if n != 0 { - t.Errorf("govips: %d ImageRef(s) not closed (leaked)", n) - } -} - -// ReadVipsMemStats returns various memory statistics such as allocated memory and open files. -func ReadVipsMemStats(stats *MemoryStats) { - stats.Mem = int64(C.vips_tracked_get_mem()) - stats.MemHigh = int64(C.vips_tracked_get_mem_highwater()) - stats.Allocs = int64(C.vips_tracked_get_allocs()) - stats.Files = int64(C.vips_tracked_get_files()) -} - -func startupIfNeeded() error { - if !running { - govipsLog("govips", LogLevelInfo, "libvips was forcibly started automatically, consider calling Startup/Shutdown yourself") - if err := Startup(nil); err != nil { - return err - } - } - return nil -} - -// InitTypes initializes caches and figures out which image types are supported -func initTypes() { - once.Do(func() { - cType := C.CString("VipsOperation") - defer freeCString(cType) - - for k, v := range ImageTypes { - name := strings.ToLower("VipsForeignLoad" + v) - typeLoaders[name] = k - typeLoaders[name+"buffer"] = k - - cFunc := C.CString(v + "load") - //noinspection GoDeferInLoop - defer freeCString(cFunc) - - ret := C.vips_type_find(cType, cFunc) - - supportedImageTypes[k] = int(ret) != 0 - - if supportedImageTypes[k] { - govipsLog("govips", LogLevelInfo, fmt.Sprintf("registered image type loader type=%s", v)) - } - } - }) -} diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/govips.h b/vendor/github.com/davidbyttow/govips/v2/vips/govips.h deleted file mode 100644 index 31f42b04c6..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/govips.h +++ /dev/null @@ -1,26 +0,0 @@ - -// clang-format off -// include order matters -#include -#include -#include -// clang-format on - -#if (VIPS_MAJOR_VERSION < 8) -error_requires_version_8 -#endif - - extern void - govipsLoggingHandler(char *log_domain, int log_level, char *message); - -static void govips_logging_handler(const gchar *log_domain, - GLogLevelFlags log_level, - const gchar *message, gpointer user_data); - -static void null_logging_handler(const gchar *log_domain, - GLogLevelFlags log_level, const gchar *message, - gpointer user_data); - -void vips_set_logging_handler(void); -void vips_unset_logging_handler(void); -void vips_default_logging_handler(void); \ No newline at end of file diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/icc_profiles.go b/vendor/github.com/davidbyttow/govips/v2/vips/icc_profiles.go deleted file mode 100644 index 8d5c55fb00..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/icc_profiles.go +++ /dev/null @@ -1,724 +0,0 @@ -package vips - -import ( - "os" - "path/filepath" - "sync" -) - -var ( - // ATTRIBUTION: - // The following micro icc profile taken from: https://github.com/saucecontrol/Compact-ICC-Profiles. - // Read more (very interesting): https://photosauce.net/blog/post/making-a-minimal-srgb-icc-profile-part-1-trim-the-fat-abuse-the-spec - sRGBV2MicroICCProfile = []byte{ - 0x00, 0x00, 0x01, 0xc8, 0x6c, 0x63, 0x6d, 0x73, 0x02, 0x10, 0x00, 0x00, - 0x6d, 0x6e, 0x74, 0x72, 0x52, 0x47, 0x42, 0x20, 0x58, 0x59, 0x5a, 0x20, - 0x07, 0xe2, 0x00, 0x03, 0x00, 0x14, 0x00, 0x09, 0x00, 0x0e, 0x00, 0x1d, - 0x61, 0x63, 0x73, 0x70, 0x4d, 0x53, 0x46, 0x54, 0x00, 0x00, 0x00, 0x00, - 0x73, 0x61, 0x77, 0x73, 0x63, 0x74, 0x72, 0x6c, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xd6, - 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d, 0x68, 0x61, 0x6e, 0x64, - 0x9d, 0x91, 0x00, 0x3d, 0x40, 0x80, 0xb0, 0x3d, 0x40, 0x74, 0x2c, 0x81, - 0x9e, 0xa5, 0x22, 0x8e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, - 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x5f, - 0x63, 0x70, 0x72, 0x74, 0x00, 0x00, 0x01, 0x0c, 0x00, 0x00, 0x00, 0x0c, - 0x77, 0x74, 0x70, 0x74, 0x00, 0x00, 0x01, 0x18, 0x00, 0x00, 0x00, 0x14, - 0x72, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x01, 0x2c, 0x00, 0x00, 0x00, 0x14, - 0x67, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x14, - 0x62, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x01, 0x54, 0x00, 0x00, 0x00, 0x14, - 0x72, 0x54, 0x52, 0x43, 0x00, 0x00, 0x01, 0x68, 0x00, 0x00, 0x00, 0x60, - 0x67, 0x54, 0x52, 0x43, 0x00, 0x00, 0x01, 0x68, 0x00, 0x00, 0x00, 0x60, - 0x62, 0x54, 0x52, 0x43, 0x00, 0x00, 0x01, 0x68, 0x00, 0x00, 0x00, 0x60, - 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, - 0x75, 0x52, 0x47, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x74, 0x65, 0x78, 0x74, 0x00, 0x00, 0x00, 0x00, - 0x43, 0x43, 0x30, 0x00, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xf3, 0x54, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x16, 0xc9, - 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6f, 0xa0, - 0x00, 0x00, 0x38, 0xf2, 0x00, 0x00, 0x03, 0x8f, 0x58, 0x59, 0x5a, 0x20, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x96, 0x00, 0x00, 0xb7, 0x89, - 0x00, 0x00, 0x18, 0xda, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x24, 0xa0, 0x00, 0x00, 0x0f, 0x85, 0x00, 0x00, 0xb6, 0xc4, - 0x63, 0x75, 0x72, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, - 0x00, 0x00, 0x00, 0x7c, 0x00, 0xf8, 0x01, 0x9c, 0x02, 0x75, 0x03, 0x83, - 0x04, 0xc9, 0x06, 0x4e, 0x08, 0x12, 0x0a, 0x18, 0x0c, 0x62, 0x0e, 0xf4, - 0x11, 0xcf, 0x14, 0xf6, 0x18, 0x6a, 0x1c, 0x2e, 0x20, 0x43, 0x24, 0xac, - 0x29, 0x6a, 0x2e, 0x7e, 0x33, 0xeb, 0x39, 0xb3, 0x3f, 0xd6, 0x46, 0x57, - 0x4d, 0x36, 0x54, 0x76, 0x5c, 0x17, 0x64, 0x1d, 0x6c, 0x86, 0x75, 0x56, - 0x7e, 0x8d, 0x88, 0x2c, 0x92, 0x36, 0x9c, 0xab, 0xa7, 0x8c, 0xb2, 0xdb, - 0xbe, 0x99, 0xca, 0xc7, 0xd7, 0x65, 0xe4, 0x77, 0xf1, 0xf9, 0xff, 0xff, - } - - // ATTRIBUTION: - // The following micro icc profile taken from: https://github.com/saucecontrol/Compact-ICC-Profiles. - // Read more (very interesting): https://photosauce.net/blog/post/making-a-minimal-srgb-icc-profile-part-1-trim-the-fat-abuse-the-spec - sGrayV2MicroICCProfile = []byte{ - 0x00, 0x00, 0x01, 0x50, 0x6c, 0x63, 0x6d, 0x73, 0x02, 0x10, 0x00, 0x00, - 0x6d, 0x6e, 0x74, 0x72, 0x47, 0x52, 0x41, 0x59, 0x58, 0x59, 0x5a, 0x20, - 0x07, 0xe2, 0x00, 0x03, 0x00, 0x14, 0x00, 0x09, 0x00, 0x0e, 0x00, 0x1d, - 0x61, 0x63, 0x73, 0x70, 0x4d, 0x53, 0x46, 0x54, 0x00, 0x00, 0x00, 0x00, - 0x73, 0x61, 0x77, 0x73, 0x63, 0x74, 0x72, 0x6c, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xd6, - 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d, 0x68, 0x61, 0x6e, 0x64, - 0x05, 0xd2, 0x02, 0xa7, 0xf9, 0xdd, 0x47, 0x94, 0xc7, 0x4f, 0x4c, 0x5f, - 0x26, 0x82, 0x3a, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, - 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x00, 0xb4, 0x00, 0x00, 0x00, 0x5f, - 0x63, 0x70, 0x72, 0x74, 0x00, 0x00, 0x00, 0xd0, 0x00, 0x00, 0x00, 0x0c, - 0x77, 0x74, 0x70, 0x74, 0x00, 0x00, 0x00, 0xdc, 0x00, 0x00, 0x00, 0x14, - 0x6b, 0x54, 0x52, 0x43, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x60, - 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, - 0x75, 0x47, 0x72, 0x79, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x74, 0x65, 0x78, 0x74, 0x00, 0x00, 0x00, 0x00, - 0x43, 0x43, 0x30, 0x00, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xf3, 0x54, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x16, 0xc9, - 0x63, 0x75, 0x72, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, - 0x00, 0x00, 0x00, 0x7c, 0x00, 0xf8, 0x01, 0x9c, 0x02, 0x75, 0x03, 0x83, - 0x04, 0xc9, 0x06, 0x4e, 0x08, 0x12, 0x0a, 0x18, 0x0c, 0x62, 0x0e, 0xf4, - 0x11, 0xcf, 0x14, 0xf6, 0x18, 0x6a, 0x1c, 0x2e, 0x20, 0x43, 0x24, 0xac, - 0x29, 0x6a, 0x2e, 0x7e, 0x33, 0xeb, 0x39, 0xb3, 0x3f, 0xd6, 0x46, 0x57, - 0x4d, 0x36, 0x54, 0x76, 0x5c, 0x17, 0x64, 0x1d, 0x6c, 0x86, 0x75, 0x56, - 0x7e, 0x8d, 0x88, 0x2c, 0x92, 0x36, 0x9c, 0xab, 0xa7, 0x8c, 0xb2, 0xdb, - 0xbe, 0x99, 0xca, 0xc7, 0xd7, 0x65, 0xe4, 0x77, 0xf1, 0xf9, 0xff, 0xff, - } - - sRGBIEC6196621ICCProfile = []byte{ - 0x00, 0x00, 0x0b, 0xe8, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x6d, 0x6e, 0x74, 0x72, 0x52, 0x47, 0x42, 0x20, 0x58, 0x59, 0x5a, 0x20, - 0x07, 0xd9, 0x00, 0x03, 0x00, 0x1b, 0x00, 0x15, 0x00, 0x24, 0x00, 0x1f, - 0x61, 0x63, 0x73, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xd6, - 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d, 0x00, 0x00, 0x00, 0x00, - 0x29, 0xf8, 0x3d, 0xde, 0xaf, 0xf2, 0x55, 0xae, 0x78, 0x42, 0xfa, 0xe4, - 0xca, 0x83, 0x39, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, - 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x01, 0x44, 0x00, 0x00, 0x00, 0x79, - 0x62, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x14, - 0x62, 0x54, 0x52, 0x43, 0x00, 0x00, 0x01, 0xd4, 0x00, 0x00, 0x08, 0x0c, - 0x64, 0x6d, 0x64, 0x64, 0x00, 0x00, 0x09, 0xe0, 0x00, 0x00, 0x00, 0x88, - 0x67, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x0a, 0x68, 0x00, 0x00, 0x00, 0x14, - 0x67, 0x54, 0x52, 0x43, 0x00, 0x00, 0x01, 0xd4, 0x00, 0x00, 0x08, 0x0c, - 0x6c, 0x75, 0x6d, 0x69, 0x00, 0x00, 0x0a, 0x7c, 0x00, 0x00, 0x00, 0x14, - 0x6d, 0x65, 0x61, 0x73, 0x00, 0x00, 0x0a, 0x90, 0x00, 0x00, 0x00, 0x24, - 0x62, 0x6b, 0x70, 0x74, 0x00, 0x00, 0x0a, 0xb4, 0x00, 0x00, 0x00, 0x14, - 0x72, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x0a, 0xc8, 0x00, 0x00, 0x00, 0x14, - 0x72, 0x54, 0x52, 0x43, 0x00, 0x00, 0x01, 0xd4, 0x00, 0x00, 0x08, 0x0c, - 0x74, 0x65, 0x63, 0x68, 0x00, 0x00, 0x0a, 0xdc, 0x00, 0x00, 0x00, 0x0c, - 0x76, 0x75, 0x65, 0x64, 0x00, 0x00, 0x0a, 0xe8, 0x00, 0x00, 0x00, 0x87, - 0x77, 0x74, 0x70, 0x74, 0x00, 0x00, 0x0b, 0x70, 0x00, 0x00, 0x00, 0x14, - 0x63, 0x70, 0x72, 0x74, 0x00, 0x00, 0x0b, 0x84, 0x00, 0x00, 0x00, 0x37, - 0x63, 0x68, 0x61, 0x64, 0x00, 0x00, 0x0b, 0xbc, 0x00, 0x00, 0x00, 0x2c, - 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, - 0x73, 0x52, 0x47, 0x42, 0x20, 0x49, 0x45, 0x43, 0x36, 0x31, 0x39, 0x36, - 0x36, 0x2d, 0x32, 0x2d, 0x31, 0x20, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x20, - 0x73, 0x63, 0x61, 0x6c, 0x65, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x24, 0xa0, 0x00, 0x00, 0x0f, 0x84, 0x00, 0x00, 0xb6, 0xcf, - 0x63, 0x75, 0x72, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, - 0x00, 0x00, 0x00, 0x05, 0x00, 0x0a, 0x00, 0x0f, 0x00, 0x14, 0x00, 0x19, - 0x00, 0x1e, 0x00, 0x23, 0x00, 0x28, 0x00, 0x2d, 0x00, 0x32, 0x00, 0x37, - 0x00, 0x3b, 0x00, 0x40, 0x00, 0x45, 0x00, 0x4a, 0x00, 0x4f, 0x00, 0x54, - 0x00, 0x59, 0x00, 0x5e, 0x00, 0x63, 0x00, 0x68, 0x00, 0x6d, 0x00, 0x72, - 0x00, 0x77, 0x00, 0x7c, 0x00, 0x81, 0x00, 0x86, 0x00, 0x8b, 0x00, 0x90, - 0x00, 0x95, 0x00, 0x9a, 0x00, 0x9f, 0x00, 0xa4, 0x00, 0xa9, 0x00, 0xae, - 0x00, 0xb2, 0x00, 0xb7, 0x00, 0xbc, 0x00, 0xc1, 0x00, 0xc6, 0x00, 0xcb, - 0x00, 0xd0, 0x00, 0xd5, 0x00, 0xdb, 0x00, 0xe0, 0x00, 0xe5, 0x00, 0xeb, - 0x00, 0xf0, 0x00, 0xf6, 0x00, 0xfb, 0x01, 0x01, 0x01, 0x07, 0x01, 0x0d, - 0x01, 0x13, 0x01, 0x19, 0x01, 0x1f, 0x01, 0x25, 0x01, 0x2b, 0x01, 0x32, - 0x01, 0x38, 0x01, 0x3e, 0x01, 0x45, 0x01, 0x4c, 0x01, 0x52, 0x01, 0x59, - 0x01, 0x60, 0x01, 0x67, 0x01, 0x6e, 0x01, 0x75, 0x01, 0x7c, 0x01, 0x83, - 0x01, 0x8b, 0x01, 0x92, 0x01, 0x9a, 0x01, 0xa1, 0x01, 0xa9, 0x01, 0xb1, - 0x01, 0xb9, 0x01, 0xc1, 0x01, 0xc9, 0x01, 0xd1, 0x01, 0xd9, 0x01, 0xe1, - 0x01, 0xe9, 0x01, 0xf2, 0x01, 0xfa, 0x02, 0x03, 0x02, 0x0c, 0x02, 0x14, - 0x02, 0x1d, 0x02, 0x26, 0x02, 0x2f, 0x02, 0x38, 0x02, 0x41, 0x02, 0x4b, - 0x02, 0x54, 0x02, 0x5d, 0x02, 0x67, 0x02, 0x71, 0x02, 0x7a, 0x02, 0x84, - 0x02, 0x8e, 0x02, 0x98, 0x02, 0xa2, 0x02, 0xac, 0x02, 0xb6, 0x02, 0xc1, - 0x02, 0xcb, 0x02, 0xd5, 0x02, 0xe0, 0x02, 0xeb, 0x02, 0xf5, 0x03, 0x00, - 0x03, 0x0b, 0x03, 0x16, 0x03, 0x21, 0x03, 0x2d, 0x03, 0x38, 0x03, 0x43, - 0x03, 0x4f, 0x03, 0x5a, 0x03, 0x66, 0x03, 0x72, 0x03, 0x7e, 0x03, 0x8a, - 0x03, 0x96, 0x03, 0xa2, 0x03, 0xae, 0x03, 0xba, 0x03, 0xc7, 0x03, 0xd3, - 0x03, 0xe0, 0x03, 0xec, 0x03, 0xf9, 0x04, 0x06, 0x04, 0x13, 0x04, 0x20, - 0x04, 0x2d, 0x04, 0x3b, 0x04, 0x48, 0x04, 0x55, 0x04, 0x63, 0x04, 0x71, - 0x04, 0x7e, 0x04, 0x8c, 0x04, 0x9a, 0x04, 0xa8, 0x04, 0xb6, 0x04, 0xc4, - 0x04, 0xd3, 0x04, 0xe1, 0x04, 0xf0, 0x04, 0xfe, 0x05, 0x0d, 0x05, 0x1c, - 0x05, 0x2b, 0x05, 0x3a, 0x05, 0x49, 0x05, 0x58, 0x05, 0x67, 0x05, 0x77, - 0x05, 0x86, 0x05, 0x96, 0x05, 0xa6, 0x05, 0xb5, 0x05, 0xc5, 0x05, 0xd5, - 0x05, 0xe5, 0x05, 0xf6, 0x06, 0x06, 0x06, 0x16, 0x06, 0x27, 0x06, 0x37, - 0x06, 0x48, 0x06, 0x59, 0x06, 0x6a, 0x06, 0x7b, 0x06, 0x8c, 0x06, 0x9d, - 0x06, 0xaf, 0x06, 0xc0, 0x06, 0xd1, 0x06, 0xe3, 0x06, 0xf5, 0x07, 0x07, - 0x07, 0x19, 0x07, 0x2b, 0x07, 0x3d, 0x07, 0x4f, 0x07, 0x61, 0x07, 0x74, - 0x07, 0x86, 0x07, 0x99, 0x07, 0xac, 0x07, 0xbf, 0x07, 0xd2, 0x07, 0xe5, - 0x07, 0xf8, 0x08, 0x0b, 0x08, 0x1f, 0x08, 0x32, 0x08, 0x46, 0x08, 0x5a, - 0x08, 0x6e, 0x08, 0x82, 0x08, 0x96, 0x08, 0xaa, 0x08, 0xbe, 0x08, 0xd2, - 0x08, 0xe7, 0x08, 0xfb, 0x09, 0x10, 0x09, 0x25, 0x09, 0x3a, 0x09, 0x4f, - 0x09, 0x64, 0x09, 0x79, 0x09, 0x8f, 0x09, 0xa4, 0x09, 0xba, 0x09, 0xcf, - 0x09, 0xe5, 0x09, 0xfb, 0x0a, 0x11, 0x0a, 0x27, 0x0a, 0x3d, 0x0a, 0x54, - 0x0a, 0x6a, 0x0a, 0x81, 0x0a, 0x98, 0x0a, 0xae, 0x0a, 0xc5, 0x0a, 0xdc, - 0x0a, 0xf3, 0x0b, 0x0b, 0x0b, 0x22, 0x0b, 0x39, 0x0b, 0x51, 0x0b, 0x69, - 0x0b, 0x80, 0x0b, 0x98, 0x0b, 0xb0, 0x0b, 0xc8, 0x0b, 0xe1, 0x0b, 0xf9, - 0x0c, 0x12, 0x0c, 0x2a, 0x0c, 0x43, 0x0c, 0x5c, 0x0c, 0x75, 0x0c, 0x8e, - 0x0c, 0xa7, 0x0c, 0xc0, 0x0c, 0xd9, 0x0c, 0xf3, 0x0d, 0x0d, 0x0d, 0x26, - 0x0d, 0x40, 0x0d, 0x5a, 0x0d, 0x74, 0x0d, 0x8e, 0x0d, 0xa9, 0x0d, 0xc3, - 0x0d, 0xde, 0x0d, 0xf8, 0x0e, 0x13, 0x0e, 0x2e, 0x0e, 0x49, 0x0e, 0x64, - 0x0e, 0x7f, 0x0e, 0x9b, 0x0e, 0xb6, 0x0e, 0xd2, 0x0e, 0xee, 0x0f, 0x09, - 0x0f, 0x25, 0x0f, 0x41, 0x0f, 0x5e, 0x0f, 0x7a, 0x0f, 0x96, 0x0f, 0xb3, - 0x0f, 0xcf, 0x0f, 0xec, 0x10, 0x09, 0x10, 0x26, 0x10, 0x43, 0x10, 0x61, - 0x10, 0x7e, 0x10, 0x9b, 0x10, 0xb9, 0x10, 0xd7, 0x10, 0xf5, 0x11, 0x13, - 0x11, 0x31, 0x11, 0x4f, 0x11, 0x6d, 0x11, 0x8c, 0x11, 0xaa, 0x11, 0xc9, - 0x11, 0xe8, 0x12, 0x07, 0x12, 0x26, 0x12, 0x45, 0x12, 0x64, 0x12, 0x84, - 0x12, 0xa3, 0x12, 0xc3, 0x12, 0xe3, 0x13, 0x03, 0x13, 0x23, 0x13, 0x43, - 0x13, 0x63, 0x13, 0x83, 0x13, 0xa4, 0x13, 0xc5, 0x13, 0xe5, 0x14, 0x06, - 0x14, 0x27, 0x14, 0x49, 0x14, 0x6a, 0x14, 0x8b, 0x14, 0xad, 0x14, 0xce, - 0x14, 0xf0, 0x15, 0x12, 0x15, 0x34, 0x15, 0x56, 0x15, 0x78, 0x15, 0x9b, - 0x15, 0xbd, 0x15, 0xe0, 0x16, 0x03, 0x16, 0x26, 0x16, 0x49, 0x16, 0x6c, - 0x16, 0x8f, 0x16, 0xb2, 0x16, 0xd6, 0x16, 0xfa, 0x17, 0x1d, 0x17, 0x41, - 0x17, 0x65, 0x17, 0x89, 0x17, 0xae, 0x17, 0xd2, 0x17, 0xf7, 0x18, 0x1b, - 0x18, 0x40, 0x18, 0x65, 0x18, 0x8a, 0x18, 0xaf, 0x18, 0xd5, 0x18, 0xfa, - 0x19, 0x20, 0x19, 0x45, 0x19, 0x6b, 0x19, 0x91, 0x19, 0xb7, 0x19, 0xdd, - 0x1a, 0x04, 0x1a, 0x2a, 0x1a, 0x51, 0x1a, 0x77, 0x1a, 0x9e, 0x1a, 0xc5, - 0x1a, 0xec, 0x1b, 0x14, 0x1b, 0x3b, 0x1b, 0x63, 0x1b, 0x8a, 0x1b, 0xb2, - 0x1b, 0xda, 0x1c, 0x02, 0x1c, 0x2a, 0x1c, 0x52, 0x1c, 0x7b, 0x1c, 0xa3, - 0x1c, 0xcc, 0x1c, 0xf5, 0x1d, 0x1e, 0x1d, 0x47, 0x1d, 0x70, 0x1d, 0x99, - 0x1d, 0xc3, 0x1d, 0xec, 0x1e, 0x16, 0x1e, 0x40, 0x1e, 0x6a, 0x1e, 0x94, - 0x1e, 0xbe, 0x1e, 0xe9, 0x1f, 0x13, 0x1f, 0x3e, 0x1f, 0x69, 0x1f, 0x94, - 0x1f, 0xbf, 0x1f, 0xea, 0x20, 0x15, 0x20, 0x41, 0x20, 0x6c, 0x20, 0x98, - 0x20, 0xc4, 0x20, 0xf0, 0x21, 0x1c, 0x21, 0x48, 0x21, 0x75, 0x21, 0xa1, - 0x21, 0xce, 0x21, 0xfb, 0x22, 0x27, 0x22, 0x55, 0x22, 0x82, 0x22, 0xaf, - 0x22, 0xdd, 0x23, 0x0a, 0x23, 0x38, 0x23, 0x66, 0x23, 0x94, 0x23, 0xc2, - 0x23, 0xf0, 0x24, 0x1f, 0x24, 0x4d, 0x24, 0x7c, 0x24, 0xab, 0x24, 0xda, - 0x25, 0x09, 0x25, 0x38, 0x25, 0x68, 0x25, 0x97, 0x25, 0xc7, 0x25, 0xf7, - 0x26, 0x27, 0x26, 0x57, 0x26, 0x87, 0x26, 0xb7, 0x26, 0xe8, 0x27, 0x18, - 0x27, 0x49, 0x27, 0x7a, 0x27, 0xab, 0x27, 0xdc, 0x28, 0x0d, 0x28, 0x3f, - 0x28, 0x71, 0x28, 0xa2, 0x28, 0xd4, 0x29, 0x06, 0x29, 0x38, 0x29, 0x6b, - 0x29, 0x9d, 0x29, 0xd0, 0x2a, 0x02, 0x2a, 0x35, 0x2a, 0x68, 0x2a, 0x9b, - 0x2a, 0xcf, 0x2b, 0x02, 0x2b, 0x36, 0x2b, 0x69, 0x2b, 0x9d, 0x2b, 0xd1, - 0x2c, 0x05, 0x2c, 0x39, 0x2c, 0x6e, 0x2c, 0xa2, 0x2c, 0xd7, 0x2d, 0x0c, - 0x2d, 0x41, 0x2d, 0x76, 0x2d, 0xab, 0x2d, 0xe1, 0x2e, 0x16, 0x2e, 0x4c, - 0x2e, 0x82, 0x2e, 0xb7, 0x2e, 0xee, 0x2f, 0x24, 0x2f, 0x5a, 0x2f, 0x91, - 0x2f, 0xc7, 0x2f, 0xfe, 0x30, 0x35, 0x30, 0x6c, 0x30, 0xa4, 0x30, 0xdb, - 0x31, 0x12, 0x31, 0x4a, 0x31, 0x82, 0x31, 0xba, 0x31, 0xf2, 0x32, 0x2a, - 0x32, 0x63, 0x32, 0x9b, 0x32, 0xd4, 0x33, 0x0d, 0x33, 0x46, 0x33, 0x7f, - 0x33, 0xb8, 0x33, 0xf1, 0x34, 0x2b, 0x34, 0x65, 0x34, 0x9e, 0x34, 0xd8, - 0x35, 0x13, 0x35, 0x4d, 0x35, 0x87, 0x35, 0xc2, 0x35, 0xfd, 0x36, 0x37, - 0x36, 0x72, 0x36, 0xae, 0x36, 0xe9, 0x37, 0x24, 0x37, 0x60, 0x37, 0x9c, - 0x37, 0xd7, 0x38, 0x14, 0x38, 0x50, 0x38, 0x8c, 0x38, 0xc8, 0x39, 0x05, - 0x39, 0x42, 0x39, 0x7f, 0x39, 0xbc, 0x39, 0xf9, 0x3a, 0x36, 0x3a, 0x74, - 0x3a, 0xb2, 0x3a, 0xef, 0x3b, 0x2d, 0x3b, 0x6b, 0x3b, 0xaa, 0x3b, 0xe8, - 0x3c, 0x27, 0x3c, 0x65, 0x3c, 0xa4, 0x3c, 0xe3, 0x3d, 0x22, 0x3d, 0x61, - 0x3d, 0xa1, 0x3d, 0xe0, 0x3e, 0x20, 0x3e, 0x60, 0x3e, 0xa0, 0x3e, 0xe0, - 0x3f, 0x21, 0x3f, 0x61, 0x3f, 0xa2, 0x3f, 0xe2, 0x40, 0x23, 0x40, 0x64, - 0x40, 0xa6, 0x40, 0xe7, 0x41, 0x29, 0x41, 0x6a, 0x41, 0xac, 0x41, 0xee, - 0x42, 0x30, 0x42, 0x72, 0x42, 0xb5, 0x42, 0xf7, 0x43, 0x3a, 0x43, 0x7d, - 0x43, 0xc0, 0x44, 0x03, 0x44, 0x47, 0x44, 0x8a, 0x44, 0xce, 0x45, 0x12, - 0x45, 0x55, 0x45, 0x9a, 0x45, 0xde, 0x46, 0x22, 0x46, 0x67, 0x46, 0xab, - 0x46, 0xf0, 0x47, 0x35, 0x47, 0x7b, 0x47, 0xc0, 0x48, 0x05, 0x48, 0x4b, - 0x48, 0x91, 0x48, 0xd7, 0x49, 0x1d, 0x49, 0x63, 0x49, 0xa9, 0x49, 0xf0, - 0x4a, 0x37, 0x4a, 0x7d, 0x4a, 0xc4, 0x4b, 0x0c, 0x4b, 0x53, 0x4b, 0x9a, - 0x4b, 0xe2, 0x4c, 0x2a, 0x4c, 0x72, 0x4c, 0xba, 0x4d, 0x02, 0x4d, 0x4a, - 0x4d, 0x93, 0x4d, 0xdc, 0x4e, 0x25, 0x4e, 0x6e, 0x4e, 0xb7, 0x4f, 0x00, - 0x4f, 0x49, 0x4f, 0x93, 0x4f, 0xdd, 0x50, 0x27, 0x50, 0x71, 0x50, 0xbb, - 0x51, 0x06, 0x51, 0x50, 0x51, 0x9b, 0x51, 0xe6, 0x52, 0x31, 0x52, 0x7c, - 0x52, 0xc7, 0x53, 0x13, 0x53, 0x5f, 0x53, 0xaa, 0x53, 0xf6, 0x54, 0x42, - 0x54, 0x8f, 0x54, 0xdb, 0x55, 0x28, 0x55, 0x75, 0x55, 0xc2, 0x56, 0x0f, - 0x56, 0x5c, 0x56, 0xa9, 0x56, 0xf7, 0x57, 0x44, 0x57, 0x92, 0x57, 0xe0, - 0x58, 0x2f, 0x58, 0x7d, 0x58, 0xcb, 0x59, 0x1a, 0x59, 0x69, 0x59, 0xb8, - 0x5a, 0x07, 0x5a, 0x56, 0x5a, 0xa6, 0x5a, 0xf5, 0x5b, 0x45, 0x5b, 0x95, - 0x5b, 0xe5, 0x5c, 0x35, 0x5c, 0x86, 0x5c, 0xd6, 0x5d, 0x27, 0x5d, 0x78, - 0x5d, 0xc9, 0x5e, 0x1a, 0x5e, 0x6c, 0x5e, 0xbd, 0x5f, 0x0f, 0x5f, 0x61, - 0x5f, 0xb3, 0x60, 0x05, 0x60, 0x57, 0x60, 0xaa, 0x60, 0xfc, 0x61, 0x4f, - 0x61, 0xa2, 0x61, 0xf5, 0x62, 0x49, 0x62, 0x9c, 0x62, 0xf0, 0x63, 0x43, - 0x63, 0x97, 0x63, 0xeb, 0x64, 0x40, 0x64, 0x94, 0x64, 0xe9, 0x65, 0x3d, - 0x65, 0x92, 0x65, 0xe7, 0x66, 0x3d, 0x66, 0x92, 0x66, 0xe8, 0x67, 0x3d, - 0x67, 0x93, 0x67, 0xe9, 0x68, 0x3f, 0x68, 0x96, 0x68, 0xec, 0x69, 0x43, - 0x69, 0x9a, 0x69, 0xf1, 0x6a, 0x48, 0x6a, 0x9f, 0x6a, 0xf7, 0x6b, 0x4f, - 0x6b, 0xa7, 0x6b, 0xff, 0x6c, 0x57, 0x6c, 0xaf, 0x6d, 0x08, 0x6d, 0x60, - 0x6d, 0xb9, 0x6e, 0x12, 0x6e, 0x6b, 0x6e, 0xc4, 0x6f, 0x1e, 0x6f, 0x78, - 0x6f, 0xd1, 0x70, 0x2b, 0x70, 0x86, 0x70, 0xe0, 0x71, 0x3a, 0x71, 0x95, - 0x71, 0xf0, 0x72, 0x4b, 0x72, 0xa6, 0x73, 0x01, 0x73, 0x5d, 0x73, 0xb8, - 0x74, 0x14, 0x74, 0x70, 0x74, 0xcc, 0x75, 0x28, 0x75, 0x85, 0x75, 0xe1, - 0x76, 0x3e, 0x76, 0x9b, 0x76, 0xf8, 0x77, 0x56, 0x77, 0xb3, 0x78, 0x11, - 0x78, 0x6e, 0x78, 0xcc, 0x79, 0x2a, 0x79, 0x89, 0x79, 0xe7, 0x7a, 0x46, - 0x7a, 0xa5, 0x7b, 0x04, 0x7b, 0x63, 0x7b, 0xc2, 0x7c, 0x21, 0x7c, 0x81, - 0x7c, 0xe1, 0x7d, 0x41, 0x7d, 0xa1, 0x7e, 0x01, 0x7e, 0x62, 0x7e, 0xc2, - 0x7f, 0x23, 0x7f, 0x84, 0x7f, 0xe5, 0x80, 0x47, 0x80, 0xa8, 0x81, 0x0a, - 0x81, 0x6b, 0x81, 0xcd, 0x82, 0x30, 0x82, 0x92, 0x82, 0xf4, 0x83, 0x57, - 0x83, 0xba, 0x84, 0x1d, 0x84, 0x80, 0x84, 0xe3, 0x85, 0x47, 0x85, 0xab, - 0x86, 0x0e, 0x86, 0x72, 0x86, 0xd7, 0x87, 0x3b, 0x87, 0x9f, 0x88, 0x04, - 0x88, 0x69, 0x88, 0xce, 0x89, 0x33, 0x89, 0x99, 0x89, 0xfe, 0x8a, 0x64, - 0x8a, 0xca, 0x8b, 0x30, 0x8b, 0x96, 0x8b, 0xfc, 0x8c, 0x63, 0x8c, 0xca, - 0x8d, 0x31, 0x8d, 0x98, 0x8d, 0xff, 0x8e, 0x66, 0x8e, 0xce, 0x8f, 0x36, - 0x8f, 0x9e, 0x90, 0x06, 0x90, 0x6e, 0x90, 0xd6, 0x91, 0x3f, 0x91, 0xa8, - 0x92, 0x11, 0x92, 0x7a, 0x92, 0xe3, 0x93, 0x4d, 0x93, 0xb6, 0x94, 0x20, - 0x94, 0x8a, 0x94, 0xf4, 0x95, 0x5f, 0x95, 0xc9, 0x96, 0x34, 0x96, 0x9f, - 0x97, 0x0a, 0x97, 0x75, 0x97, 0xe0, 0x98, 0x4c, 0x98, 0xb8, 0x99, 0x24, - 0x99, 0x90, 0x99, 0xfc, 0x9a, 0x68, 0x9a, 0xd5, 0x9b, 0x42, 0x9b, 0xaf, - 0x9c, 0x1c, 0x9c, 0x89, 0x9c, 0xf7, 0x9d, 0x64, 0x9d, 0xd2, 0x9e, 0x40, - 0x9e, 0xae, 0x9f, 0x1d, 0x9f, 0x8b, 0x9f, 0xfa, 0xa0, 0x69, 0xa0, 0xd8, - 0xa1, 0x47, 0xa1, 0xb6, 0xa2, 0x26, 0xa2, 0x96, 0xa3, 0x06, 0xa3, 0x76, - 0xa3, 0xe6, 0xa4, 0x56, 0xa4, 0xc7, 0xa5, 0x38, 0xa5, 0xa9, 0xa6, 0x1a, - 0xa6, 0x8b, 0xa6, 0xfd, 0xa7, 0x6e, 0xa7, 0xe0, 0xa8, 0x52, 0xa8, 0xc4, - 0xa9, 0x37, 0xa9, 0xa9, 0xaa, 0x1c, 0xaa, 0x8f, 0xab, 0x02, 0xab, 0x75, - 0xab, 0xe9, 0xac, 0x5c, 0xac, 0xd0, 0xad, 0x44, 0xad, 0xb8, 0xae, 0x2d, - 0xae, 0xa1, 0xaf, 0x16, 0xaf, 0x8b, 0xb0, 0x00, 0xb0, 0x75, 0xb0, 0xea, - 0xb1, 0x60, 0xb1, 0xd6, 0xb2, 0x4b, 0xb2, 0xc2, 0xb3, 0x38, 0xb3, 0xae, - 0xb4, 0x25, 0xb4, 0x9c, 0xb5, 0x13, 0xb5, 0x8a, 0xb6, 0x01, 0xb6, 0x79, - 0xb6, 0xf0, 0xb7, 0x68, 0xb7, 0xe0, 0xb8, 0x59, 0xb8, 0xd1, 0xb9, 0x4a, - 0xb9, 0xc2, 0xba, 0x3b, 0xba, 0xb5, 0xbb, 0x2e, 0xbb, 0xa7, 0xbc, 0x21, - 0xbc, 0x9b, 0xbd, 0x15, 0xbd, 0x8f, 0xbe, 0x0a, 0xbe, 0x84, 0xbe, 0xff, - 0xbf, 0x7a, 0xbf, 0xf5, 0xc0, 0x70, 0xc0, 0xec, 0xc1, 0x67, 0xc1, 0xe3, - 0xc2, 0x5f, 0xc2, 0xdb, 0xc3, 0x58, 0xc3, 0xd4, 0xc4, 0x51, 0xc4, 0xce, - 0xc5, 0x4b, 0xc5, 0xc8, 0xc6, 0x46, 0xc6, 0xc3, 0xc7, 0x41, 0xc7, 0xbf, - 0xc8, 0x3d, 0xc8, 0xbc, 0xc9, 0x3a, 0xc9, 0xb9, 0xca, 0x38, 0xca, 0xb7, - 0xcb, 0x36, 0xcb, 0xb6, 0xcc, 0x35, 0xcc, 0xb5, 0xcd, 0x35, 0xcd, 0xb5, - 0xce, 0x36, 0xce, 0xb6, 0xcf, 0x37, 0xcf, 0xb8, 0xd0, 0x39, 0xd0, 0xba, - 0xd1, 0x3c, 0xd1, 0xbe, 0xd2, 0x3f, 0xd2, 0xc1, 0xd3, 0x44, 0xd3, 0xc6, - 0xd4, 0x49, 0xd4, 0xcb, 0xd5, 0x4e, 0xd5, 0xd1, 0xd6, 0x55, 0xd6, 0xd8, - 0xd7, 0x5c, 0xd7, 0xe0, 0xd8, 0x64, 0xd8, 0xe8, 0xd9, 0x6c, 0xd9, 0xf1, - 0xda, 0x76, 0xda, 0xfb, 0xdb, 0x80, 0xdc, 0x05, 0xdc, 0x8a, 0xdd, 0x10, - 0xdd, 0x96, 0xde, 0x1c, 0xde, 0xa2, 0xdf, 0x29, 0xdf, 0xaf, 0xe0, 0x36, - 0xe0, 0xbd, 0xe1, 0x44, 0xe1, 0xcc, 0xe2, 0x53, 0xe2, 0xdb, 0xe3, 0x63, - 0xe3, 0xeb, 0xe4, 0x73, 0xe4, 0xfc, 0xe5, 0x84, 0xe6, 0x0d, 0xe6, 0x96, - 0xe7, 0x1f, 0xe7, 0xa9, 0xe8, 0x32, 0xe8, 0xbc, 0xe9, 0x46, 0xe9, 0xd0, - 0xea, 0x5b, 0xea, 0xe5, 0xeb, 0x70, 0xeb, 0xfb, 0xec, 0x86, 0xed, 0x11, - 0xed, 0x9c, 0xee, 0x28, 0xee, 0xb4, 0xef, 0x40, 0xef, 0xcc, 0xf0, 0x58, - 0xf0, 0xe5, 0xf1, 0x72, 0xf1, 0xff, 0xf2, 0x8c, 0xf3, 0x19, 0xf3, 0xa7, - 0xf4, 0x34, 0xf4, 0xc2, 0xf5, 0x50, 0xf5, 0xde, 0xf6, 0x6d, 0xf6, 0xfb, - 0xf7, 0x8a, 0xf8, 0x19, 0xf8, 0xa8, 0xf9, 0x38, 0xf9, 0xc7, 0xfa, 0x57, - 0xfa, 0xe7, 0xfb, 0x77, 0xfc, 0x07, 0xfc, 0x98, 0xfd, 0x29, 0xfd, 0xba, - 0xfe, 0x4b, 0xfe, 0xdc, 0xff, 0x6d, 0xff, 0xff, 0x64, 0x65, 0x73, 0x63, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2e, 0x49, 0x45, 0x43, 0x20, - 0x36, 0x31, 0x39, 0x36, 0x36, 0x2d, 0x32, 0x2d, 0x31, 0x20, 0x44, 0x65, - 0x66, 0x61, 0x75, 0x6c, 0x74, 0x20, 0x52, 0x47, 0x42, 0x20, 0x43, 0x6f, - 0x6c, 0x6f, 0x75, 0x72, 0x20, 0x53, 0x70, 0x61, 0x63, 0x65, 0x20, 0x2d, - 0x20, 0x73, 0x52, 0x47, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x99, - 0x00, 0x00, 0xb7, 0x85, 0x00, 0x00, 0x18, 0xda, 0x58, 0x59, 0x5a, 0x20, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x6d, 0x65, 0x61, 0x73, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x02, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x03, 0x16, 0x00, 0x00, 0x03, 0x33, 0x00, 0x00, 0x02, 0xa4, - 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6f, 0xa2, - 0x00, 0x00, 0x38, 0xf5, 0x00, 0x00, 0x03, 0x90, 0x73, 0x69, 0x67, 0x20, - 0x00, 0x00, 0x00, 0x00, 0x43, 0x52, 0x54, 0x20, 0x64, 0x65, 0x73, 0x63, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x52, 0x65, 0x66, 0x65, - 0x72, 0x65, 0x6e, 0x63, 0x65, 0x20, 0x56, 0x69, 0x65, 0x77, 0x69, 0x6e, - 0x67, 0x20, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, - 0x69, 0x6e, 0x20, 0x49, 0x45, 0x43, 0x20, 0x36, 0x31, 0x39, 0x36, 0x36, - 0x2d, 0x32, 0x2d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xd6, - 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d, 0x74, 0x65, 0x78, 0x74, - 0x00, 0x00, 0x00, 0x00, 0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68, - 0x74, 0x20, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x61, 0x6c, 0x20, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x43, 0x6f, - 0x6e, 0x73, 0x6f, 0x72, 0x74, 0x69, 0x75, 0x6d, 0x2c, 0x20, 0x32, 0x30, - 0x30, 0x39, 0x00, 0x00, 0x73, 0x66, 0x33, 0x32, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x01, 0x0c, 0x44, 0x00, 0x00, 0x05, 0xdf, 0xff, 0xff, 0xf3, 0x26, - 0x00, 0x00, 0x07, 0x94, 0x00, 0x00, 0xfd, 0x8f, 0xff, 0xff, 0xfb, 0xa1, - 0xff, 0xff, 0xfd, 0xa2, 0x00, 0x00, 0x03, 0xdb, 0x00, 0x00, 0xc0, 0x75, - } - - genericGrayGamma22ICCProfile = []byte{ - 0x00, 0x00, 0x0e, 0x04, 0x61, 0x70, 0x70, 0x6c, 0x02, 0x00, 0x00, 0x00, - 0x6d, 0x6e, 0x74, 0x72, 0x47, 0x52, 0x41, 0x59, 0x58, 0x59, 0x5a, 0x20, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x61, 0x63, 0x73, 0x70, 0x41, 0x50, 0x50, 0x4c, 0x00, 0x00, 0x00, 0x00, - 0x6e, 0x6f, 0x6e, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xd6, - 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d, 0x61, 0x70, 0x70, 0x6c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, - 0x6b, 0x54, 0x52, 0x43, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x08, 0x0c, - 0x77, 0x74, 0x70, 0x74, 0x00, 0x00, 0x08, 0xcc, 0x00, 0x00, 0x00, 0x14, - 0x63, 0x70, 0x72, 0x74, 0x00, 0x00, 0x08, 0xe0, 0x00, 0x00, 0x00, 0x23, - 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x09, 0x04, 0x00, 0x00, 0x00, 0x79, - 0x64, 0x73, 0x63, 0x6d, 0x00, 0x00, 0x09, 0x80, 0x00, 0x00, 0x04, 0x82, - 0x63, 0x75, 0x72, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, - 0x00, 0x00, 0x00, 0x05, 0x00, 0x0a, 0x00, 0x0f, 0x00, 0x14, 0x00, 0x19, - 0x00, 0x1e, 0x00, 0x23, 0x00, 0x28, 0x00, 0x2d, 0x00, 0x32, 0x00, 0x37, - 0x00, 0x3b, 0x00, 0x40, 0x00, 0x45, 0x00, 0x4a, 0x00, 0x4f, 0x00, 0x54, - 0x00, 0x59, 0x00, 0x5e, 0x00, 0x63, 0x00, 0x68, 0x00, 0x6d, 0x00, 0x72, - 0x00, 0x77, 0x00, 0x7c, 0x00, 0x81, 0x00, 0x86, 0x00, 0x8b, 0x00, 0x90, - 0x00, 0x95, 0x00, 0x9a, 0x00, 0x9f, 0x00, 0xa4, 0x00, 0xa9, 0x00, 0xae, - 0x00, 0xb2, 0x00, 0xb7, 0x00, 0xbc, 0x00, 0xc1, 0x00, 0xc6, 0x00, 0xcb, - 0x00, 0xd0, 0x00, 0xd5, 0x00, 0xdb, 0x00, 0xe0, 0x00, 0xe5, 0x00, 0xeb, - 0x00, 0xf0, 0x00, 0xf6, 0x00, 0xfb, 0x01, 0x01, 0x01, 0x07, 0x01, 0x0d, - 0x01, 0x13, 0x01, 0x19, 0x01, 0x1f, 0x01, 0x25, 0x01, 0x2b, 0x01, 0x32, - 0x01, 0x38, 0x01, 0x3e, 0x01, 0x45, 0x01, 0x4c, 0x01, 0x52, 0x01, 0x59, - 0x01, 0x60, 0x01, 0x67, 0x01, 0x6e, 0x01, 0x75, 0x01, 0x7c, 0x01, 0x83, - 0x01, 0x8b, 0x01, 0x92, 0x01, 0x9a, 0x01, 0xa1, 0x01, 0xa9, 0x01, 0xb1, - 0x01, 0xb9, 0x01, 0xc1, 0x01, 0xc9, 0x01, 0xd1, 0x01, 0xd9, 0x01, 0xe1, - 0x01, 0xe9, 0x01, 0xf2, 0x01, 0xfa, 0x02, 0x03, 0x02, 0x0c, 0x02, 0x14, - 0x02, 0x1d, 0x02, 0x26, 0x02, 0x2f, 0x02, 0x38, 0x02, 0x41, 0x02, 0x4b, - 0x02, 0x54, 0x02, 0x5d, 0x02, 0x67, 0x02, 0x71, 0x02, 0x7a, 0x02, 0x84, - 0x02, 0x8e, 0x02, 0x98, 0x02, 0xa2, 0x02, 0xac, 0x02, 0xb6, 0x02, 0xc1, - 0x02, 0xcb, 0x02, 0xd5, 0x02, 0xe0, 0x02, 0xeb, 0x02, 0xf5, 0x03, 0x00, - 0x03, 0x0b, 0x03, 0x16, 0x03, 0x21, 0x03, 0x2d, 0x03, 0x38, 0x03, 0x43, - 0x03, 0x4f, 0x03, 0x5a, 0x03, 0x66, 0x03, 0x72, 0x03, 0x7e, 0x03, 0x8a, - 0x03, 0x96, 0x03, 0xa2, 0x03, 0xae, 0x03, 0xba, 0x03, 0xc7, 0x03, 0xd3, - 0x03, 0xe0, 0x03, 0xec, 0x03, 0xf9, 0x04, 0x06, 0x04, 0x13, 0x04, 0x20, - 0x04, 0x2d, 0x04, 0x3b, 0x04, 0x48, 0x04, 0x55, 0x04, 0x63, 0x04, 0x71, - 0x04, 0x7e, 0x04, 0x8c, 0x04, 0x9a, 0x04, 0xa8, 0x04, 0xb6, 0x04, 0xc4, - 0x04, 0xd3, 0x04, 0xe1, 0x04, 0xf0, 0x04, 0xfe, 0x05, 0x0d, 0x05, 0x1c, - 0x05, 0x2b, 0x05, 0x3a, 0x05, 0x49, 0x05, 0x58, 0x05, 0x67, 0x05, 0x77, - 0x05, 0x86, 0x05, 0x96, 0x05, 0xa6, 0x05, 0xb5, 0x05, 0xc5, 0x05, 0xd5, - 0x05, 0xe5, 0x05, 0xf6, 0x06, 0x06, 0x06, 0x16, 0x06, 0x27, 0x06, 0x37, - 0x06, 0x48, 0x06, 0x59, 0x06, 0x6a, 0x06, 0x7b, 0x06, 0x8c, 0x06, 0x9d, - 0x06, 0xaf, 0x06, 0xc0, 0x06, 0xd1, 0x06, 0xe3, 0x06, 0xf5, 0x07, 0x07, - 0x07, 0x19, 0x07, 0x2b, 0x07, 0x3d, 0x07, 0x4f, 0x07, 0x61, 0x07, 0x74, - 0x07, 0x86, 0x07, 0x99, 0x07, 0xac, 0x07, 0xbf, 0x07, 0xd2, 0x07, 0xe5, - 0x07, 0xf8, 0x08, 0x0b, 0x08, 0x1f, 0x08, 0x32, 0x08, 0x46, 0x08, 0x5a, - 0x08, 0x6e, 0x08, 0x82, 0x08, 0x96, 0x08, 0xaa, 0x08, 0xbe, 0x08, 0xd2, - 0x08, 0xe7, 0x08, 0xfb, 0x09, 0x10, 0x09, 0x25, 0x09, 0x3a, 0x09, 0x4f, - 0x09, 0x64, 0x09, 0x79, 0x09, 0x8f, 0x09, 0xa4, 0x09, 0xba, 0x09, 0xcf, - 0x09, 0xe5, 0x09, 0xfb, 0x0a, 0x11, 0x0a, 0x27, 0x0a, 0x3d, 0x0a, 0x54, - 0x0a, 0x6a, 0x0a, 0x81, 0x0a, 0x98, 0x0a, 0xae, 0x0a, 0xc5, 0x0a, 0xdc, - 0x0a, 0xf3, 0x0b, 0x0b, 0x0b, 0x22, 0x0b, 0x39, 0x0b, 0x51, 0x0b, 0x69, - 0x0b, 0x80, 0x0b, 0x98, 0x0b, 0xb0, 0x0b, 0xc8, 0x0b, 0xe1, 0x0b, 0xf9, - 0x0c, 0x12, 0x0c, 0x2a, 0x0c, 0x43, 0x0c, 0x5c, 0x0c, 0x75, 0x0c, 0x8e, - 0x0c, 0xa7, 0x0c, 0xc0, 0x0c, 0xd9, 0x0c, 0xf3, 0x0d, 0x0d, 0x0d, 0x26, - 0x0d, 0x40, 0x0d, 0x5a, 0x0d, 0x74, 0x0d, 0x8e, 0x0d, 0xa9, 0x0d, 0xc3, - 0x0d, 0xde, 0x0d, 0xf8, 0x0e, 0x13, 0x0e, 0x2e, 0x0e, 0x49, 0x0e, 0x64, - 0x0e, 0x7f, 0x0e, 0x9b, 0x0e, 0xb6, 0x0e, 0xd2, 0x0e, 0xee, 0x0f, 0x09, - 0x0f, 0x25, 0x0f, 0x41, 0x0f, 0x5e, 0x0f, 0x7a, 0x0f, 0x96, 0x0f, 0xb3, - 0x0f, 0xcf, 0x0f, 0xec, 0x10, 0x09, 0x10, 0x26, 0x10, 0x43, 0x10, 0x61, - 0x10, 0x7e, 0x10, 0x9b, 0x10, 0xb9, 0x10, 0xd7, 0x10, 0xf5, 0x11, 0x13, - 0x11, 0x31, 0x11, 0x4f, 0x11, 0x6d, 0x11, 0x8c, 0x11, 0xaa, 0x11, 0xc9, - 0x11, 0xe8, 0x12, 0x07, 0x12, 0x26, 0x12, 0x45, 0x12, 0x64, 0x12, 0x84, - 0x12, 0xa3, 0x12, 0xc3, 0x12, 0xe3, 0x13, 0x03, 0x13, 0x23, 0x13, 0x43, - 0x13, 0x63, 0x13, 0x83, 0x13, 0xa4, 0x13, 0xc5, 0x13, 0xe5, 0x14, 0x06, - 0x14, 0x27, 0x14, 0x49, 0x14, 0x6a, 0x14, 0x8b, 0x14, 0xad, 0x14, 0xce, - 0x14, 0xf0, 0x15, 0x12, 0x15, 0x34, 0x15, 0x56, 0x15, 0x78, 0x15, 0x9b, - 0x15, 0xbd, 0x15, 0xe0, 0x16, 0x03, 0x16, 0x26, 0x16, 0x49, 0x16, 0x6c, - 0x16, 0x8f, 0x16, 0xb2, 0x16, 0xd6, 0x16, 0xfa, 0x17, 0x1d, 0x17, 0x41, - 0x17, 0x65, 0x17, 0x89, 0x17, 0xae, 0x17, 0xd2, 0x17, 0xf7, 0x18, 0x1b, - 0x18, 0x40, 0x18, 0x65, 0x18, 0x8a, 0x18, 0xaf, 0x18, 0xd5, 0x18, 0xfa, - 0x19, 0x20, 0x19, 0x45, 0x19, 0x6b, 0x19, 0x91, 0x19, 0xb7, 0x19, 0xdd, - 0x1a, 0x04, 0x1a, 0x2a, 0x1a, 0x51, 0x1a, 0x77, 0x1a, 0x9e, 0x1a, 0xc5, - 0x1a, 0xec, 0x1b, 0x14, 0x1b, 0x3b, 0x1b, 0x63, 0x1b, 0x8a, 0x1b, 0xb2, - 0x1b, 0xda, 0x1c, 0x02, 0x1c, 0x2a, 0x1c, 0x52, 0x1c, 0x7b, 0x1c, 0xa3, - 0x1c, 0xcc, 0x1c, 0xf5, 0x1d, 0x1e, 0x1d, 0x47, 0x1d, 0x70, 0x1d, 0x99, - 0x1d, 0xc3, 0x1d, 0xec, 0x1e, 0x16, 0x1e, 0x40, 0x1e, 0x6a, 0x1e, 0x94, - 0x1e, 0xbe, 0x1e, 0xe9, 0x1f, 0x13, 0x1f, 0x3e, 0x1f, 0x69, 0x1f, 0x94, - 0x1f, 0xbf, 0x1f, 0xea, 0x20, 0x15, 0x20, 0x41, 0x20, 0x6c, 0x20, 0x98, - 0x20, 0xc4, 0x20, 0xf0, 0x21, 0x1c, 0x21, 0x48, 0x21, 0x75, 0x21, 0xa1, - 0x21, 0xce, 0x21, 0xfb, 0x22, 0x27, 0x22, 0x55, 0x22, 0x82, 0x22, 0xaf, - 0x22, 0xdd, 0x23, 0x0a, 0x23, 0x38, 0x23, 0x66, 0x23, 0x94, 0x23, 0xc2, - 0x23, 0xf0, 0x24, 0x1f, 0x24, 0x4d, 0x24, 0x7c, 0x24, 0xab, 0x24, 0xda, - 0x25, 0x09, 0x25, 0x38, 0x25, 0x68, 0x25, 0x97, 0x25, 0xc7, 0x25, 0xf7, - 0x26, 0x27, 0x26, 0x57, 0x26, 0x87, 0x26, 0xb7, 0x26, 0xe8, 0x27, 0x18, - 0x27, 0x49, 0x27, 0x7a, 0x27, 0xab, 0x27, 0xdc, 0x28, 0x0d, 0x28, 0x3f, - 0x28, 0x71, 0x28, 0xa2, 0x28, 0xd4, 0x29, 0x06, 0x29, 0x38, 0x29, 0x6b, - 0x29, 0x9d, 0x29, 0xd0, 0x2a, 0x02, 0x2a, 0x35, 0x2a, 0x68, 0x2a, 0x9b, - 0x2a, 0xcf, 0x2b, 0x02, 0x2b, 0x36, 0x2b, 0x69, 0x2b, 0x9d, 0x2b, 0xd1, - 0x2c, 0x05, 0x2c, 0x39, 0x2c, 0x6e, 0x2c, 0xa2, 0x2c, 0xd7, 0x2d, 0x0c, - 0x2d, 0x41, 0x2d, 0x76, 0x2d, 0xab, 0x2d, 0xe1, 0x2e, 0x16, 0x2e, 0x4c, - 0x2e, 0x82, 0x2e, 0xb7, 0x2e, 0xee, 0x2f, 0x24, 0x2f, 0x5a, 0x2f, 0x91, - 0x2f, 0xc7, 0x2f, 0xfe, 0x30, 0x35, 0x30, 0x6c, 0x30, 0xa4, 0x30, 0xdb, - 0x31, 0x12, 0x31, 0x4a, 0x31, 0x82, 0x31, 0xba, 0x31, 0xf2, 0x32, 0x2a, - 0x32, 0x63, 0x32, 0x9b, 0x32, 0xd4, 0x33, 0x0d, 0x33, 0x46, 0x33, 0x7f, - 0x33, 0xb8, 0x33, 0xf1, 0x34, 0x2b, 0x34, 0x65, 0x34, 0x9e, 0x34, 0xd8, - 0x35, 0x13, 0x35, 0x4d, 0x35, 0x87, 0x35, 0xc2, 0x35, 0xfd, 0x36, 0x37, - 0x36, 0x72, 0x36, 0xae, 0x36, 0xe9, 0x37, 0x24, 0x37, 0x60, 0x37, 0x9c, - 0x37, 0xd7, 0x38, 0x14, 0x38, 0x50, 0x38, 0x8c, 0x38, 0xc8, 0x39, 0x05, - 0x39, 0x42, 0x39, 0x7f, 0x39, 0xbc, 0x39, 0xf9, 0x3a, 0x36, 0x3a, 0x74, - 0x3a, 0xb2, 0x3a, 0xef, 0x3b, 0x2d, 0x3b, 0x6b, 0x3b, 0xaa, 0x3b, 0xe8, - 0x3c, 0x27, 0x3c, 0x65, 0x3c, 0xa4, 0x3c, 0xe3, 0x3d, 0x22, 0x3d, 0x61, - 0x3d, 0xa1, 0x3d, 0xe0, 0x3e, 0x20, 0x3e, 0x60, 0x3e, 0xa0, 0x3e, 0xe0, - 0x3f, 0x21, 0x3f, 0x61, 0x3f, 0xa2, 0x3f, 0xe2, 0x40, 0x23, 0x40, 0x64, - 0x40, 0xa6, 0x40, 0xe7, 0x41, 0x29, 0x41, 0x6a, 0x41, 0xac, 0x41, 0xee, - 0x42, 0x30, 0x42, 0x72, 0x42, 0xb5, 0x42, 0xf7, 0x43, 0x3a, 0x43, 0x7d, - 0x43, 0xc0, 0x44, 0x03, 0x44, 0x47, 0x44, 0x8a, 0x44, 0xce, 0x45, 0x12, - 0x45, 0x55, 0x45, 0x9a, 0x45, 0xde, 0x46, 0x22, 0x46, 0x67, 0x46, 0xab, - 0x46, 0xf0, 0x47, 0x35, 0x47, 0x7b, 0x47, 0xc0, 0x48, 0x05, 0x48, 0x4b, - 0x48, 0x91, 0x48, 0xd7, 0x49, 0x1d, 0x49, 0x63, 0x49, 0xa9, 0x49, 0xf0, - 0x4a, 0x37, 0x4a, 0x7d, 0x4a, 0xc4, 0x4b, 0x0c, 0x4b, 0x53, 0x4b, 0x9a, - 0x4b, 0xe2, 0x4c, 0x2a, 0x4c, 0x72, 0x4c, 0xba, 0x4d, 0x02, 0x4d, 0x4a, - 0x4d, 0x93, 0x4d, 0xdc, 0x4e, 0x25, 0x4e, 0x6e, 0x4e, 0xb7, 0x4f, 0x00, - 0x4f, 0x49, 0x4f, 0x93, 0x4f, 0xdd, 0x50, 0x27, 0x50, 0x71, 0x50, 0xbb, - 0x51, 0x06, 0x51, 0x50, 0x51, 0x9b, 0x51, 0xe6, 0x52, 0x31, 0x52, 0x7c, - 0x52, 0xc7, 0x53, 0x13, 0x53, 0x5f, 0x53, 0xaa, 0x53, 0xf6, 0x54, 0x42, - 0x54, 0x8f, 0x54, 0xdb, 0x55, 0x28, 0x55, 0x75, 0x55, 0xc2, 0x56, 0x0f, - 0x56, 0x5c, 0x56, 0xa9, 0x56, 0xf7, 0x57, 0x44, 0x57, 0x92, 0x57, 0xe0, - 0x58, 0x2f, 0x58, 0x7d, 0x58, 0xcb, 0x59, 0x1a, 0x59, 0x69, 0x59, 0xb8, - 0x5a, 0x07, 0x5a, 0x56, 0x5a, 0xa6, 0x5a, 0xf5, 0x5b, 0x45, 0x5b, 0x95, - 0x5b, 0xe5, 0x5c, 0x35, 0x5c, 0x86, 0x5c, 0xd6, 0x5d, 0x27, 0x5d, 0x78, - 0x5d, 0xc9, 0x5e, 0x1a, 0x5e, 0x6c, 0x5e, 0xbd, 0x5f, 0x0f, 0x5f, 0x61, - 0x5f, 0xb3, 0x60, 0x05, 0x60, 0x57, 0x60, 0xaa, 0x60, 0xfc, 0x61, 0x4f, - 0x61, 0xa2, 0x61, 0xf5, 0x62, 0x49, 0x62, 0x9c, 0x62, 0xf0, 0x63, 0x43, - 0x63, 0x97, 0x63, 0xeb, 0x64, 0x40, 0x64, 0x94, 0x64, 0xe9, 0x65, 0x3d, - 0x65, 0x92, 0x65, 0xe7, 0x66, 0x3d, 0x66, 0x92, 0x66, 0xe8, 0x67, 0x3d, - 0x67, 0x93, 0x67, 0xe9, 0x68, 0x3f, 0x68, 0x96, 0x68, 0xec, 0x69, 0x43, - 0x69, 0x9a, 0x69, 0xf1, 0x6a, 0x48, 0x6a, 0x9f, 0x6a, 0xf7, 0x6b, 0x4f, - 0x6b, 0xa7, 0x6b, 0xff, 0x6c, 0x57, 0x6c, 0xaf, 0x6d, 0x08, 0x6d, 0x60, - 0x6d, 0xb9, 0x6e, 0x12, 0x6e, 0x6b, 0x6e, 0xc4, 0x6f, 0x1e, 0x6f, 0x78, - 0x6f, 0xd1, 0x70, 0x2b, 0x70, 0x86, 0x70, 0xe0, 0x71, 0x3a, 0x71, 0x95, - 0x71, 0xf0, 0x72, 0x4b, 0x72, 0xa6, 0x73, 0x01, 0x73, 0x5d, 0x73, 0xb8, - 0x74, 0x14, 0x74, 0x70, 0x74, 0xcc, 0x75, 0x28, 0x75, 0x85, 0x75, 0xe1, - 0x76, 0x3e, 0x76, 0x9b, 0x76, 0xf8, 0x77, 0x56, 0x77, 0xb3, 0x78, 0x11, - 0x78, 0x6e, 0x78, 0xcc, 0x79, 0x2a, 0x79, 0x89, 0x79, 0xe7, 0x7a, 0x46, - 0x7a, 0xa5, 0x7b, 0x04, 0x7b, 0x63, 0x7b, 0xc2, 0x7c, 0x21, 0x7c, 0x81, - 0x7c, 0xe1, 0x7d, 0x41, 0x7d, 0xa1, 0x7e, 0x01, 0x7e, 0x62, 0x7e, 0xc2, - 0x7f, 0x23, 0x7f, 0x84, 0x7f, 0xe5, 0x80, 0x47, 0x80, 0xa8, 0x81, 0x0a, - 0x81, 0x6b, 0x81, 0xcd, 0x82, 0x30, 0x82, 0x92, 0x82, 0xf4, 0x83, 0x57, - 0x83, 0xba, 0x84, 0x1d, 0x84, 0x80, 0x84, 0xe3, 0x85, 0x47, 0x85, 0xab, - 0x86, 0x0e, 0x86, 0x72, 0x86, 0xd7, 0x87, 0x3b, 0x87, 0x9f, 0x88, 0x04, - 0x88, 0x69, 0x88, 0xce, 0x89, 0x33, 0x89, 0x99, 0x89, 0xfe, 0x8a, 0x64, - 0x8a, 0xca, 0x8b, 0x30, 0x8b, 0x96, 0x8b, 0xfc, 0x8c, 0x63, 0x8c, 0xca, - 0x8d, 0x31, 0x8d, 0x98, 0x8d, 0xff, 0x8e, 0x66, 0x8e, 0xce, 0x8f, 0x36, - 0x8f, 0x9e, 0x90, 0x06, 0x90, 0x6e, 0x90, 0xd6, 0x91, 0x3f, 0x91, 0xa8, - 0x92, 0x11, 0x92, 0x7a, 0x92, 0xe3, 0x93, 0x4d, 0x93, 0xb6, 0x94, 0x20, - 0x94, 0x8a, 0x94, 0xf4, 0x95, 0x5f, 0x95, 0xc9, 0x96, 0x34, 0x96, 0x9f, - 0x97, 0x0a, 0x97, 0x75, 0x97, 0xe0, 0x98, 0x4c, 0x98, 0xb8, 0x99, 0x24, - 0x99, 0x90, 0x99, 0xfc, 0x9a, 0x68, 0x9a, 0xd5, 0x9b, 0x42, 0x9b, 0xaf, - 0x9c, 0x1c, 0x9c, 0x89, 0x9c, 0xf7, 0x9d, 0x64, 0x9d, 0xd2, 0x9e, 0x40, - 0x9e, 0xae, 0x9f, 0x1d, 0x9f, 0x8b, 0x9f, 0xfa, 0xa0, 0x69, 0xa0, 0xd8, - 0xa1, 0x47, 0xa1, 0xb6, 0xa2, 0x26, 0xa2, 0x96, 0xa3, 0x06, 0xa3, 0x76, - 0xa3, 0xe6, 0xa4, 0x56, 0xa4, 0xc7, 0xa5, 0x38, 0xa5, 0xa9, 0xa6, 0x1a, - 0xa6, 0x8b, 0xa6, 0xfd, 0xa7, 0x6e, 0xa7, 0xe0, 0xa8, 0x52, 0xa8, 0xc4, - 0xa9, 0x37, 0xa9, 0xa9, 0xaa, 0x1c, 0xaa, 0x8f, 0xab, 0x02, 0xab, 0x75, - 0xab, 0xe9, 0xac, 0x5c, 0xac, 0xd0, 0xad, 0x44, 0xad, 0xb8, 0xae, 0x2d, - 0xae, 0xa1, 0xaf, 0x16, 0xaf, 0x8b, 0xb0, 0x00, 0xb0, 0x75, 0xb0, 0xea, - 0xb1, 0x60, 0xb1, 0xd6, 0xb2, 0x4b, 0xb2, 0xc2, 0xb3, 0x38, 0xb3, 0xae, - 0xb4, 0x25, 0xb4, 0x9c, 0xb5, 0x13, 0xb5, 0x8a, 0xb6, 0x01, 0xb6, 0x79, - 0xb6, 0xf0, 0xb7, 0x68, 0xb7, 0xe0, 0xb8, 0x59, 0xb8, 0xd1, 0xb9, 0x4a, - 0xb9, 0xc2, 0xba, 0x3b, 0xba, 0xb5, 0xbb, 0x2e, 0xbb, 0xa7, 0xbc, 0x21, - 0xbc, 0x9b, 0xbd, 0x15, 0xbd, 0x8f, 0xbe, 0x0a, 0xbe, 0x84, 0xbe, 0xff, - 0xbf, 0x7a, 0xbf, 0xf5, 0xc0, 0x70, 0xc0, 0xec, 0xc1, 0x67, 0xc1, 0xe3, - 0xc2, 0x5f, 0xc2, 0xdb, 0xc3, 0x58, 0xc3, 0xd4, 0xc4, 0x51, 0xc4, 0xce, - 0xc5, 0x4b, 0xc5, 0xc8, 0xc6, 0x46, 0xc6, 0xc3, 0xc7, 0x41, 0xc7, 0xbf, - 0xc8, 0x3d, 0xc8, 0xbc, 0xc9, 0x3a, 0xc9, 0xb9, 0xca, 0x38, 0xca, 0xb7, - 0xcb, 0x36, 0xcb, 0xb6, 0xcc, 0x35, 0xcc, 0xb5, 0xcd, 0x35, 0xcd, 0xb5, - 0xce, 0x36, 0xce, 0xb6, 0xcf, 0x37, 0xcf, 0xb8, 0xd0, 0x39, 0xd0, 0xba, - 0xd1, 0x3c, 0xd1, 0xbe, 0xd2, 0x3f, 0xd2, 0xc1, 0xd3, 0x44, 0xd3, 0xc6, - 0xd4, 0x49, 0xd4, 0xcb, 0xd5, 0x4e, 0xd5, 0xd1, 0xd6, 0x55, 0xd6, 0xd8, - 0xd7, 0x5c, 0xd7, 0xe0, 0xd8, 0x64, 0xd8, 0xe8, 0xd9, 0x6c, 0xd9, 0xf1, - 0xda, 0x76, 0xda, 0xfb, 0xdb, 0x80, 0xdc, 0x05, 0xdc, 0x8a, 0xdd, 0x10, - 0xdd, 0x96, 0xde, 0x1c, 0xde, 0xa2, 0xdf, 0x29, 0xdf, 0xaf, 0xe0, 0x36, - 0xe0, 0xbd, 0xe1, 0x44, 0xe1, 0xcc, 0xe2, 0x53, 0xe2, 0xdb, 0xe3, 0x63, - 0xe3, 0xeb, 0xe4, 0x73, 0xe4, 0xfc, 0xe5, 0x84, 0xe6, 0x0d, 0xe6, 0x96, - 0xe7, 0x1f, 0xe7, 0xa9, 0xe8, 0x32, 0xe8, 0xbc, 0xe9, 0x46, 0xe9, 0xd0, - 0xea, 0x5b, 0xea, 0xe5, 0xeb, 0x70, 0xeb, 0xfb, 0xec, 0x86, 0xed, 0x11, - 0xed, 0x9c, 0xee, 0x28, 0xee, 0xb4, 0xef, 0x40, 0xef, 0xcc, 0xf0, 0x58, - 0xf0, 0xe5, 0xf1, 0x72, 0xf1, 0xff, 0xf2, 0x8c, 0xf3, 0x19, 0xf3, 0xa7, - 0xf4, 0x34, 0xf4, 0xc2, 0xf5, 0x50, 0xf5, 0xde, 0xf6, 0x6d, 0xf6, 0xfb, - 0xf7, 0x8a, 0xf8, 0x19, 0xf8, 0xa8, 0xf9, 0x38, 0xf9, 0xc7, 0xfa, 0x57, - 0xfa, 0xe7, 0xfb, 0x77, 0xfc, 0x07, 0xfc, 0x98, 0xfd, 0x29, 0xfd, 0xba, - 0xfe, 0x4b, 0xfe, 0xdc, 0xff, 0x6d, 0xff, 0xff, 0x58, 0x59, 0x5a, 0x20, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf3, 0x51, 0x00, 0x01, 0x00, 0x00, - 0x00, 0x01, 0x16, 0xcc, 0x74, 0x65, 0x78, 0x74, 0x00, 0x00, 0x00, 0x00, - 0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68, 0x74, 0x20, 0x41, 0x70, - 0x70, 0x6c, 0x65, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x2c, 0x20, 0x32, 0x30, - 0x30, 0x38, 0x00, 0x00, 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x1f, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x69, 0x63, 0x20, - 0x47, 0x72, 0x61, 0x79, 0x20, 0x47, 0x61, 0x6d, 0x6d, 0x61, 0x20, 0x32, - 0x2e, 0x32, 0x20, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x6c, 0x75, 0x63, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x0c, - 0x65, 0x6e, 0x55, 0x53, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0xdc, - 0x65, 0x73, 0x45, 0x53, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x01, 0x18, - 0x64, 0x61, 0x44, 0x4b, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x02, 0x2a, - 0x64, 0x65, 0x44, 0x45, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x01, 0xde, - 0x66, 0x69, 0x46, 0x49, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x02, 0xa0, - 0x66, 0x72, 0x46, 0x55, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x02, 0x62, - 0x69, 0x74, 0x49, 0x54, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x03, 0x70, - 0x6e, 0x6c, 0x4e, 0x4c, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, 0x64, - 0x6e, 0x62, 0x4e, 0x4f, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x03, 0xc4, - 0x70, 0x74, 0x42, 0x52, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x03, 0x26, - 0x73, 0x76, 0x53, 0x45, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x02, 0x2a, - 0x6a, 0x61, 0x4a, 0x50, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x03, 0xfe, - 0x6b, 0x6f, 0x4b, 0x52, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x04, 0x24, - 0x7a, 0x68, 0x54, 0x57, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x04, 0x46, - 0x7a, 0x68, 0x43, 0x4e, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x04, 0x64, - 0x72, 0x75, 0x52, 0x55, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x01, 0xa4, - 0x70, 0x6c, 0x50, 0x4c, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x02, 0xe6, - 0x00, 0x47, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x72, 0x00, 0x69, - 0x00, 0x63, 0x00, 0x20, 0x00, 0x47, 0x00, 0x72, 0x00, 0x61, 0x00, 0x79, - 0x00, 0x20, 0x00, 0x47, 0x00, 0x61, 0x00, 0x6d, 0x00, 0x6d, 0x00, 0x61, - 0x00, 0x20, 0x00, 0x32, 0x00, 0x2e, 0x00, 0x32, 0x00, 0x20, 0x00, 0x50, - 0x00, 0x72, 0x00, 0x6f, 0x00, 0x66, 0x00, 0x69, 0x00, 0x6c, 0x00, 0x65, - 0x00, 0x50, 0x00, 0x65, 0x00, 0x72, 0x00, 0x66, 0x00, 0x69, 0x00, 0x6c, - 0x00, 0x20, 0x00, 0x67, 0x00, 0x65, 0x00, 0x6e, 0x00, 0xe9, 0x00, 0x72, - 0x00, 0x69, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x20, 0x00, 0x64, 0x00, 0x65, - 0x00, 0x20, 0x00, 0x67, 0x00, 0x61, 0x00, 0x6d, 0x00, 0x6d, 0x00, 0x61, - 0x00, 0x20, 0x00, 0x64, 0x00, 0x65, 0x00, 0x20, 0x00, 0x67, 0x00, 0x72, - 0x00, 0x69, 0x00, 0x73, 0x00, 0x65, 0x00, 0x73, 0x00, 0x20, 0x00, 0x32, - 0x00, 0x2c, 0x00, 0x32, 0x00, 0x41, 0x00, 0x6c, 0x00, 0x67, 0x00, 0x65, - 0x00, 0x6d, 0x00, 0x65, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x20, 0x00, 0x67, - 0x00, 0x72, 0x00, 0x69, 0x00, 0x6a, 0x00, 0x73, 0x00, 0x20, 0x00, 0x67, - 0x00, 0x61, 0x00, 0x6d, 0x00, 0x6d, 0x00, 0x61, 0x00, 0x20, 0x00, 0x32, - 0x00, 0x2c, 0x00, 0x32, 0x00, 0x2d, 0x00, 0x70, 0x00, 0x72, 0x00, 0x6f, - 0x00, 0x66, 0x00, 0x69, 0x00, 0x65, 0x00, 0x6c, 0x04, 0x1e, 0x04, 0x31, - 0x04, 0x49, 0x04, 0x30, 0x04, 0x4f, 0x00, 0x20, 0x04, 0x41, 0x04, 0x35, - 0x04, 0x40, 0x04, 0x30, 0x04, 0x4f, 0x00, 0x20, 0x04, 0x33, 0x04, 0x30, - 0x04, 0x3c, 0x04, 0x3c, 0x04, 0x30, 0x00, 0x20, 0x00, 0x32, 0x00, 0x2c, - 0x00, 0x32, 0x00, 0x2d, 0x04, 0x3f, 0x04, 0x40, 0x04, 0x3e, 0x04, 0x44, - 0x04, 0x38, 0x04, 0x3b, 0x04, 0x4c, 0x00, 0x41, 0x00, 0x6c, 0x00, 0x6c, - 0x00, 0x67, 0x00, 0x65, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x69, 0x00, 0x6e, - 0x00, 0x65, 0x00, 0x73, 0x00, 0x20, 0x00, 0x47, 0x00, 0x72, 0x00, 0x61, - 0x00, 0x75, 0x00, 0x73, 0x00, 0x74, 0x00, 0x75, 0x00, 0x66, 0x00, 0x65, - 0x00, 0x6e, 0x00, 0x70, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x66, 0x00, 0x69, - 0x00, 0x6c, 0x00, 0x20, 0x00, 0x47, 0x00, 0x61, 0x00, 0x6d, 0x00, 0x6d, - 0x00, 0x61, 0x00, 0x20, 0x00, 0x32, 0x00, 0x2c, 0x00, 0x32, 0x00, 0x47, - 0x00, 0x65, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x72, 0x00, 0x69, 0x00, 0x73, - 0x00, 0x6b, 0x00, 0x20, 0x00, 0x67, 0x00, 0x72, 0x00, 0xe5, 0x00, 0x20, - 0x00, 0x32, 0x00, 0x2c, 0x00, 0x32, 0x00, 0x20, 0x00, 0x67, 0x00, 0x61, - 0x00, 0x6d, 0x00, 0x6d, 0x00, 0x61, 0x00, 0x70, 0x00, 0x72, 0x00, 0x6f, - 0x00, 0x66, 0x00, 0x69, 0x00, 0x6c, 0x00, 0x50, 0x00, 0x72, 0x00, 0x6f, - 0x00, 0x66, 0x00, 0x69, 0x00, 0x6c, 0x00, 0x20, 0x00, 0x67, 0x00, 0xe9, - 0x00, 0x6e, 0x00, 0xe9, 0x00, 0x72, 0x00, 0x69, 0x00, 0x71, 0x00, 0x75, - 0x00, 0x65, 0x00, 0x20, 0x00, 0x67, 0x00, 0x72, 0x00, 0x69, 0x00, 0x73, - 0x00, 0x20, 0x00, 0x67, 0x00, 0x61, 0x00, 0x6d, 0x00, 0x6d, 0x00, 0x61, - 0x00, 0x20, 0x00, 0x32, 0x00, 0x2c, 0x00, 0x32, 0x00, 0x59, 0x00, 0x6c, - 0x00, 0x65, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x20, - 0x00, 0x68, 0x00, 0x61, 0x00, 0x72, 0x00, 0x6d, 0x00, 0x61, 0x00, 0x61, - 0x00, 0x6e, 0x00, 0x20, 0x00, 0x67, 0x00, 0x61, 0x00, 0x6d, 0x00, 0x6d, - 0x00, 0x61, 0x00, 0x20, 0x00, 0x32, 0x00, 0x2c, 0x00, 0x32, 0x00, 0x20, - 0x00, 0x2d, 0x00, 0x70, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x66, 0x00, 0x69, - 0x00, 0x69, 0x00, 0x6c, 0x00, 0x69, 0x00, 0x4f, 0x00, 0x67, 0x00, 0xf3, - 0x00, 0x6c, 0x00, 0x6e, 0x00, 0x79, 0x00, 0x20, 0x00, 0x70, 0x00, 0x72, - 0x00, 0x6f, 0x00, 0x66, 0x00, 0x69, 0x00, 0x6c, 0x00, 0x20, 0x00, 0x73, - 0x00, 0x7a, 0x00, 0x61, 0x00, 0x72, 0x00, 0x6f, 0x01, 0x5b, 0x00, 0x63, - 0x00, 0x69, 0x00, 0x20, 0x00, 0x67, 0x00, 0x61, 0x00, 0x6d, 0x00, 0x6d, - 0x00, 0x61, 0x00, 0x20, 0x00, 0x32, 0x00, 0x2c, 0x00, 0x32, 0x00, 0x50, - 0x00, 0x65, 0x00, 0x72, 0x00, 0x66, 0x00, 0x69, 0x00, 0x6c, 0x00, 0x20, - 0x00, 0x47, 0x00, 0x65, 0x00, 0x6e, 0x00, 0xe9, 0x00, 0x72, 0x00, 0x69, - 0x00, 0x63, 0x00, 0x6f, 0x00, 0x20, 0x00, 0x64, 0x00, 0x61, 0x00, 0x20, - 0x00, 0x47, 0x00, 0x61, 0x00, 0x6d, 0x00, 0x61, 0x00, 0x20, 0x00, 0x64, - 0x00, 0x65, 0x00, 0x20, 0x00, 0x43, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x7a, - 0x00, 0x61, 0x00, 0x73, 0x00, 0x20, 0x00, 0x32, 0x00, 0x2c, 0x00, 0x32, - 0x00, 0x50, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x66, 0x00, 0x69, 0x00, 0x6c, - 0x00, 0x6f, 0x00, 0x20, 0x00, 0x67, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x65, - 0x00, 0x72, 0x00, 0x69, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x20, 0x00, 0x64, - 0x00, 0x65, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x61, 0x00, 0x20, 0x00, 0x67, - 0x00, 0x61, 0x00, 0x6d, 0x00, 0x6d, 0x00, 0x61, 0x00, 0x20, 0x00, 0x64, - 0x00, 0x65, 0x00, 0x69, 0x00, 0x20, 0x00, 0x67, 0x00, 0x72, 0x00, 0x69, - 0x00, 0x67, 0x00, 0x69, 0x00, 0x20, 0x00, 0x32, 0x00, 0x2c, 0x00, 0x32, - 0x00, 0x47, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x72, 0x00, 0x69, - 0x00, 0x73, 0x00, 0x6b, 0x00, 0x20, 0x00, 0x67, 0x00, 0x72, 0x00, 0xe5, - 0x00, 0x20, 0x00, 0x67, 0x00, 0x61, 0x00, 0x6d, 0x00, 0x6d, 0x00, 0x61, - 0x00, 0x20, 0x00, 0x32, 0x00, 0x2c, 0x00, 0x32, 0x00, 0x2d, 0x00, 0x70, - 0x00, 0x72, 0x00, 0x6f, 0x00, 0x66, 0x00, 0x69, 0x00, 0x6c, 0x4e, 0x00, - 0x82, 0x2c, 0x30, 0xb0, 0x30, 0xec, 0x30, 0xa4, 0x30, 0xac, 0x30, 0xf3, - 0x30, 0xde, 0x00, 0x20, 0x00, 0x32, 0x00, 0x2e, 0x00, 0x32, 0x00, 0x20, - 0x30, 0xd7, 0x30, 0xed, 0x30, 0xd5, 0x30, 0xa1, 0x30, 0xa4, 0x30, 0xeb, - 0xc7, 0x7c, 0xbc, 0x18, 0x00, 0x20, 0xd6, 0x8c, 0xc0, 0xc9, 0x00, 0x20, - 0xac, 0x10, 0xb9, 0xc8, 0x00, 0x20, 0x00, 0x32, 0x00, 0x2e, 0x00, 0x32, - 0x00, 0x20, 0xd5, 0x04, 0xb8, 0x5c, 0xd3, 0x0c, 0xc7, 0x7c, 0x90, 0x1a, - 0x75, 0x28, 0x70, 0x70, 0x96, 0x8e, 0x51, 0x49, 0x5e, 0xa6, 0x00, 0x20, - 0x00, 0x32, 0x00, 0x2e, 0x00, 0x32, 0x00, 0x20, 0x82, 0x72, 0x5f, 0x69, - 0x63, 0xcf, 0x8f, 0xf0, 0x90, 0x1a, 0x75, 0x28, 0x70, 0x70, 0x5e, 0xa6, - 0x7c, 0xfb, 0x65, 0x70, 0x00, 0x20, 0x00, 0x32, 0x00, 0x2e, 0x00, 0x32, - 0x00, 0x20, 0x63, 0xcf, 0x8f, 0xf0, 0x65, 0x87, 0x4e, 0xf6, 0x00, 0x00, - } - - sRGBV2MicroICCProfilePathToken = "\x00srgb_v2_micro.icc" - sGrayV2MicroICCProfilePathToken = "\x00sgray_v2_micro.icc" - sRGBIEC6196621ICCProfilePathToken = "\x00srgb_iec61966_2_1.icc" - genericGrayGamma22ICCProfilePathToken = "\x00generic_gray_gamma_2_2.icc" - - temporaryDirectory = "" - SRGBV2MicroICCProfilePath = sRGBV2MicroICCProfilePathToken - SGrayV2MicroICCProfilePath = sGrayV2MicroICCProfilePathToken - SRGBIEC6196621ICCProfilePath = sRGBIEC6196621ICCProfilePathToken - GenericGrayGamma22ICCProfilePath = genericGrayGamma22ICCProfilePathToken -) - -// Back support -func ensureLoadICCPath(name *string) (err error) { - if len(*name) > 0 && (*name)[0] == 0 { - switch *name { - case sRGBV2MicroICCProfilePathToken: - *name, err = GetSRGBV2MicroICCProfilePath() - return - case sGrayV2MicroICCProfilePathToken: - *name, err = GetSGrayV2MicroICCProfilePath() - return - case sRGBIEC6196621ICCProfilePathToken: - *name, err = GetSRGBIEC6196621ICCProfilePath() - return - case genericGrayGamma22ICCProfilePathToken: - *name, err = GetGenericGrayGamma22ICCProfilePath() - return - } - } - return -} - -var tempDirOnce sync.Once -var tempDirErr error - -func getTemporaryDirectory() (string, error) { - tempDirOnce.Do(func() { - temporaryDirectory, tempDirErr = os.MkdirTemp("", "govips-") - }) - return temporaryDirectory, tempDirErr -} - -var lockIcc sync.Mutex - -func GetSRGBV2MicroICCProfilePath() (string, error) { - return getOrLoad(&SRGBV2MicroICCProfilePath, "srgb_v2_micro.icc", sRGBV2MicroICCProfile) -} - -func GetSGrayV2MicroICCProfilePath() (string, error) { - return getOrLoad(&SGrayV2MicroICCProfilePath, "sgray_v2_micro.icc", sGrayV2MicroICCProfile) -} - -func GetSRGBIEC6196621ICCProfilePath() (string, error) { - return getOrLoad(&SRGBIEC6196621ICCProfilePath, "srgb_iec61966_2_1.icc", sRGBIEC6196621ICCProfile) -} - -func GetGenericGrayGamma22ICCProfilePath() (string, error) { - return getOrLoad(&GenericGrayGamma22ICCProfilePath, "generic_gray_gamma_2_2.icc", genericGrayGamma22ICCProfile) -} - -func getOrLoad(pathFile *string, name string, fileBytes []byte) (string, error) { - lockIcc.Lock() - defer lockIcc.Unlock() - if len(*pathFile) > 0 && (*pathFile)[0] != 0 { - return *pathFile, nil - } - - if _, err := getTemporaryDirectory(); err != nil { - return "", err - } - - *pathFile = filepath.Join(temporaryDirectory, name) - if err := os.WriteFile(*pathFile, fileBytes, 0600); err != nil { - return "", err - } - return *pathFile, nil -} diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/image.c b/vendor/github.com/davidbyttow/govips/v2/vips/image.c deleted file mode 100644 index a9046f1eb6..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/image.c +++ /dev/null @@ -1,16 +0,0 @@ -#include "image.h" - -int has_alpha_channel(VipsImage *image) { return vips_image_hasalpha(image); } - -void clear_image(VipsImage **image) { - // Reference-counting in libvips: https://www.libvips.org/API/current/using-from-c.html#using-C-ref - // https://docs.gtk.org/gobject/method.Object.unref.html - if (G_IS_OBJECT(*image)) g_object_unref(*image); -} - -VipsImage *create_image_from_memory_copy(const void *data, size_t size, - int width, int height, int bands, - VipsBandFormat format) { - return vips_image_new_from_memory_copy(data, size, width, height, bands, - format); -} diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/image.go b/vendor/github.com/davidbyttow/govips/v2/vips/image.go deleted file mode 100644 index d3a3e6e649..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/image.go +++ /dev/null @@ -1,988 +0,0 @@ -package vips - -// #include "image.h" -import "C" - -import ( - "errors" - "fmt" - "image" - "image/draw" - _ "image/gif" - _ "image/jpeg" - _ "image/png" - "io" - "os" - "runtime" - "strconv" - "strings" - "sync" - "unsafe" - - _ "golang.org/x/image/webp" -) - -const GaussBlurDefaultMinAMpl = 0.2 - -// PreMultiplicationState stores the pre-multiplication band format of the image -type PreMultiplicationState struct { - bandFormat BandFormat -} - -// ImageRef contains a libvips image and manages its lifecycle. -type ImageRef struct { - // NOTE: We keep a reference to this so that the input buffer is - // never garbage collected during processing. Some image loaders use random - // access transcoding and therefore need the original buffer to be in memory. - buf []byte - image *C.VipsImage - format ImageType - originalFormat ImageType - lock sync.Mutex - preMultiplication *PreMultiplicationState - optimizedIccProfile string - - // streamSource is non-nil for sequentially stream-loaded images - // (LoadImageFromReader with AccessSequential): the image pulls - // pixels from the source on demand, so the C source and the Go - // reader stay alive until Close or materialize. See stream.go. - streamSource *streamSourceRef -} - -// ImageMetadata is a data structure holding the width, height, orientation and other metadata of the picture. -type ImageMetadata struct { - Format ImageType - Width int - Height int - Colorspace Interpretation - Orientation int - Pages int -} - -type Parameter struct { - value interface{} - isSet bool -} - -func (p *Parameter) IsSet() bool { - return p.isSet -} - -func (p *Parameter) set(v interface{}) { - p.value = v - p.isSet = true -} - -type BoolParameter struct { - Parameter -} - -func (p *BoolParameter) Set(v bool) { - p.set(v) -} - -func (p *BoolParameter) Get() bool { - return p.value.(bool) -} - -type IntParameter struct { - Parameter -} - -func (p *IntParameter) Set(v int) { - p.set(v) -} - -func (p *IntParameter) Get() int { - return p.value.(int) -} - -type Float64Parameter struct { - Parameter -} - -func (p *Float64Parameter) Set(v float64) { - p.set(v) -} - -func (p *Float64Parameter) Get() float64 { - return p.value.(float64) -} - -// ImportParams are options for loading an image. Some are type-specific. -// For default loading, use NewImportParams() or specify nil -type ImportParams struct { - AutoRotate BoolParameter - FailOnError BoolParameter - Page IntParameter - NumPages IntParameter - Density IntParameter - - JpegShrinkFactor IntParameter - WebpScaleFactor Float64Parameter - HeifThumbnail BoolParameter - SvgUnlimited BoolParameter - Access IntParameter -} - -// NewImportParams creates default ImportParams -func NewImportParams() *ImportParams { - p := &ImportParams{} - p.FailOnError.Set(true) - return p -} - -// OptionString convert import params to option_string -func (i *ImportParams) OptionString() string { - var values []string - if v := i.NumPages; v.IsSet() { - values = append(values, "n="+strconv.Itoa(v.Get())) - } - if v := i.Page; v.IsSet() { - values = append(values, "page="+strconv.Itoa(v.Get())) - } - if v := i.Density; v.IsSet() { - values = append(values, "dpi="+strconv.Itoa(v.Get())) - } - if v := i.FailOnError; v.IsSet() { - values = append(values, "fail="+boolToStr(v.Get())) - } - if v := i.JpegShrinkFactor; v.IsSet() { - values = append(values, "shrink="+strconv.Itoa(v.Get())) - } - if v := i.WebpScaleFactor; v.IsSet() { - values = append(values, "scale="+strconv.FormatFloat(v.Get(), 'f', -1, 64)) - } - if v := i.AutoRotate; v.IsSet() { - values = append(values, "autorotate="+boolToStr(v.Get())) - } - if v := i.SvgUnlimited; v.IsSet() { - values = append(values, "unlimited="+boolToStr(v.Get())) - } - if v := i.HeifThumbnail; v.IsSet() { - values = append(values, "thumbnail="+boolToStr(v.Get())) - } - if v := i.Access; v.IsSet() { - values = append(values, "access="+strconv.Itoa(v.Get())) - } - return strings.Join(values, ",") -} - -func boolToStr(v bool) string { - if v { - return "TRUE" - } - return "FALSE" -} - -// ExportParams are options when exporting an image to file or buffer. -// Deprecated: Use format-specific params -type ExportParams struct { - Format ImageType - Quality int - Compression int - Interlaced bool - Lossless bool - Effort int - StripMetadata bool - OptimizeCoding bool // jpeg param - SubsampleMode SubsampleMode // jpeg param - TrellisQuant bool // jpeg param - OvershootDeringing bool // jpeg param - OptimizeScans bool // jpeg param - QuantTable int // jpeg param - Speed int // avif param -} - -// NewDefaultExportParams creates default values for an export when image type is not JPEG, PNG or WEBP. -// By default, govips creates interlaced, lossy images with a quality of 80/100 and compression of 6/10. -// As these are default values for a wide variety of image formats, their application varies. -// Some formats use the quality parameters, some compression, etc. -// Deprecated: Use format-specific params -func NewDefaultExportParams() *ExportParams { - return &ExportParams{ - Format: ImageTypeUnknown, // defaults to the starting encoder - Quality: 80, - Compression: 6, - Interlaced: true, - Lossless: false, - Effort: 4, - } -} - -// NewDefaultJPEGExportParams creates default values for an export of a JPEG image. -// By default, govips creates interlaced JPEGs with a quality of 80/100. -// Deprecated: Use NewJpegExportParams -func NewDefaultJPEGExportParams() *ExportParams { - return &ExportParams{ - Format: ImageTypeJPEG, - Quality: 80, - Interlaced: true, - } -} - -// NewDefaultPNGExportParams creates default values for an export of a PNG image. -// By default, govips creates non-interlaced PNGs with a compression of 6/10. -// Deprecated: Use NewPngExportParams -func NewDefaultPNGExportParams() *ExportParams { - return &ExportParams{ - Format: ImageTypePNG, - Compression: 6, - Interlaced: false, - } -} - -// NewDefaultWEBPExportParams creates default values for an export of a WEBP image. -// By default, govips creates lossy images with a quality of 75/100. -// Deprecated: Use NewWebpExportParams -func NewDefaultWEBPExportParams() *ExportParams { - return &ExportParams{ - Format: ImageTypeWEBP, - Quality: 75, - Lossless: false, - Effort: 4, - } -} - -// JpegExportParams are options when exporting a JPEG to file or buffer -type JpegExportParams struct { - StripMetadata bool - Quality int - Interlace bool - OptimizeCoding bool - SubsampleMode SubsampleMode - TrellisQuant bool - OvershootDeringing bool - OptimizeScans bool - QuantTable int - - // Keep selects which metadata to retain (libvips's "keep" option; see - // ForeignKeep). The zero value leaves it unset, so StripMetadata (where - // present) decides as before. When set, it takes precedence over - // StripMetadata. Requires libvips 8.15+; saving returns an error if Keep - // is set on an older libvips. - Keep ForeignKeep -} - -// NewJpegExportParams creates default values for an export of a JPEG image. -// By default, govips creates interlaced JPEGs with a quality of 80/100. -func NewJpegExportParams() *JpegExportParams { - return &JpegExportParams{ - Quality: 80, - Interlace: true, - } -} - -// PngExportParams are options when exporting a PNG to file or buffer -type PngExportParams struct { - StripMetadata bool - Compression int - Filter PngFilter - Interlace bool - Quality int - Palette bool - Dither float64 - Bitdepth int - Profile string - - // Keep selects which metadata to retain (libvips's "keep" option; see - // ForeignKeep). The zero value leaves it unset, so StripMetadata (where - // present) decides as before. When set, it takes precedence over - // StripMetadata. Requires libvips 8.15+; saving returns an error if Keep - // is set on an older libvips. - Keep ForeignKeep -} - -// NewPngExportParams creates default values for an export of a PNG image. -// By default, govips creates non-interlaced PNGs with a compression of 6/10. -func NewPngExportParams() *PngExportParams { - return &PngExportParams{ - Compression: 6, - Filter: PngFilterNone, - Interlace: false, - Palette: false, - } -} - -// WebpExportParams are options when exporting a WEBP to file or buffer -// see https://www.libvips.org/API/current/VipsForeignSave.html#vips-webpsave -// for details on each parameter -type WebpExportParams struct { - StripMetadata bool - Quality int - Lossless bool - NearLossless bool - ReductionEffort int - IccProfile string - MinSize bool - MinKeyFrames int - MaxKeyFrames int - // TargetSize is the desired output size in bytes (libvips's webpsave - // "target_size" option, passed straight through to libwebp's own - // WebPConfig.target_size). When set (> 0), it takes precedence over - // Quality: libwebp runs its own internal search over the quality range, - // using more encoding passes, to produce output close to this size. It - // is a best effort: the resulting size may still land above or below - // the target. Leave at 0 (the default) to encode at Quality instead. - // - // Requires libvips 8.17.4+ (when target_size was added to webpsave); - // ExportWebp returns an error if TargetSize is set on an older libvips. - TargetSize int - - // Keep selects which metadata to retain (libvips's "keep" option; see - // ForeignKeep). The zero value leaves it unset, so StripMetadata decides, - // as for the other formats: the source image's ICC profile is kept - // unless StripMetadata is set. A profile from IccProfile or - // OptimizeICCProfile replaces the source profile and is embedded even - // when StripMetadata is set. When set, Keep takes precedence over - // StripMetadata, and it - // alone decides whether an ICC profile is written: without - // ForeignKeepIcc no profile is embedded, whatever its source. With - // ForeignKeepIcc, the embedded profile is the one the path already - // chooses: ExportWebp uses the profile picked by OptimizeICCProfile - // (and ignores IccProfile, as before), while SaveToWriterWebp uses - // IccProfile. With neither, the source image's profile is kept. - // Requires libvips 8.15+; saving returns an error if Keep is set on an - // older libvips. - Keep ForeignKeep -} - -// NewWebpExportParams creates default values for an export of a WEBP image. -// By default, govips creates lossy images with a quality of 75/100. -func NewWebpExportParams() *WebpExportParams { - return &WebpExportParams{ - Quality: 75, - Lossless: false, - NearLossless: false, - ReductionEffort: 4, - } -} - -// TiffExportParams are options when exporting a TIFF to file or buffer -type TiffExportParams struct { - StripMetadata bool - Quality int - Compression TiffCompression - Predictor TiffPredictor - Pyramid bool - Tile bool - TileHeight int - TileWidth int - - // Keep selects which metadata to retain (libvips's "keep" option; see - // ForeignKeep). The zero value leaves it unset, so StripMetadata (where - // present) decides as before. When set, it takes precedence over - // StripMetadata. Requires libvips 8.15+; saving returns an error if Keep - // is set on an older libvips. - Keep ForeignKeep -} - -// NewTiffExportParams creates default values for an export of a TIFF image. -func NewTiffExportParams() *TiffExportParams { - return &TiffExportParams{ - Quality: 80, - Compression: TiffCompressionLzw, - Predictor: TiffPredictorHorizontal, - Pyramid: false, - Tile: false, - TileHeight: 256, - TileWidth: 256, - } -} - -// GifExportParams are options when exporting a GIF to file or buffer. -// -// For vips 8.12+, native gifsave is used. The relevant parameters are Dither, -// Effort, and Bitdepth. Quality is ignored because native gifsave does not -// support a quality parameter. -// -// For vips below 8.12, magicksave is used as a fallback. The relevant -// parameters are Quality and Bitdepth. -// -// StripMetadata has no effect on GIF images. -type GifExportParams struct { - StripMetadata bool - // Quality is only used with vips < 8.12 (magicksave fallback). - // Ignored by native gifsave in vips 8.12+. - Quality int - Dither float64 - Effort int - Bitdepth int - - // Keep selects which metadata to retain (libvips's "keep" option; see - // ForeignKeep). The zero value leaves it unset, so StripMetadata (where - // present) decides as before. When set, it takes precedence over - // StripMetadata. Requires libvips 8.15+; saving returns an error if Keep - // is set on an older libvips. - Keep ForeignKeep -} - -// NewGifExportParams creates default values for an export of a GIF image. -func NewGifExportParams() *GifExportParams { - return &GifExportParams{ - Quality: 75, - Effort: 7, - Bitdepth: 8, - } -} - -// HeifExportParams are options when exporting a HEIF to file or buffer -type HeifExportParams struct { - Quality int - Bitdepth int - Effort int - Lossless bool - - // Keep selects which metadata to retain (libvips's "keep" option; see - // ForeignKeep). The zero value leaves it unset, so StripMetadata (where - // present) decides as before. When set, it takes precedence over - // StripMetadata. Requires libvips 8.15+; saving returns an error if Keep - // is set on an older libvips. - Keep ForeignKeep -} - -// NewHeifExportParams creates default values for an export of a HEIF image. -func NewHeifExportParams() *HeifExportParams { - return &HeifExportParams{ - Quality: 80, - Bitdepth: 8, - Effort: 5, - Lossless: false, - } -} - -// AvifExportParams are options when exporting an AVIF to file or buffer. -type AvifExportParams struct { - StripMetadata bool - Quality int - Bitdepth int - Effort int - Lossless bool - - // DEPRECATED - Use Effort instead. - Speed int - - // Keep selects which metadata to retain (libvips's "keep" option; see - // ForeignKeep). The zero value leaves it unset, so StripMetadata (where - // present) decides as before. When set, it takes precedence over - // StripMetadata. Requires libvips 8.15+; saving returns an error if Keep - // is set on an older libvips. - Keep ForeignKeep -} - -// NewAvifExportParams creates default values for an export of an AVIF image. -func NewAvifExportParams() *AvifExportParams { - return &AvifExportParams{ - Quality: 80, - Bitdepth: 8, - Effort: 5, - Lossless: false, - } -} - -// Jp2kExportParams are options when exporting an JPEG2000 to file or buffer. -type Jp2kExportParams struct { - Quality int - Lossless bool - TileWidth int - TileHeight int - SubsampleMode SubsampleMode - - // Keep selects which metadata to retain (libvips's "keep" option; see - // ForeignKeep). The zero value leaves it unset, so StripMetadata (where - // present) decides as before. When set, it takes precedence over - // StripMetadata. Requires libvips 8.15+; saving returns an error if Keep - // is set on an older libvips. - Keep ForeignKeep -} - -// NewJp2kExportParams creates default values for an export of an JPEG2000 image. -func NewJp2kExportParams() *Jp2kExportParams { - return &Jp2kExportParams{ - Quality: 80, - Lossless: false, - TileWidth: 512, - TileHeight: 512, - } -} - -// JxlExportParams are options when exporting an JXL to file or buffer. -type JxlExportParams struct { - Quality int - Lossless bool - Tier int - Distance float64 - Effort int - - // Keep selects which metadata to retain (libvips's "keep" option; see - // ForeignKeep). The zero value leaves it unset, so StripMetadata (where - // present) decides as before. When set, it takes precedence over - // StripMetadata. Requires libvips 8.15+; saving returns an error if Keep - // is set on an older libvips. - Keep ForeignKeep -} - -// NewJxlExportParams creates default values for an export of an JXL image. -func NewJxlExportParams() *JxlExportParams { - return &JxlExportParams{ - Quality: 75, - Lossless: false, - Effort: 7, - Distance: 1.0, - } -} - -// MagickExportParams are options when exporting an image to file or buffer by ImageMagick. -type MagickExportParams struct { - Quality int - Format string - OptimizeGifFrames bool - OptimizeGifTransparency bool - BitDepth int - - // Keep selects which metadata to retain (libvips's "keep" option; see - // ForeignKeep). The zero value leaves it unset, so StripMetadata (where - // present) decides as before. When set, it takes precedence over - // StripMetadata. Requires libvips 8.15+; saving returns an error if Keep - // is set on an older libvips. - Keep ForeignKeep -} - -// NewMagickExportParams creates default values for an export of an image by ImageMagick. -func NewMagickExportParams() *MagickExportParams { - return &MagickExportParams{ - Quality: 75, - } -} - -// NewImageFromReader loads an ImageRef from the given reader by reading -// the entire stream into memory first (io.ReadAll). For large inputs -// prefer LoadImageFromReader, which streams compressed bytes through -// libvips without buffering the whole input in Go memory. -func NewImageFromReader(r io.Reader) (*ImageRef, error) { - buf, err := io.ReadAll(r) - if err != nil { - return nil, err - } - - return NewImageFromBuffer(buf) -} - -// NewImageFromFile loads an image from file and creates a new ImageRef -func NewImageFromFile(file string) (*ImageRef, error) { - return LoadImageFromFile(file, nil) -} - -// LoadImageFromFile loads an image from file and creates a new ImageRef -func LoadImageFromFile(file string, params *ImportParams) (*ImageRef, error) { - buf, err := os.ReadFile(file) - if err != nil { - return nil, err - } - - govipsLog("govips", LogLevelDebug, fmt.Sprintf("creating imageRef from file %s", file)) - return LoadImageFromBuffer(buf, params) -} - -// NewImageFromBuffer loads an image buffer and creates a new Image -func NewImageFromBuffer(buf []byte) (*ImageRef, error) { - return LoadImageFromBuffer(buf, nil) -} - -// LoadImageFromBuffer loads an image buffer and creates a new Image -func LoadImageFromBuffer(buf []byte, params *ImportParams) (*ImageRef, error) { - if err := startupIfNeeded(); err != nil { - return nil, err - } - - if params == nil { - params = NewImportParams() - } - - vipsImage, currentFormat, originalFormat, err := vipsLoadFromBuffer(buf, params) - if err != nil { - return nil, err - } - - ref := newImageRef(vipsImage, currentFormat, originalFormat, buf) - - govipsLog("govips", LogLevelDebug, fmt.Sprintf("created imageRef %p", ref)) - return ref, nil -} - -// NewThumbnailFromFile loads an image from file and creates a new ImageRef with thumbnail crop -func NewThumbnailFromFile(file string, width, height int, crop Interesting) (*ImageRef, error) { - return LoadThumbnailFromFile(file, width, height, crop, SizeBoth, nil) -} - -// NewThumbnailFromBuffer loads an image buffer and creates a new Image with thumbnail crop -func NewThumbnailFromBuffer(buf []byte, width, height int, crop Interesting) (*ImageRef, error) { - return LoadThumbnailFromBuffer(buf, width, height, crop, SizeBoth, nil) -} - -// NewThumbnailWithSizeFromFile loads an image from file and creates a new ImageRef with thumbnail crop and size -func NewThumbnailWithSizeFromFile(file string, width, height int, crop Interesting, size Size) (*ImageRef, error) { - return LoadThumbnailFromFile(file, width, height, crop, size, nil) -} - -// LoadThumbnailFromFile loads an image from file and creates a new ImageRef with thumbnail crop and size -func LoadThumbnailFromFile(file string, width, height int, crop Interesting, size Size, params *ImportParams) (*ImageRef, error) { - if err := startupIfNeeded(); err != nil { - return nil, err - } - - vipsImage, format, err := vipsThumbnailFromFile(file, width, height, crop, size, params) - if err != nil { - return nil, err - } - - ref := newImageRef(vipsImage, format, format, nil) - - govipsLog("govips", LogLevelDebug, fmt.Sprintf("created imageref %p", ref)) - return ref, nil -} - -// NewThumbnailWithSizeFromBuffer loads an image buffer and creates a new Image with thumbnail crop and size -func NewThumbnailWithSizeFromBuffer(buf []byte, width, height int, crop Interesting, size Size) (*ImageRef, error) { - return LoadThumbnailFromBuffer(buf, width, height, crop, size, nil) -} - -// LoadThumbnailFromBuffer loads an image buffer and creates a new Image with thumbnail crop and size -func LoadThumbnailFromBuffer(buf []byte, width, height int, crop Interesting, size Size, params *ImportParams) (*ImageRef, error) { - if err := startupIfNeeded(); err != nil { - return nil, err - } - - vipsImage, format, err := vipsThumbnailFromBuffer(buf, width, height, crop, size, params) - if err != nil { - return nil, err - } - - ref := newImageRef(vipsImage, format, format, buf) - - govipsLog("govips", LogLevelDebug, fmt.Sprintf("created imageref %p", ref)) - return ref, nil -} - -// Metadata returns the metadata (ImageMetadata struct) of the associated ImageRef -func (r *ImageRef) Metadata() *ImageMetadata { - return &ImageMetadata{ - Format: r.Format(), - Width: r.Width(), - Height: r.Height(), - Orientation: r.Orientation(), - Colorspace: r.ColorSpace(), - Pages: r.Pages(), - } -} - -// Copy creates a new copy of the given image. -func (r *ImageRef) Copy() (*ImageRef, error) { - defer runtime.KeepAlive(r) - out, err := vipsGenCopy(r.image, nil) - if err != nil { - return nil, err - } - - return newImageRef(out, r.format, r.originalFormat, r.buf), nil -} - -// Copy creates a new copy of the given image with the new X and Y resolution (PPI). -func (r *ImageRef) CopyChangingResolution(xres, yres float64) (*ImageRef, error) { - defer runtime.KeepAlive(r) - out, err := vipsGenCopy(r.image, &CopyOptions{Xres: &xres, Yres: &yres}) - if err != nil { - return nil, err - } - - return newImageRef(out, r.format, r.originalFormat, r.buf), nil -} - -// Copy creates a new copy of the given image with the interpretation. -func (r *ImageRef) CopyChangingInterpretation(interpretation Interpretation) (*ImageRef, error) { - defer runtime.KeepAlive(r) - out, err := vipsGenCopy(r.image, &CopyOptions{Interpretation: &interpretation}) - if err != nil { - return nil, err - } - - return newImageRef(out, r.format, r.originalFormat, r.buf), nil -} - -// XYZ creates a two-band uint32 image where the elements in the first band have the value of their x coordinate -// and elements in the second band have their y coordinate. -func XYZ(width, height int) (*ImageRef, error) { - vipsImage, err := vipsGenXyz(width, height, nil) - return newImageRef(vipsImage, ImageTypeUnknown, ImageTypeUnknown, nil), err -} - -// Identity creates an identity lookup table, which will leave an image unchanged when applied with Maplut. -// Each entry in the table has a value equal to its position. -func Identity(ushort bool) (*ImageRef, error) { - img, err := vipsGenIdentity(&IdentityOptions{Ushort: &ushort}) - return newImageRef(img, ImageTypeUnknown, ImageTypeUnknown, nil), err -} - -// Black creates a new black image of the specified size -func Black(width, height int) (*ImageRef, error) { - vipsImage, err := vipsGenBlack(width, height, nil) - if err != nil { - return nil, err - } - return newImageRef(vipsImage, ImageTypeUnknown, ImageTypeUnknown, nil), nil -} - -// Grey creates a horizontal gradient image (ramp from black to white). -// When uchar is true, pixel values are 0-255 uint8; when false, 0.0-1.0 float. -// Useful for creating gradient overlays when combined with rotation, BandJoin, and Composite. -func Grey(width, height int, uchar bool) (*ImageRef, error) { - img, err := vipsGenGrey(width, height, &GreyOptions{Uchar: &uchar}) - if err != nil { - return nil, err - } - return newImageRef(img, ImageTypeUnknown, ImageTypeUnknown, nil), nil -} - -// NewTransparentCanvas creates a fully transparent RGBA image of the given dimensions. -// The image is in sRGB color space with 4 bands (RGBA), all channels set to 0. -func NewTransparentCanvas(width, height int) (*ImageRef, error) { - ref, err := Black(width, height) - if err != nil { - return nil, err - } - - if err := ref.ToColorSpace(InterpretationSRGB); err != nil { - ref.Close() - return nil, err - } - - if err := ref.BandJoinConst([]float64{0}); err != nil { - ref.Close() - return nil, err - } - - return ref, nil -} - -// Text draws the string text to an image. -func Text(params *TextParams) (*ImageRef, error) { - img, err := vipsText(params) - return newImageRef(img, ImageTypeUnknown, ImageTypeUnknown, nil), err -} - -// NewImageFromGoImage creates a new ImageRef from a Go image.Image. -// The image is normalized to NRGBA (non-premultiplied RGBA, 8-bit) and -// imported into libvips in sRGB color space. -func NewImageFromGoImage(img image.Image) (*ImageRef, error) { - if err := startupIfNeeded(); err != nil { - return nil, err - } - - bounds := img.Bounds() - width := bounds.Dx() - height := bounds.Dy() - - if width == 0 || height == 0 { - return nil, errors.New("image has zero dimensions") - } - - // Normalize to NRGBA - var nrgba *image.NRGBA - if n, ok := img.(*image.NRGBA); ok && n.Rect.Min.X == 0 && n.Rect.Min.Y == 0 && n.Stride == width*4 { - nrgba = n - } else { - nrgba = image.NewNRGBA(image.Rect(0, 0, width, height)) - draw.Draw(nrgba, nrgba.Bounds(), img, bounds.Min, draw.Src) - } - - // Create vips image from pixel data (copies data, safe for Go GC) - vipsImage := C.create_image_from_memory_copy( - unsafe.Pointer(&nrgba.Pix[0]), - C.size_t(len(nrgba.Pix)), - C.int(width), - C.int(height), - 4, - C.VIPS_FORMAT_UCHAR, - ) - runtime.KeepAlive(nrgba) - if vipsImage == nil { - return nil, errors.New("failed to create vips image from memory") - } - - // Set interpretation to sRGB - vipsImage.Type = C.VIPS_INTERPRETATION_sRGB - - return newImageRef(vipsImage, ImageTypeUnknown, ImageTypeUnknown, nil), nil -} - -// NewImageFromMemory creates a new ImageRef from a raw, uncompressed pixel -// buffer. The buffer is interpreted as height rows of width pixels, each pixel -// holding bands samples of the given BandFormat, laid out contiguously (no row -// stride padding). -// -// Use this for raw byte arrays from sources like ML inference outputs (ONNX, -// TensorFlow), camera sensors, or any in-memory pixel data. For Go's -// image.Image, use NewImageFromGoImage. For compressed bytes (PNG, JPEG, etc.), -// use NewImageFromBuffer. -// -// The pixel data is copied into libvips, so the caller is free to reuse or -// free the input slice after this call returns. -func NewImageFromMemory(pixels []byte, width, height, bands int, format BandFormat, interpretation Interpretation) (*ImageRef, error) { - if err := startupIfNeeded(); err != nil { - return nil, err - } - - if width <= 0 || height <= 0 || bands <= 0 { - return nil, fmt.Errorf("invalid dimensions: width=%d height=%d bands=%d", width, height, bands) - } - - bytesPerSample, ok := bandFormatSizes[format] - if !ok { - return nil, fmt.Errorf("unsupported band format: %d", format) - } - - expected := width * height * bands * bytesPerSample - if len(pixels) != expected { - return nil, fmt.Errorf("pixel buffer size mismatch: got %d bytes, expected %d (%dx%dx%d samples of %d bytes)", - len(pixels), expected, width, height, bands, bytesPerSample) - } - - vipsImage := C.create_image_from_memory_copy( - unsafe.Pointer(&pixels[0]), - C.size_t(len(pixels)), - C.int(width), - C.int(height), - C.int(bands), - C.VipsBandFormat(format), - ) - runtime.KeepAlive(pixels) - if vipsImage == nil { - return nil, errors.New("failed to create vips image from memory") - } - - vipsImage.Type = C.VipsInterpretation(interpretation) - - return newImageRef(vipsImage, ImageTypeUnknown, ImageTypeUnknown, nil), nil -} - -// bandFormatSizes is the byte size of one sample for each supported BandFormat. -// Complex/DPComplex are excluded — vips_image_new_from_memory rejects them in -// practice and the size depends on real/imag pairing semantics. -var bandFormatSizes = map[BandFormat]int{ - BandFormatUchar: 1, - BandFormatChar: 1, - BandFormatUshort: 2, - BandFormatShort: 2, - BandFormatUint: 4, - BandFormatInt: 4, - BandFormatFloat: 4, - BandFormatDouble: 8, -} - -func newImageRef(vipsImage *C.VipsImage, currentFormat ImageType, originalFormat ImageType, buf []byte) *ImageRef { - imageRef := &ImageRef{ - image: vipsImage, - format: currentFormat, - originalFormat: originalFormat, - buf: buf, - } - openImageRefs.Add(1) - runtime.SetFinalizer(imageRef, finalizeImage) - - return imageRef -} - -func finalizeImage(ref *ImageRef) { - govipsLog("govips", LogLevelDebug, fmt.Sprintf("closing image %p", ref)) - ref.Close() -} - -// Close manually closes the image and frees the memory. Calling Close() is optional. -// Images are automatically closed by GC. However, in high volume applications the GC -// can't keep up with the amount of memory, so you might want to manually close the images. -func (r *ImageRef) Close() { - r.lock.Lock() - - if r.image != nil { - clearImage(r.image) - r.image = nil - openImageRefs.Add(-1) - } - - r.buf = nil - - // Release the streaming source only after the image is gone: the - // image may still hold references that read from the source. - src := r.streamSource - r.streamSource = nil - - r.lock.Unlock() - - if src != nil { - src.release() - } -} - -// SetKill sets the libvips kill flag used to stop image evaluation. -func (r *ImageRef) SetKill(kill bool) { - r.lock.Lock() - defer r.lock.Unlock() - - if r.image != nil { - C.vips_image_set_kill(r.image, toGboolean(kill)) - } -} - -// setImage resets the image for this image and frees the previous one -func (r *ImageRef) setImage(image *C.VipsImage) { - r.lock.Lock() - defer r.lock.Unlock() - - if r.image == image { - return - } - - if r.image != nil { - clearImage(r.image) - } - - r.image = image -} - -func vipsHasAlpha(in *C.VipsImage) bool { - return int(C.has_alpha_channel(in)) > 0 -} - -func clearImage(ref *C.VipsImage) { - C.clear_image(&ref) -} - -// vipsRefCount reads the GObject reference count. Test-only: it lets tests -// catch a stray unref without relying on a use-after-free to crash. -func vipsRefCount(in *C.VipsImage) int { - return int((*C.GObject)(unsafe.Pointer(in)).ref_count) -} - -// Coding represents VIPS_CODING type -type Coding int - -// Coding enum -// -//goland:noinspection GoUnusedConst -const ( - CodingError Coding = C.VIPS_CODING_ERROR - CodingNone Coding = C.VIPS_CODING_NONE - CodingLABQ Coding = C.VIPS_CODING_LABQ - CodingRAD Coding = C.VIPS_CODING_RAD -) - -func (r *ImageRef) newMetadata(format ImageType) *ImageMetadata { - return &ImageMetadata{ - Format: format, - Width: r.Width(), - Height: r.Height(), - Colorspace: r.ColorSpace(), - Orientation: r.Orientation(), - Pages: r.Pages(), - } -} diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/image.h b/vendor/github.com/davidbyttow/govips/v2/vips/image.h deleted file mode 100644 index e8c8aa5be0..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/image.h +++ /dev/null @@ -1,12 +0,0 @@ -// https://libvips.github.io/libvips/API/current/VipsImage.html - -#include -#include - -int has_alpha_channel(VipsImage *image); - -void clear_image(VipsImage **image); - -VipsImage *create_image_from_memory_copy(const void *data, size_t size, - int width, int height, int bands, - VipsBandFormat format); diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/image_color.go b/vendor/github.com/davidbyttow/govips/v2/vips/image_color.go deleted file mode 100644 index 8ce388f20d..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/image_color.go +++ /dev/null @@ -1,173 +0,0 @@ -package vips - -// #include "image.h" -import "C" - -import ( - "errors" - "runtime" -) - -// ToColorSpace changes the color space of the image to the interpretation supplied as the parameter. -func (r *ImageRef) ToColorSpace(interpretation Interpretation) error { - defer runtime.KeepAlive(r) - out, err := vipsToColorSpace(r.image, interpretation) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// Flatten removes the alpha channel from the image and replaces it with the background color -func (r *ImageRef) Flatten(backgroundColor *Color) error { - defer runtime.KeepAlive(r) - opts := &FlattenOptions{} - if backgroundColor != nil { - opts.Background = []float64{float64(backgroundColor.R), float64(backgroundColor.G), float64(backgroundColor.B)} - } - out, err := vipsGenFlatten(r.image, opts) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// Modulate the colors -func (r *ImageRef) Modulate(brightness, saturation, hue float64) error { - defer runtime.KeepAlive(r) - var err error - var multiplications []float64 - var additions []float64 - - colorspace := r.ColorSpace() - if colorspace == InterpretationRGB { - colorspace = InterpretationSRGB - } - - multiplications = []float64{brightness, saturation, 1} - additions = []float64{0, 0, hue} - - if r.HasAlpha() { - multiplications = append(multiplications, 1) - additions = append(additions, 0) - } - - err = r.ToColorSpace(InterpretationLCH) - if err != nil { - return err - } - - err = r.Linear(multiplications, additions) - if err != nil { - return err - } - - err = r.ToColorSpace(colorspace) - if err != nil { - return err - } - - return nil -} - -// ModulateHSV modulates the image HSV values based on the supplier parameters. -func (r *ImageRef) ModulateHSV(brightness, saturation float64, hue int) error { - defer runtime.KeepAlive(r) - var err error - var multiplications []float64 - var additions []float64 - - colorspace := r.ColorSpace() - if colorspace == InterpretationRGB { - colorspace = InterpretationSRGB - } - - if r.HasAlpha() { - multiplications = []float64{1, saturation, brightness, 1} - additions = []float64{float64(hue), 0, 0, 0} - } else { - multiplications = []float64{1, saturation, brightness} - additions = []float64{float64(hue), 0, 0} - } - - err = r.ToColorSpace(InterpretationHSV) - if err != nil { - return err - } - - err = r.Linear(multiplications, additions) - if err != nil { - return err - } - - err = r.ToColorSpace(colorspace) - if err != nil { - return err - } - - return nil -} - -// Invert inverts the image -func (r *ImageRef) Invert() error { - defer runtime.KeepAlive(r) - out, err := vipsGenInvert(r.image) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// Adjusts the image's gamma value. -// See https://www.libvips.org/API/current/libvips-conversion.html#vips-gamma -func (r *ImageRef) Gamma(gamma float64) error { - defer runtime.KeepAlive(r) - out, err := vipsGenGamma(r.image, &GammaOptions{Exponent: &gamma}) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// Linear passes an image through a linear transformation (i.e. output = input * a + b). -// See https://libvips.github.io/libvips/API/current/libvips-arithmetic.html#vips-linear -func (r *ImageRef) Linear(a, b []float64) error { - defer runtime.KeepAlive(r) - if len(a) != len(b) { - return errors.New("a and b must be of same length") - } - - out, err := vipsGenLinear(r.image, a, b, nil) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// Linear1 runs Linear() with a single constant. -// See https://libvips.github.io/libvips/API/current/libvips-arithmetic.html#vips-linear1 -func (r *ImageRef) Linear1(a, b float64) error { - defer runtime.KeepAlive(r) - out, err := vipsGenLinear(r.image, []float64{a}, []float64{b}, nil) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// Cast converts the image to a target band format -func (r *ImageRef) Cast(format BandFormat) error { - defer runtime.KeepAlive(r) - out, err := vipsGenCast(r.image, format, nil) - if err != nil { - return err - } - r.setImage(out) - return nil -} diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/image_composite.go b/vendor/github.com/davidbyttow/govips/v2/vips/image_composite.go deleted file mode 100644 index db4a347107..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/image_composite.go +++ /dev/null @@ -1,75 +0,0 @@ -package vips - -// #include "image.h" -import "C" - -import "runtime" - -// CompositeMulti composites the given overlay image on top of the associated image with provided blending mode. -func (r *ImageRef) CompositeMulti(ins []*ImageComposite) error { - defer runtime.KeepAlive(r) - defer runtime.KeepAlive(ins) - out, err := vipsComposite(toVipsCompositeStructs(r, ins)) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// Composite composites the given overlay image on top of the associated image with provided blending mode. -func (r *ImageRef) Composite(overlay *ImageRef, mode BlendMode, x, y int) error { - defer runtime.KeepAlive(r) - defer runtime.KeepAlive(overlay) - out, err := vipsGenComposite2(r.image, overlay.image, mode, &Composite2Options{X: &x, Y: &y}) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// Insert draws the image on top of the associated image at the given coordinates. -func (r *ImageRef) Insert(sub *ImageRef, x, y int, expand bool, background *ColorRGBA) error { - defer runtime.KeepAlive(r) - defer runtime.KeepAlive(sub) - insertOpts := &InsertOptions{Expand: &expand} - if background != nil { - insertOpts.Background = []float64{float64(background.R), float64(background.G), float64(background.B), float64(background.A)} - } - out, err := vipsGenInsert(r.image, sub.image, x, y, insertOpts) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// Join joins this image with another in the direction specified -func (r *ImageRef) Join(in *ImageRef, dir Direction) error { - defer runtime.KeepAlive(r) - defer runtime.KeepAlive(in) - out, err := vipsJoin(r.image, in.image, dir) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// ArrayJoin joins an array of images together wrapping at each n images -func (r *ImageRef) ArrayJoin(images []*ImageRef, across int) error { - defer runtime.KeepAlive(r) - defer runtime.KeepAlive(images) - allImages := append([]*ImageRef{r}, images...) - inputs := make([]*C.VipsImage, len(allImages)) - for i := range inputs { - inputs[i] = allImages[i].image - } - out, err := vipsGenArrayjoin(inputs, &ArrayjoinOptions{Across: &across}) - if err != nil { - return err - } - r.setImage(out) - return nil -} diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/image_export.go b/vendor/github.com/davidbyttow/govips/v2/vips/image_export.go deleted file mode 100644 index f866def302..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/image_export.go +++ /dev/null @@ -1,439 +0,0 @@ -package vips - -// #include "image.h" -import "C" - -import ( - "bytes" - "errors" - "fmt" - "image" - "runtime" - "unsafe" -) - -// Export creates a byte array of the image for use. -// The function returns a byte array that can be written to a file e.g. via os.WriteFile(). -// N.B. govips does not currently have built-in support for directly exporting to a file. -// The function also returns a copy of the image metadata as well as an error. -// Deprecated: Use ExportNative or format-specific Export methods -func (r *ImageRef) Export(params *ExportParams) ([]byte, *ImageMetadata, error) { - if params == nil || params.Format == ImageTypeUnknown { - return r.ExportNative() - } - - format := params.Format - - if !IsTypeSupported(format) { - return nil, r.newMetadata(ImageTypeUnknown), fmt.Errorf("cannot save to %#v", ImageTypes[format]) - } - - switch format { - case ImageTypeGIF: - return r.ExportGIF(gifParamsFromExport(params)) - case ImageTypeWEBP: - return r.ExportWebp(webpParamsFromExport(params)) - case ImageTypePNG: - return r.ExportPng(pngParamsFromExport(params)) - case ImageTypeTIFF: - return r.ExportTiff(tiffParamsFromExport(params)) - case ImageTypeHEIF: - return r.ExportHeif(heifParamsFromExport(params)) - case ImageTypeAVIF: - return r.ExportAvif(&AvifExportParams{ - StripMetadata: params.StripMetadata, - Quality: params.Quality, - Lossless: params.Lossless, - Speed: params.Speed, - }) - case ImageTypeJXL: - return r.ExportJxl(&JxlExportParams{ - Quality: params.Quality, - Lossless: params.Lossless, - Effort: params.Effort, - }) - default: - format = ImageTypeJPEG - return r.ExportJpeg(jpegParamsFromExport(params)) - } -} - -// The *ParamsFromExport helpers map the generic (deprecated) ExportParams -// onto format-specific params. They are shared between Export and the -// streaming SaveToWriter so the two paths cannot drift. A nil params -// yields the format's defaults. - -func jpegParamsFromExport(params *ExportParams) *JpegExportParams { - if params == nil { - return NewJpegExportParams() - } - return &JpegExportParams{ - Quality: params.Quality, - StripMetadata: params.StripMetadata, - Interlace: params.Interlaced, - OptimizeCoding: params.OptimizeCoding, - SubsampleMode: params.SubsampleMode, - TrellisQuant: params.TrellisQuant, - OvershootDeringing: params.OvershootDeringing, - OptimizeScans: params.OptimizeScans, - QuantTable: params.QuantTable, - } -} - -func pngParamsFromExport(params *ExportParams) *PngExportParams { - if params == nil { - return NewPngExportParams() - } - return &PngExportParams{ - StripMetadata: params.StripMetadata, - Compression: params.Compression, - Interlace: params.Interlaced, - } -} - -func webpParamsFromExport(params *ExportParams) *WebpExportParams { - if params == nil { - return NewWebpExportParams() - } - return &WebpExportParams{ - StripMetadata: params.StripMetadata, - Quality: params.Quality, - Lossless: params.Lossless, - ReductionEffort: params.Effort, - } -} - -func tiffParamsFromExport(params *ExportParams) *TiffExportParams { - if params == nil { - return NewTiffExportParams() - } - compression := TiffCompressionLzw - if params.Lossless { - compression = TiffCompressionNone - } - return &TiffExportParams{ - StripMetadata: params.StripMetadata, - Quality: params.Quality, - Compression: compression, - } -} - -func heifParamsFromExport(params *ExportParams) *HeifExportParams { - if params == nil { - return NewHeifExportParams() - } - return &HeifExportParams{ - Quality: params.Quality, - Lossless: params.Lossless, - } -} - -func gifParamsFromExport(params *ExportParams) *GifExportParams { - if params == nil { - return NewGifExportParams() - } - return &GifExportParams{ - Quality: params.Quality, - } -} - -// ExportNative exports the image to a buffer based on its native format with default parameters. -func (r *ImageRef) ExportNative() ([]byte, *ImageMetadata, error) { - switch r.format { - case ImageTypeJPEG: - return r.ExportJpeg(NewJpegExportParams()) - case ImageTypePNG: - return r.ExportPng(NewPngExportParams()) - case ImageTypeWEBP: - return r.ExportWebp(NewWebpExportParams()) - case ImageTypeHEIF: - return r.ExportHeif(NewHeifExportParams()) - case ImageTypeTIFF: - return r.ExportTiff(NewTiffExportParams()) - case ImageTypeAVIF: - return r.ExportAvif(NewAvifExportParams()) - case ImageTypeJP2K: - return r.ExportJp2k(NewJp2kExportParams()) - case ImageTypeGIF: - return r.ExportGIF(NewGifExportParams()) - case ImageTypeJXL: - return r.ExportJxl(NewJxlExportParams()) - default: - return r.ExportJpeg(NewJpegExportParams()) - } -} - -// ExportJpeg exports the image as JPEG to a buffer. -func (r *ImageRef) ExportJpeg(params *JpegExportParams) ([]byte, *ImageMetadata, error) { - defer runtime.KeepAlive(r) - if params == nil { - params = NewJpegExportParams() - } - - buf, err := vipsSaveJPEGToBuffer(r.image, *params) - if err != nil { - return nil, nil, err - } - - return buf, r.newMetadata(ImageTypeJPEG), nil -} - -// ExportPng exports the image as PNG to a buffer. -func (r *ImageRef) ExportPng(params *PngExportParams) ([]byte, *ImageMetadata, error) { - defer runtime.KeepAlive(r) - if params == nil { - params = NewPngExportParams() - } - - buf, err := vipsSavePNGToBuffer(r.image, *params) - if err != nil { - return nil, nil, err - } - - return buf, r.newMetadata(ImageTypePNG), nil -} - -// ExportWebp exports the image as WEBP to a buffer. -func (r *ImageRef) ExportWebp(params *WebpExportParams) ([]byte, *ImageMetadata, error) { - defer runtime.KeepAlive(r) - if params == nil { - params = NewWebpExportParams() - } - - paramsWithIccProfile := *params - paramsWithIccProfile.IccProfile = r.optimizedIccProfile - - buf, err := vipsSaveWebPToBuffer(r.image, paramsWithIccProfile) - if err != nil { - return nil, nil, err - } - - return buf, r.newMetadata(ImageTypeWEBP), nil -} - -// ExportHeif exports the image as HEIF to a buffer. -func (r *ImageRef) ExportHeif(params *HeifExportParams) ([]byte, *ImageMetadata, error) { - defer runtime.KeepAlive(r) - if params == nil { - params = NewHeifExportParams() - } - - buf, err := vipsSaveHEIFToBuffer(r.image, *params) - if err != nil { - return nil, nil, err - } - - return buf, r.newMetadata(ImageTypeHEIF), nil -} - -// ExportTiff exports the image as TIFF to a buffer. -func (r *ImageRef) ExportTiff(params *TiffExportParams) ([]byte, *ImageMetadata, error) { - defer runtime.KeepAlive(r) - if params == nil { - params = NewTiffExportParams() - } - - buf, err := vipsSaveTIFFToBuffer(r.image, *params) - if err != nil { - return nil, nil, err - } - - return buf, r.newMetadata(ImageTypeTIFF), nil -} - -// ExportGIF exports the image as GIF to a buffer. -func (r *ImageRef) ExportGIF(params *GifExportParams) ([]byte, *ImageMetadata, error) { - defer runtime.KeepAlive(r) - if params == nil { - params = NewGifExportParams() - } - - buf, err := vipsSaveGIFToBuffer(r.image, *params) - if err != nil { - return nil, nil, err - } - - return buf, r.newMetadata(ImageTypeGIF), nil -} - -// ExportAvif exports the image as AVIF to a buffer. -func (r *ImageRef) ExportAvif(params *AvifExportParams) ([]byte, *ImageMetadata, error) { - defer runtime.KeepAlive(r) - if params == nil { - params = NewAvifExportParams() - } - - buf, err := vipsSaveAVIFToBuffer(r.image, *params) - if err != nil { - return nil, nil, err - } - - return buf, r.newMetadata(ImageTypeAVIF), nil -} - -// ExportJp2k exports the image as JPEG2000 to a buffer. -func (r *ImageRef) ExportJp2k(params *Jp2kExportParams) ([]byte, *ImageMetadata, error) { - defer runtime.KeepAlive(r) - if params == nil { - params = NewJp2kExportParams() - } - - buf, err := vipsSaveJP2KToBuffer(r.image, *params) - if err != nil { - return nil, nil, err - } - - return buf, r.newMetadata(ImageTypeJP2K), nil -} - -// ExportJxl exports the image as JPEG XL to a buffer. -func (r *ImageRef) ExportJxl(params *JxlExportParams) ([]byte, *ImageMetadata, error) { - defer runtime.KeepAlive(r) - if params == nil { - params = NewJxlExportParams() - } - - buf, err := vipsSaveJxlToBuffer(r.image, *params) - if err != nil { - return nil, nil, err - } - - return buf, r.newMetadata(ImageTypeJXL), nil -} - -// ExportMagick exports the image as Format set in param to a buffer. -func (r *ImageRef) ExportMagick(params *MagickExportParams) ([]byte, *ImageMetadata, error) { - defer runtime.KeepAlive(r) - if params == nil { - params = NewMagickExportParams() - params.Format = "JPG" - } - - buf, err := vipsSaveMagickToBuffer(r.image, *params) - if err != nil { - return nil, nil, err - } - - return buf, r.newMetadata(ImageTypeMagick), nil -} - -// ToBytes writes the image to memory in VIPs format and returns the raw bytes, useful for storage. -func (r *ImageRef) ToBytes() ([]byte, error) { - defer runtime.KeepAlive(r) - var cSize C.size_t - cData := C.vips_image_write_to_memory(r.image, &cSize) - if cData == nil { - return nil, errors.New("failed to write image to memory") - } - defer C.free(cData) - - data := C.GoBytes(unsafe.Pointer(cData), C.int(cSize)) - return data, nil -} - -// ToImage converts a VIPs image to a golang image.Image object, useful for interoperability with other golang libraries. -// Deprecated: Use ToGoImage for a faster, direct conversion without encoding round-trip. -func (r *ImageRef) ToImage(params *ExportParams) (image.Image, error) { - imageBytes, _, err := r.ExportNative() - if err != nil { - return nil, err - } - - reader := bytes.NewReader(imageBytes) - img, _, err := image.Decode(reader) - if err != nil { - return nil, err - } - - return img, nil -} - -// ToGoImage converts a vips image directly to a Go image.Image without encoding. -// This is significantly faster than ToImage() which round-trips through JPEG/PNG. -// The resulting image will be in sRGB color space with 8-bit depth. -func (r *ImageRef) ToGoImage() (image.Image, error) { - defer runtime.KeepAlive(r) - - // Work on a copy to avoid mutating the receiver - tmp, err := vipsGenCopy(r.image, nil) - if err != nil { - return nil, err - } - defer clearImage(tmp) - - // Convert to sRGB if needed (keep B_W for grayscale) - interp := Interpretation(int(tmp.Type)) - if interp != InterpretationSRGB && interp != InterpretationBW { - out, err := vipsToColorSpace(tmp, InterpretationSRGB) - if err != nil { - return nil, err - } - clearImage(tmp) - tmp = out - } - - // Cast to uchar if needed - if BandFormat(int(tmp.BandFmt)) != BandFormatUchar { - out, err := vipsGenCast(tmp, BandFormatUchar, nil) - if err != nil { - return nil, err - } - clearImage(tmp) - tmp = out - } - - // Extract raw pixel data - var cSize C.size_t - cData := C.vips_image_write_to_memory(tmp, &cSize) - if cData == nil { - return nil, errors.New("failed to write image to memory") - } - defer C.free(cData) - - width := int(tmp.Xsize) - height := int(tmp.Ysize) - bands := int(tmp.Bands) - pixels := C.GoBytes(unsafe.Pointer(cData), C.int(cSize)) - - switch bands { - case 1: - img := image.NewGray(image.Rect(0, 0, width, height)) - copy(img.Pix, pixels) - return img, nil - case 2: - // Grayscale + alpha - img := image.NewNRGBA(image.Rect(0, 0, width, height)) - srcIdx := 0 - dstIdx := 0 - for srcIdx+1 < len(pixels) { - v := pixels[srcIdx] - img.Pix[dstIdx] = v - img.Pix[dstIdx+1] = v - img.Pix[dstIdx+2] = v - img.Pix[dstIdx+3] = pixels[srcIdx+1] - srcIdx += 2 - dstIdx += 4 - } - return img, nil - case 3: - // RGB, add opaque alpha - img := image.NewNRGBA(image.Rect(0, 0, width, height)) - srcIdx := 0 - dstIdx := 0 - for srcIdx+2 < len(pixels) { - img.Pix[dstIdx] = pixels[srcIdx] - img.Pix[dstIdx+1] = pixels[srcIdx+1] - img.Pix[dstIdx+2] = pixels[srcIdx+2] - img.Pix[dstIdx+3] = 255 - srcIdx += 3 - dstIdx += 4 - } - return img, nil - case 4: - img := image.NewNRGBA(image.Rect(0, 0, width, height)) - copy(img.Pix, pixels) - return img, nil - default: - return nil, fmt.Errorf("unsupported number of bands: %d", bands) - } -} diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/image_icc.go b/vendor/github.com/davidbyttow/govips/v2/vips/image_icc.go deleted file mode 100644 index 4a6ff3a8d4..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/image_icc.go +++ /dev/null @@ -1,108 +0,0 @@ -package vips - -// #include "image.h" -import "C" - -import ( - "fmt" - "runtime" -) - -// GetICCProfile retrieves the ICC profile data (if any) from the image. -func (r *ImageRef) GetICCProfile() []byte { - defer runtime.KeepAlive(r) - bytes, _ := vipsGetICCProfile(r.image) - return bytes -} - -// RemoveICCProfile removes the ICC Profile information from the image. -// Typically, browsers and other software assume images without profile to be in the sRGB color space. -func (r *ImageRef) RemoveICCProfile() error { - defer runtime.KeepAlive(r) - out, err := vipsGenCopy(r.image, nil) - if err != nil { - return err - } - - vipsRemoveICCProfile(out) - - r.setImage(out) - return nil -} - -// TransformICCProfileWithFallback transforms from the embedded ICC profile of the image to the ICC profile at the given path. -// The fallback ICC profile is used if the image does not have an embedded ICC profile. -func (r *ImageRef) TransformICCProfileWithFallback(targetProfilePath, fallbackProfilePath string) error { - defer runtime.KeepAlive(r) - if err := ensureLoadICCPath(&targetProfilePath); err != nil { - return err - } - if err := ensureLoadICCPath(&fallbackProfilePath); err != nil { - return err - } - - depth := 16 - if r.BandFormat() == BandFormatUchar || r.BandFormat() == BandFormatChar || r.BandFormat() == BandFormatNotSet { - depth = 8 - } - - out, err := vipsICCTransform(r.image, targetProfilePath, fallbackProfilePath, IntentPerceptual, depth, true) - if err != nil { - govipsLog("govips", LogLevelError, fmt.Sprintf("failed to do icc transform: %v", err.Error())) - return err - } - - r.setImage(out) - return nil -} - -// TransformICCProfile transforms from the embedded ICC profile of the image to the icc profile at the given path. -func (r *ImageRef) TransformICCProfile(outputProfilePath string) error { - return r.TransformICCProfileWithFallback(outputProfilePath, SRGBIEC6196621ICCProfilePath) -} - -// OptimizeICCProfile optimizes the ICC color profile of the image. -// For two color channel images, it sets a grayscale profile. -// For color images, it sets a CMYK or non-CMYK profile based on the image metadata. -func (r *ImageRef) OptimizeICCProfile() error { - defer runtime.KeepAlive(r) - inputProfile := r.determineInputICCProfile() - if !r.HasICCProfile() && (inputProfile == "") { - // No embedded ICC profile in the input image and no input profile determined, nothing to do. - return nil - } - - r.optimizedIccProfile = SRGBV2MicroICCProfilePath - if r.Bands() <= 2 { - r.optimizedIccProfile = SGrayV2MicroICCProfilePath - } - - if err := ensureLoadICCPath(&r.optimizedIccProfile); err != nil { - return err - } - - embedded := r.HasICCProfile() && (inputProfile == "") - - depth := 16 - if r.BandFormat() == BandFormatUchar || r.BandFormat() == BandFormatChar || r.BandFormat() == BandFormatNotSet { - depth = 8 - } - - out, err := vipsICCTransform(r.image, r.optimizedIccProfile, inputProfile, IntentPerceptual, depth, embedded) - if err != nil { - govipsLog("govips", LogLevelError, fmt.Sprintf("failed to do icc transform: %v", err.Error())) - return err - } - - r.setImage(out) - return nil -} - -func (r *ImageRef) determineInputICCProfile() (inputProfile string) { - if r.Interpretation() == InterpretationCMYK { - if !r.HasICCProfile() { - inputProfile = "cmyk" - } - } - return -} diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/image_metadata.go b/vendor/github.com/davidbyttow/govips/v2/vips/image_metadata.go deleted file mode 100644 index 5b90bfc3b0..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/image_metadata.go +++ /dev/null @@ -1,338 +0,0 @@ -package vips - -// #include "image.h" -import "C" - -import ( - "runtime" - "strings" -) - -// Format returns the current format of the vips image. -func (r *ImageRef) Format() ImageType { - return r.format -} - -// OriginalFormat returns the original format of the image when loaded. -// In some cases the loaded image is converted on load, for example, a BMP is automatically converted to PNG -// This method returns the format of the original buffer, as opposed to Format() with will return the format of the -// currently held buffer content. -func (r *ImageRef) OriginalFormat() ImageType { - return r.originalFormat -} - -// Width returns the width of this image. -func (r *ImageRef) Width() int { - return int(r.image.Xsize) -} - -// Height returns the height of this image. -func (r *ImageRef) Height() int { - return int(r.image.Ysize) -} - -// Bands returns the number of bands for this image. -func (r *ImageRef) Bands() int { - return int(r.image.Bands) -} - -// HasProfile returns if the image has an ICC profile embedded. -func (r *ImageRef) HasProfile() bool { - defer runtime.KeepAlive(r) - return vipsHasICCProfile(r.image) -} - -// HasICCProfile checks whether the image has an ICC profile embedded. Alias to HasProfile -func (r *ImageRef) HasICCProfile() bool { - return r.HasProfile() -} - -// HasIPTC returns a boolean whether the image in question has IPTC data associated with it. -func (r *ImageRef) HasIPTC() bool { - defer runtime.KeepAlive(r) - return vipsHasIPTC(r.image) -} - -// HasAlpha returns if the image has an alpha layer. -func (r *ImageRef) HasAlpha() bool { - defer runtime.KeepAlive(r) - return vipsHasAlpha(r.image) -} - -// Orientation returns the orientation number as it appears in the EXIF, if present -func (r *ImageRef) Orientation() int { - defer runtime.KeepAlive(r) - return vipsGetMetaOrientation(r.image) -} - -// Deprecated: use Orientation() instead -func (r *ImageRef) GetOrientation() int { - return r.Orientation() -} - -// SetOrientation sets the orientation in the EXIF header of the associated image. -func (r *ImageRef) SetOrientation(orientation int) error { - defer runtime.KeepAlive(r) - out, err := vipsGenCopy(r.image, nil) - if err != nil { - return err - } - - vipsSetMetaOrientation(out, orientation) - - r.setImage(out) - return nil -} - -// RemoveOrientation removes the EXIF orientation information of the image. -func (r *ImageRef) RemoveOrientation() error { - defer runtime.KeepAlive(r) - out, err := vipsGenCopy(r.image, nil) - if err != nil { - return err - } - - vipsRemoveMetaOrientation(out) - - r.setImage(out) - return nil -} - -// ResX returns the X resolution -func (r *ImageRef) ResX() float64 { - return float64(r.image.Xres) -} - -// ResY returns the Y resolution -func (r *ImageRef) ResY() float64 { - return float64(r.image.Yres) -} - -// OffsetX returns the X offset -func (r *ImageRef) OffsetX() int { - return int(r.image.Xoffset) -} - -// OffsetY returns the Y offset -func (r *ImageRef) OffsetY() int { - return int(r.image.Yoffset) -} - -// BandFormat returns the current band format -func (r *ImageRef) BandFormat() BandFormat { - return BandFormat(int(r.image.BandFmt)) -} - -// Coding returns the image coding -func (r *ImageRef) Coding() Coding { - return Coding(int(r.image.Coding)) -} - -// Interpretation returns the current interpretation of the color space of the image. -func (r *ImageRef) Interpretation() Interpretation { - return Interpretation(int(r.image.Type)) -} - -// ColorSpace returns the interpretation of the current color space. Alias to Interpretation(). -func (r *ImageRef) ColorSpace() Interpretation { - return r.Interpretation() -} - -// IsColorSpaceSupported returns a boolean whether the image's color space is supported by libvips. -func (r *ImageRef) IsColorSpaceSupported() bool { - defer runtime.KeepAlive(r) - return vipsIsColorSpaceSupported(r.image) -} - -// Pages returns the number of pages in the Image -// For animated images this corresponds to the number of frames -func (r *ImageRef) Pages() int { - // libvips uses the same attribute (n_pages) to represent the number of pyramid layers in JP2K - // as we interpret the attribute as frames and JP2K does not support animation we override this with 1 - if r.format == ImageTypeJP2K { - return 1 - } - - defer runtime.KeepAlive(r) - return vipsGetImageNPages(r.image) -} - -// Deprecated: use Pages() instead -func (r *ImageRef) GetPages() int { - return r.Pages() -} - -// SetPages sets the number of pages in the Image -// For animated images this corresponds to the number of frames -func (r *ImageRef) SetPages(pages int) error { - defer runtime.KeepAlive(r) - out, err := vipsGenCopy(r.image, nil) - if err != nil { - return err - } - - vipsSetImageNPages(out, pages) - - r.setImage(out) - return nil -} - -// PageHeight return the height of a single page -func (r *ImageRef) PageHeight() int { - defer runtime.KeepAlive(r) - return vipsGetPageHeight(r.image) -} - -// GetPageHeight return the height of a single page -// Deprecated use PageHeight() instead -func (r *ImageRef) GetPageHeight() int { - defer runtime.KeepAlive(r) - return vipsGetPageHeight(r.image) -} - -// SetPageHeight set the height of a page -// For animated images this is used when "unrolling" back to frames -func (r *ImageRef) SetPageHeight(height int) error { - defer runtime.KeepAlive(r) - out, err := vipsGenCopy(r.image, nil) - if err != nil { - return err - } - - vipsSetPageHeight(out, height) - - r.setImage(out) - return nil -} - -// PageDelay get the page delay array for animation -func (r *ImageRef) PageDelay() ([]int, error) { - defer runtime.KeepAlive(r) - n := vipsGetImageNPages(r.image) - if n <= 1 { - // should not call if not multi page - return nil, nil - } - return vipsImageGetDelay(r.image, n) -} - -// SetPageDelay set the page delay array for animation -func (r *ImageRef) SetPageDelay(delay []int) error { - defer runtime.KeepAlive(r) - var data []C.int - for _, d := range delay { - data = append(data, C.int(d)) - } - return vipsImageSetDelay(r.image, data) -} - -// Loop returns the loop count for animated images. -// A value of 0 means infinite looping. -func (r *ImageRef) Loop() int { - defer runtime.KeepAlive(r) - return vipsImageGetLoop(r.image) -} - -// SetLoop sets the loop count for animated images. -// A value of 0 means infinite looping. -func (r *ImageRef) SetLoop(loop int) error { - defer runtime.KeepAlive(r) - vipsImageSetLoop(r.image, loop) - return nil -} - -// Background get the background of image. -func (r *ImageRef) Background() ([]float64, error) { - defer runtime.KeepAlive(r) - out, err := vipsImageGetBackground(r.image) - if err != nil { - return nil, err - } - return out, nil -} - -func (r *ImageRef) ImageFields() []string { - return r.GetFields() -} - -func (r *ImageRef) GetFields() []string { - defer runtime.KeepAlive(r) - return vipsImageGetFields(r.image) -} - -func (r *ImageRef) SetBlob(name string, data []byte) { - defer runtime.KeepAlive(r) - vipsImageSetBlob(r.image, name, data) -} - -func (r *ImageRef) GetBlob(name string) []byte { - defer runtime.KeepAlive(r) - return vipsImageGetBlob(r.image, name) -} - -func (r *ImageRef) SetDouble(name string, f float64) { - defer runtime.KeepAlive(r) - vipsImageSetDouble(r.image, name, f) -} - -func (r *ImageRef) GetDouble(name string) float64 { - defer runtime.KeepAlive(r) - return vipsImageGetDouble(r.image, name) -} - -func (r *ImageRef) SetInt(name string, i int) { - defer runtime.KeepAlive(r) - vipsImageSetInt(r.image, name, i) -} - -func (r *ImageRef) GetInt(name string) int { - defer runtime.KeepAlive(r) - return vipsImageGetInt(r.image, name) -} - -func (r *ImageRef) SetString(name string, str string) { - defer runtime.KeepAlive(r) - vipsImageSetString(r.image, name, str) -} - -func (r *ImageRef) GetString(name string) string { - defer runtime.KeepAlive(r) - return vipsImageGetString(r.image, name) -} - -func (r *ImageRef) GetAsString(name string) string { - defer runtime.KeepAlive(r) - return vipsImageGetAsString(r.image, name) -} - -func (r *ImageRef) HasExif() bool { - for _, field := range r.ImageFields() { - if strings.HasPrefix(field, "exif-") { - return true - } - } - - return false -} - -func (r *ImageRef) GetExif() map[string]string { - defer runtime.KeepAlive(r) - return vipsImageGetExifData(r.image) -} - -// RemoveMetadata removes the EXIF metadata from the image. -// N.B. this function won't remove the ICC profile, orientation and pages metadata -// because govips needs it to correctly display the image. -func (r *ImageRef) RemoveMetadata(keep ...string) error { - defer runtime.KeepAlive(r) - out, err := vipsGenCopy(r.image, nil) - if err != nil { - return err - } - - vipsRemoveMetadata(out, keep...) - - r.setImage(out) - - return nil -} diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/image_pixel.go b/vendor/github.com/davidbyttow/govips/v2/vips/image_pixel.go deleted file mode 100644 index db65d86355..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/image_pixel.go +++ /dev/null @@ -1,393 +0,0 @@ -package vips - -// #include "image.h" -import "C" - -import ( - "errors" - "runtime" -) - -// GaussianBlur blurs the image -// add support minAmpl -func (r *ImageRef) GaussianBlur(sigmas ...float64) error { - defer runtime.KeepAlive(r) - var ( - sigma = sigmas[0] - minAmpl = GaussBlurDefaultMinAMpl - ) - if len(sigmas) >= 2 { - minAmpl = sigmas[1] - } - out, err := vipsGenGaussblur(r.image, sigma, &GaussblurOptions{MinAmpl: &minAmpl}) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// Sharpen sharpens the image -// sigma: sigma of the gaussian -// x1: flat/jaggy threshold -// m2: slope for jaggy areas -func (r *ImageRef) Sharpen(sigma float64, x1 float64, m2 float64) error { - defer runtime.KeepAlive(r) - out, err := vipsGenSharpen(r.image, &SharpenOptions{Sigma: &sigma, X1: &x1, M2: &m2}) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// Apply Sobel edge detector to the image. -func (r *ImageRef) Sobel() error { - defer runtime.KeepAlive(r) - out, err := vipsGenSobel(r.image) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// Rank does rank filtering on an image. A window of size width by height is passed over the image. -// At each position, the pixels inside the window are sorted into ascending order and the pixel at position -// index is output. index numbers from 0. -func (r *ImageRef) Rank(width int, height int, index int) error { - defer runtime.KeepAlive(r) - out, err := vipsGenRank(r.image, width, height, index) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// Mapim resamples an image using index to look up pixels -func (r *ImageRef) Mapim(index *ImageRef) error { - defer runtime.KeepAlive(r) - defer runtime.KeepAlive(index) - out, err := vipsGenMapim(r.image, index.image, nil) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// Maplut maps an image through another image acting as a LUT (Look Up Table) -func (r *ImageRef) Maplut(lut *ImageRef) error { - defer runtime.KeepAlive(r) - defer runtime.KeepAlive(lut) - out, err := vipsGenMaplut(r.image, lut.image, nil) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// ExtractBand extracts one or more bands out of the image (replacing the associated ImageRef) -func (r *ImageRef) ExtractBand(band int, num int) error { - defer runtime.KeepAlive(r) - out, err := vipsGenExtractBand(r.image, band, &ExtractBandOptions{N: &num}) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// ExtractBandToImage extracts one or more bands out of the image to a new image -func (r *ImageRef) ExtractBandToImage(band int, num int) (*ImageRef, error) { - defer runtime.KeepAlive(r) - out, err := vipsGenExtractBand(r.image, band, &ExtractBandOptions{N: &num}) - if err != nil { - return nil, err - } - return newImageRef(out, ImageTypeUnknown, ImageTypeUnknown, nil), nil -} - -// BandJoin joins a set of images together, bandwise. -func (r *ImageRef) BandJoin(images ...*ImageRef) error { - defer runtime.KeepAlive(r) - defer runtime.KeepAlive(images) - vipsImages := []*C.VipsImage{r.image} - for _, vipsImage := range images { - vipsImages = append(vipsImages, vipsImage.image) - } - - out, err := vipsGenBandjoin(vipsImages) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// BandSplit split an n-band image into n separate images.. -func (r *ImageRef) BandSplit() ([]*ImageRef, error) { - defer runtime.KeepAlive(r) - var out []*ImageRef - n := 1 - for i := 0; i < r.Bands(); i++ { - img, err := vipsGenExtractBand(r.image, i, &ExtractBandOptions{N: &n}) - if err != nil { - return out, err - } - out = append(out, &ImageRef{image: img}) - } - return out, nil -} - -// BandJoinConst appends a set of constant bands to an image. -func (r *ImageRef) BandJoinConst(constants []float64) error { - defer runtime.KeepAlive(r) - if len(constants) == 0 { - return errors.New("BandJoinConst: empty constants slice") - } - out, err := vipsGenBandjoinConst(r.image, constants) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// AddAlpha adds an alpha channel to the associated image. -func (r *ImageRef) AddAlpha() error { - defer runtime.KeepAlive(r) - if vipsHasAlpha(r.image) { - return nil - } - - out, err := vipsAddAlpha(r.image) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// PremultiplyAlpha premultiplies the alpha channel. -// See https://libvips.github.io/libvips/API/current/libvips-conversion.html#vips-premultiply -func (r *ImageRef) PremultiplyAlpha() error { - defer runtime.KeepAlive(r) - if r.preMultiplication != nil || !vipsHasAlpha(r.image) { - return nil - } - - band := r.BandFormat() - - out, err := vipsGenPremultiply(r.image, nil) - if err != nil { - return err - } - r.preMultiplication = &PreMultiplicationState{ - bandFormat: band, - } - r.setImage(out) - return nil -} - -// UnpremultiplyAlpha unpremultiplies any alpha channel. -// See https://libvips.github.io/libvips/API/current/libvips-conversion.html#vips-unpremultiply -func (r *ImageRef) UnpremultiplyAlpha() error { - defer runtime.KeepAlive(r) - if r.preMultiplication == nil { - return nil - } - - unpremultiplied, err := vipsGenUnpremultiply(r.image, nil) - if err != nil { - return err - } - defer clearImage(unpremultiplied) - - out, err := vipsGenCast(unpremultiplied, r.preMultiplication.bandFormat, nil) - if err != nil { - return err - } - - r.preMultiplication = nil - r.setImage(out) - return nil -} - -// Add calculates a sum of the image + addend and stores it back in the image -func (r *ImageRef) Add(addend *ImageRef) error { - defer runtime.KeepAlive(r) - defer runtime.KeepAlive(addend) - out, err := vipsGenAdd(r.image, addend.image) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// Multiply calculates the product of the image * multiplier and stores it back in the image -func (r *ImageRef) Multiply(multiplier *ImageRef) error { - defer runtime.KeepAlive(r) - defer runtime.KeepAlive(multiplier) - out, err := vipsGenMultiply(r.image, multiplier.image) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// Divide calculates the product of the image / denominator and stores it back in the image -func (r *ImageRef) Divide(denominator *ImageRef) error { - defer runtime.KeepAlive(r) - defer runtime.KeepAlive(denominator) - out, err := vipsGenDivide(r.image, denominator.image) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// Average finds the average value in an image -func (r *ImageRef) Average() (float64, error) { - defer runtime.KeepAlive(r) - out, err := vipsGenAvg(r.image) - if err != nil { - return 0, err - } - return out, nil -} - -// FindTrim returns the bounding box of the non-border part of the image -// Returned values are left, top, width, height -func (r *ImageRef) FindTrim(threshold float64, backgroundColor *Color) (int, int, int, int, error) { - defer runtime.KeepAlive(r) - return vipsFindTrim(r.image, threshold, backgroundColor) -} - -// GetPoint reads a single pixel on an image. -// The pixel values are returned in a slice with one element per band. -func (r *ImageRef) GetPoint(x int, y int) ([]float64, error) { - defer runtime.KeepAlive(r) - return vipsGetPoint(r.image, r.Bands(), x, y) -} - -// Stats find many image statistics in a single pass through the data. Image is changed into a one-band -// `BandFormatDouble` image of at least 10 columns by n + 1 (where n is number of bands in image in) -// rows. Columns are statistics, and are, in order: minimum, maximum, sum, sum of squares, mean, -// standard deviation, x coordinate of minimum, y coordinate of minimum, x coordinate of maximum, -// y coordinate of maximum. -// -// Row 0 has statistics for all bands together, row 1 has stats for band 1, and so on. -// -// If there is more than one maxima or minima, one of them will be chosen at random. -func (r *ImageRef) Stats() error { - defer runtime.KeepAlive(r) - out, err := vipsGenStats(r.image) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// HistogramFind find the histogram the image. -// Find the histogram for all bands (producing a one-band histogram). -// char and uchar images are cast to uchar before histogramming, all other image types are cast to ushort. -func (r *ImageRef) HistogramFind() error { - defer runtime.KeepAlive(r) - out, err := vipsGenHistFind(r.image, nil) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// HistogramCumulative form cumulative histogram. -func (r *ImageRef) HistogramCumulative() error { - defer runtime.KeepAlive(r) - out, err := vipsGenHistCum(r.image) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// HistogramNormalise -// The maximum of each band becomes equal to the maximum index, so for example the max for a uchar -// image becomes 255. Normalise each band separately. -func (r *ImageRef) HistogramNormalise() error { - defer runtime.KeepAlive(r) - out, err := vipsGenHistNorm(r.image) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// HistogramEntropy estimate image entropy from a histogram. Entropy is calculated as: -// `-sum(p * log2(p))` -// where p is histogram-value / sum-of-histogram-values. -func (r *ImageRef) HistogramEntropy() (float64, error) { - defer runtime.KeepAlive(r) - return vipsGenHistEntropy(r.image) -} - -// DrawRect draws an (optionally filled) rectangle with a single colour -func (r *ImageRef) DrawRect(ink ColorRGBA, left int, top int, width int, height int, fill bool) error { - defer runtime.KeepAlive(r) - err := vipsDrawRect(r.image, ink, left, top, width, height, fill) - if err != nil { - return err - } - return nil -} - -// Subtract calculate subtract operation between two images. -func (r *ImageRef) Subtract(in2 *ImageRef) error { - defer runtime.KeepAlive(r) - defer runtime.KeepAlive(in2) - out, err := vipsGenSubtract(r.image, in2.image) - if err != nil { - return err - } - - r.setImage(out) - return nil -} - -// Abs calculate abs operation. -func (r *ImageRef) Abs() error { - defer runtime.KeepAlive(r) - out, err := vipsGenAbs(r.image) - if err != nil { - return err - } - - r.setImage(out) - return nil -} - -// Project calculate project operation. -func (r *ImageRef) Project() (*ImageRef, *ImageRef, error) { - defer runtime.KeepAlive(r) - col, row, err := vipsGenProject(r.image) - if err != nil { - return nil, nil, err - } - - return newImageRef(col, r.format, r.originalFormat, nil), newImageRef(row, r.format, r.originalFormat, nil), nil -} - -// Min finds the minimum value in an image. -func (r *ImageRef) Min() (float64, int, int, error) { - defer runtime.KeepAlive(r) - return vipsMin(r.image) -} diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/image_transform.go b/vendor/github.com/davidbyttow/govips/v2/vips/image_transform.go deleted file mode 100644 index 9975b4627c..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/image_transform.go +++ /dev/null @@ -1,458 +0,0 @@ -package vips - -// #include "image.h" -import "C" - -import ( - "errors" - "math" - "runtime" - "unsafe" -) - -// GetRotationAngleFromExif returns the angle which the image is currently rotated in. -// First returned value is the angle and second is a boolean indicating whether image is flipped. -// This is based on the EXIF orientation tag standard. -// If no proper orientation number is provided, the picture will be assumed to be upright. -func GetRotationAngleFromExif(orientation int) (Angle, bool) { - switch orientation { - case 0, 1, 2: - return Angle0, orientation == 2 - case 3, 4: - return Angle180, orientation == 4 - case 5, 8: - return Angle90, orientation == 5 - case 6, 7: - return Angle270, orientation == 7 - } - - return Angle0, false -} - -// AutoRotate rotates the image upright based on the EXIF Orientation tag, -// including the mirrored orientations (2, 4, 5 and 7), which libvips -// handles with a flip since 8.10. -// It also resets the orientation information in the EXIF tag to be 1 (i.e. upright). -// N.B. due to the HEIF image standard, HEIF images are always autorotated by default on load. -// Thus, calling AutoRotate for HEIF images is not needed. -// todo: use https://www.libvips.org/API/current/libvips-conversion.html#vips-autorot-remove-angle -func (r *ImageRef) AutoRotate() error { - defer runtime.KeepAlive(r) - out, _, _, err := vipsGenAutorot(r.image) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// ExtractArea crops the image to a specified area -func (r *ImageRef) ExtractArea(left, top, width, height int) error { - defer runtime.KeepAlive(r) - if r.Height() > r.PageHeight() { - // use animated extract area if more than 1 pages loaded - out, err := vipsExtractAreaMultiPage(r.image, left, top, width, height) - if err != nil { - return err - } - r.setImage(out) - } else { - out, err := vipsExtractArea(r.image, left, top, width, height) - if err != nil { - return err - } - r.setImage(out) - } - return nil -} - -// Resize resizes the image based on the scale, maintaining aspect ratio -func (r *ImageRef) Resize(scale float64, kernel Kernel) error { - return r.ResizeWithVScale(scale, -1, kernel) -} - -// ResizeWithVScale resizes the image with both horizontal and vertical scaling. -// The parameters are the scaling factors. -func (r *ImageRef) ResizeWithVScale(hScale, vScale float64, kernel Kernel) error { - defer runtime.KeepAlive(r) - if err := r.PremultiplyAlpha(); err != nil { - return err - } - - pages := r.loadedPages() - newPageHeight := 0 - if pages > 1 { - scale := hScale - if vScale > 0 { - scale = vScale - } - newPageHeight = int(math.Round(float64(r.PageHeight()) * scale)) - if newPageHeight < 1 { - newPageHeight = 1 - } - // libvips resizes the stacked frames as one strip, so rounding the - // strip and the page height separately can leave the strip a few - // rows short of pages*newPageHeight (#350, #554). When that happens, - // pick the vertical scale that makes the strip height exact, as - // vips_thumbnail does. Output is unchanged when the rounding agrees. - height := r.Height() - if int(math.Round(float64(height)*scale)) != pages*newPageHeight { - vScale = float64(pages*newPageHeight) / float64(height) - } - } - - out, err := vipsResizeWithVScale(r.image, hScale, vScale, kernel) - if err != nil { - return err - } - r.setImage(out) - - if pages > 1 { - if err := r.SetPageHeight(newPageHeight); err != nil { - return err - } - } - - return r.UnpremultiplyAlpha() -} - -// loadedPages is the number of pages stacked in the image. Pages() reports -// the page count of the file, which is larger when only some were loaded. -func (r *ImageRef) loadedPages() int { - pageHeight := r.PageHeight() - if pageHeight <= 0 { - return 1 - } - return r.Height() / pageHeight -} - -// Thumbnail resizes the image to the given width and height. -// crop decides algorithm vips uses to shrink and crop to fill target, -func (r *ImageRef) Thumbnail(width, height int, crop Interesting) error { - defer runtime.KeepAlive(r) - out, err := vipsThumbnail(r.image, width, height, crop, SizeBoth) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// ThumbnailWithSize resizes the image to the given width and height. -// crop decides algorithm vips uses to shrink and crop to fill target, -// size controls upsize, downsize, both or force -func (r *ImageRef) ThumbnailWithSize(width, height int, crop Interesting, size Size) error { - defer runtime.KeepAlive(r) - out, err := vipsThumbnail(r.image, width, height, crop, size) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// Embed embeds the given picture in a new one, i.e. the opposite of ExtractArea -func (r *ImageRef) Embed(left, top, width, height int, extend ExtendStrategy) error { - defer runtime.KeepAlive(r) - if r.Height() > r.PageHeight() { - out, err := vipsEmbedMultiPage(r.image, left, top, width, height, extend) - if err != nil { - return err - } - r.setImage(out) - } else { - out, err := vipsEmbed(r.image, left, top, width, height, extend) - if err != nil { - return err - } - r.setImage(out) - } - return nil -} - -// EmbedBackground embeds the given picture with a background color. -// For greyscale images (1-2 bands) the R value is used as the grey level. -func (r *ImageRef) EmbedBackground(left, top, width, height int, backgroundColor *Color) error { - defer runtime.KeepAlive(r) - c := &ColorRGBA{ - R: backgroundColor.R, - G: backgroundColor.G, - B: backgroundColor.B, - A: 255, - } - if r.Height() > r.PageHeight() { - out, err := vipsEmbedMultiPageBackground(r.image, left, top, width, height, c) - if err != nil { - return err - } - r.setImage(out) - } else { - out, err := vipsEmbedBackground(r.image, left, top, width, height, c) - if err != nil { - return err - } - r.setImage(out) - } - return nil -} - -// EmbedBackgroundRGBA embeds the given picture with a background rgba color. -// For greyscale images the background is built from R and A only: -// 1 band uses {R}, 2 bands (grey+alpha) use {R, A}. -func (r *ImageRef) EmbedBackgroundRGBA(left, top, width, height int, backgroundColor *ColorRGBA) error { - defer runtime.KeepAlive(r) - if r.Height() > r.PageHeight() { - out, err := vipsEmbedMultiPageBackground(r.image, left, top, width, height, backgroundColor) - if err != nil { - return err - } - r.setImage(out) - } else { - out, err := vipsEmbedBackground(r.image, left, top, width, height, backgroundColor) - if err != nil { - return err - } - r.setImage(out) - } - return nil -} - -// Zoom zooms the image by repeating pixels (fast nearest-neighbour) -func (r *ImageRef) Zoom(xFactor int, yFactor int) error { - defer runtime.KeepAlive(r) - pages := r.loadedPages() - pageHeight := r.PageHeight() - out, err := vipsGenZoom(r.image, xFactor, yFactor) - if err != nil { - return err - } - r.setImage(out) - if pages > 1 { - // Zooming the strip zooms every frame; only the page height is stale. - return r.SetPageHeight(pageHeight * yFactor) - } - return nil -} - -func (r *ImageRef) Gravity(gravity Gravity, width int, height int) error { - defer runtime.KeepAlive(r) - out, err := vipsGenGravity(r.image, gravity, width, height, nil) - if err != nil { - return err - } - - r.setImage(out) - return nil -} - -// Flip flips the image either horizontally or vertically based on the parameter -func (r *ImageRef) Flip(direction Direction) error { - defer runtime.KeepAlive(r) - var out *C.VipsImage - var err error - if direction == DirectionVertical && r.loadedPages() > 1 { - // Flipping the strip would reverse the frame order. - out, err = vipsMapPages(r.image, func(page *C.VipsImage) (*C.VipsImage, error) { - return vipsFlip(page, direction) - }) - } else { - out, err = vipsFlip(r.image, direction) - } - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// Recomb recombines the image bands using the matrix provided -func (r *ImageRef) Recomb(matrix [][]float64) error { - defer runtime.KeepAlive(r) - numBands := r.Bands() - // Ensure the provided matrix is 3x3 - if len(matrix) != 3 || len(matrix[0]) != 3 || len(matrix[1]) != 3 || len(matrix[2]) != 3 { - return errors.New("Invalid recombination matrix") - } - // If the image is RGBA, expand the matrix to 4x4 - if numBands == 4 { - matrix = append(matrix, []float64{0, 0, 0, 1}) - for i := 0; i < 3; i++ { - matrix[i] = append(matrix[i], 0) - } - } else if numBands != 3 { - return errors.New("Unsupported number of bands") - } - - // Flatten the matrix - matrixValues := make([]float64, 0, numBands*numBands) - for _, row := range matrix { - for _, value := range row { - matrixValues = append(matrixValues, value) - } - } - - // Convert the Go slice to a C array and get its size - matrixPtr := unsafe.Pointer(&matrixValues[0]) - matrixSize := C.size_t(len(matrixValues) * 8) // 8 bytes for each float64 - - // Create a VipsImage from the matrix in memory - matrixImage := C.vips_image_new_from_memory(matrixPtr, matrixSize, C.int(numBands), C.int(numBands), 1, C.VIPS_FORMAT_DOUBLE) - defer clearImage(matrixImage) - - if matrixImage == nil { - return handleVipsError() - } - - // Recombine the image using the matrix - out, err := vipsGenRecomb(r.image, matrixImage) - runtime.KeepAlive(matrixValues) - if err != nil { - return err - } - - r.setImage(out) - return nil -} - -// Rotate rotates the image by multiples of 90 degrees. To rotate by arbitrary angles use Similarity. -func (r *ImageRef) Rotate(angle Angle) error { - defer runtime.KeepAlive(r) - width := r.Width() - pages := r.loadedPages() - - if pages > 1 && angle == Angle180 { - // Rotating the strip would reverse the frame order. - out, err := vipsMapPages(r.image, func(page *C.VipsImage) (*C.VipsImage, error) { - return vipsGenRot(page, angle) - }) - if err != nil { - return err - } - r.setImage(out) - return nil - } - - if pages > 1 && (angle == Angle90 || angle == Angle270) { - if angle == Angle270 { - if err := r.Flip(DirectionHorizontal); err != nil { - return err - } - } - - if err := r.Grid(r.PageHeight(), pages, 1); err != nil { - return err - } - - if angle == Angle270 { - if err := r.Flip(DirectionHorizontal); err != nil { - return err - } - } - - } - - out, err := vipsGenRot(r.image, angle) - if err != nil { - return err - } - r.setImage(out) - - if pages > 1 && (angle == Angle90 || angle == Angle270) { - if err := r.SetPageHeight(width); err != nil { - return err - } - } - return nil -} - -// Similarity lets you scale, offset and rotate images by arbitrary angles in a single operation while defining the -// color of new background pixels. If the input image has no alpha channel, the alpha on `backgroundColor` will be -// ignored. You can add an alpha channel to an image with `BandJoinConst` (e.g. `img.BandJoinConst([]float64{255})`) or -// AddAlpha. -func (r *ImageRef) Similarity(scale float64, angle float64, backgroundColor *ColorRGBA, - idx float64, idy float64, odx float64, ody float64) error { - defer runtime.KeepAlive(r) - out, err := vipsSimilarity(r.image, scale, angle, backgroundColor, idx, idy, odx, ody) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// Grid tiles the image pages into a matrix across*down -func (r *ImageRef) Grid(tileHeight, across, down int) error { - defer runtime.KeepAlive(r) - out, err := vipsGenGrid(r.image, tileHeight, across, down) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// SmartCrop will crop the image based on interesting factor -func (r *ImageRef) SmartCrop(width int, height int, interesting Interesting) error { - defer runtime.KeepAlive(r) - out, err := vipsSmartCrop(r.image, width, height, interesting) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// Crop will crop the image based on coordinate and box size -func (r *ImageRef) Crop(left int, top int, width int, height int) error { - defer runtime.KeepAlive(r) - out, err := vipsCrop(r.image, left, top, width, height) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// Label overlays a label on top of the image -func (r *ImageRef) Label(labelParams *LabelParams) error { - defer runtime.KeepAlive(r) - out, err := labelImage(r.image, labelParams) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// Replicate repeats an image many times across and down -func (r *ImageRef) Replicate(across int, down int) error { - defer runtime.KeepAlive(r) - out, err := vipsGenReplicate(r.image, across, down) - if err != nil { - return err - } - r.setImage(out) - return nil -} - -// Pixelate applies a simple pixelate filter to the image -func Pixelate(imageRef *ImageRef, factor float64) (err error) { - if factor < 1 { - return errors.New("factor must be greater then 1") - } - - width := imageRef.Width() - height := imageRef.Height() - - if err = imageRef.Resize(1/factor, KernelAuto); err != nil { - return - } - - hScale := float64(width) / float64(imageRef.Width()) - vScale := float64(height) / float64(imageRef.Height()) - if err = imageRef.ResizeWithVScale(hScale, vScale, KernelNearest); err != nil { - return - } - - return -} diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/interpolate.go b/vendor/github.com/davidbyttow/govips/v2/vips/interpolate.go deleted file mode 100644 index 4854f2346a..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/interpolate.go +++ /dev/null @@ -1,20 +0,0 @@ -package vips - -// #include -import "C" - -import "unsafe" - -// NewInterpolate creates a VipsInterpolate from a name string. -// Common names: "nearest", "bilinear", "bicubic", "nohalo", "vsqbs", "lbb". -// The caller should call g_object_unref on the result when done, or pass it -// to a generated operation (which does not take ownership). -func NewInterpolate(name string) (*C.VipsInterpolate, error) { - cName := C.CString(name) - defer C.free(unsafe.Pointer(cName)) - interp := C.vips_interpolate_new(cName) - if interp == nil { - return nil, handleVipsError() - } - return interp, nil -} diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/lang.go b/vendor/github.com/davidbyttow/govips/v2/vips/lang.go deleted file mode 100644 index 56ce86a3b0..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/lang.go +++ /dev/null @@ -1,62 +0,0 @@ -package vips - -// #include -// #include -import "C" - -import ( - "reflect" - "unsafe" -) - -func freeCString(s *C.char) { - C.free(unsafe.Pointer(s)) -} - -func gFreePointer(ref unsafe.Pointer) { - C.g_free(C.gpointer(ref)) -} - -func boolToInt(b bool) int { - if b { - return 1 - } - return 0 -} - -func toGboolean(b bool) C.gboolean { - if b { - return C.gboolean(1) - } - return C.gboolean(0) -} - -func fromGboolean(b C.gboolean) bool { - return b != 0 -} - -func fromCArrayInt(out *C.int, n int) []int { - var result = make([]int, n) - var data []C.int - sh := (*reflect.SliceHeader)(unsafe.Pointer(&data)) - sh.Data = uintptr(unsafe.Pointer(out)) - sh.Len = n - sh.Cap = n - for i := range data { - result[i] = int(data[i]) - } - return result -} - -func fromCArrayDouble(out *C.double, n int) []float64 { - if out == nil || n <= 0 { - return nil - } - - data := make([]float64, n) - for i := 0; i < n; i++ { - data[i] = float64(*(*C.double)(unsafe.Pointer(uintptr(unsafe.Pointer(out)) + uintptr(i)*unsafe.Sizeof(C.double(0))))) - } - - return data -} diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/lang.h b/vendor/github.com/davidbyttow/govips/v2/vips/lang.h deleted file mode 100644 index 089d58e795..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/lang.h +++ /dev/null @@ -1,2 +0,0 @@ -#include -#include diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/logging.go b/vendor/github.com/davidbyttow/govips/v2/vips/logging.go deleted file mode 100644 index 5053d0162f..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/logging.go +++ /dev/null @@ -1,98 +0,0 @@ -package vips - -// #include -import "C" -import ( - "log" -) - -// LogLevel is the enum controlling logging message verbosity. -type LogLevel int - -// The logging verbosity levels classify and filter logging messages. -// From most to least verbose, they are debug, info, message, warning, critical and error. -const ( - LogLevelError LogLevel = C.G_LOG_LEVEL_ERROR - LogLevelCritical LogLevel = C.G_LOG_LEVEL_CRITICAL - LogLevelWarning LogLevel = C.G_LOG_LEVEL_WARNING - LogLevelMessage LogLevel = C.G_LOG_LEVEL_MESSAGE - LogLevelInfo LogLevel = C.G_LOG_LEVEL_INFO - LogLevelDebug LogLevel = C.G_LOG_LEVEL_DEBUG -) - -// Three global variables which keep state of the current logging handler -// function, desired verbosity for logging and whether defaults have been -// overridden. Set by LoggingSettings() -var ( - currentLoggingHandlerFunction LoggingHandlerFunction - currentLoggingVerbosity LogLevel - currentLoggingOverridden bool -) - -// govipsLoggingHandler is the private bridge function exported to the C library -// and called by glib and libvips for each logging message. It will call govipsLog -// which in turn will filter based on verbosity and direct the messages to the -// currently chosen LoggingHandlerFunction. -// -//export govipsLoggingHandler -func govipsLoggingHandler(messageDomain *C.char, messageLevel C.int, message *C.char) { - govipsLog(C.GoString(messageDomain), LogLevel(messageLevel), C.GoString(message)) -} - -// LoggingHandlerFunction is a function which will be called for each log message. -// By default, govips sends logging messages to os.Stderr. If you want to log elsewhere -// such as to a file or to a state variable which you inspect yourself, define a new -// logging handler function and set it via LoggingSettings(). -type LoggingHandlerFunction func(messageDomain string, messageLevel LogLevel, message string) - -// LoggingSettings sets the logging handler and logging verbosity for govips. -// The handler function is the function which will be called for each log message. -// You can define one yourself to log somewhere else besides the default (stderr). -// Use nil as handler to use standard logging handler. -// Verbosity is the minimum logLevel you want to log. Default is logLevelInfo -// due to backwards compatibility but it's quite verbose for a library. -// Suggest setting it to at least logLevelWarning. Use logLevelDebug for debugging. -func LoggingSettings(handler LoggingHandlerFunction, verbosity LogLevel) { - currentLoggingOverridden = true - govipsLoggingSettings(handler, verbosity) -} - -func govipsLoggingSettings(handler LoggingHandlerFunction, verbosity LogLevel) { - if handler == nil { - currentLoggingHandlerFunction = defaultLoggingHandlerFunction - } else { - currentLoggingHandlerFunction = handler - } - - currentLoggingVerbosity = verbosity - // TODO turn on debugging in libvips and redirect to handler when setting verbosity to debug - // This way debugging information would go to the same channel as all other logging -} - -func defaultLoggingHandlerFunction(messageDomain string, messageLevel LogLevel, message string) { - var messageLevelDescription string - switch messageLevel { - case LogLevelError: - messageLevelDescription = "error" - case LogLevelCritical: - messageLevelDescription = "critical" - case LogLevelWarning: - messageLevelDescription = "warning" - case LogLevelMessage: - messageLevelDescription = "message" - case LogLevelInfo: - messageLevelDescription = "info" - case LogLevelDebug: - messageLevelDescription = "debug" - } - - log.Printf("[%v.%v] %v", messageDomain, messageLevelDescription, message) -} - -// govipsLog is the default function used to log debug or error messages internally in govips. -// It's used by all govips functionality directly, as well as by glib and libvips via the C bridge. -func govipsLog(messageDomain string, messageLevel LogLevel, message string) { - if messageLevel <= currentLoggingVerbosity { - currentLoggingHandlerFunction(messageDomain, messageLevel, message) - } -} diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/math.go b/vendor/github.com/davidbyttow/govips/v2/vips/math.go deleted file mode 100644 index b4e1bff344..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/math.go +++ /dev/null @@ -1,57 +0,0 @@ -package vips - -import "math" - -// Scalar is the basic scalar measurement of an image's height, width or offset coordinate. -type Scalar struct { - Value float64 - Relative bool -} - -// ValueOf takes a floating point value and returns a corresponding Scalar struct -func ValueOf(value float64) Scalar { - return Scalar{value, false} -} - -// IsZero checks whether the associated Scalar's value is zero. -func (s *Scalar) IsZero() bool { - return s.Value == 0 && !s.Relative -} - -// SetInt sets an integer value for the associated Scalar. -func (s *Scalar) SetInt(value int) { - s.Set(float64(value)) -} - -// Set sets a float value for the associated Scalar. -func (s *Scalar) Set(value float64) { - s.Value = value - s.Relative = false -} - -// SetScale sets a float value for the associated Scalar and makes it relative. -func (s *Scalar) SetScale(f float64) { - s.Value = f - s.Relative = true -} - -// Get returns the value of the scalar. Either absolute, or if relative, multiplied by the base given as parameter. -func (s *Scalar) Get(base int) float64 { - if s.Relative { - return s.Value * float64(base) - } - return s.Value -} - -// GetRounded returns the value of the associated Scalar, rounded to the nearest integer, if absolute. -// If the Scalar is relative, it will be multiplied by the supplied base parameter. -func (s *Scalar) GetRounded(base int) int { - return roundFloat(s.Get(base)) -} - -func roundFloat(f float64) int { - if f < 0 { - return int(math.Ceil(f - 0.5)) - } - return int(math.Floor(f + 0.5)) -} diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/operations.c b/vendor/github.com/davidbyttow/govips/v2/vips/operations.c deleted file mode 100644 index 449e15d382..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/operations.c +++ /dev/null @@ -1,505 +0,0 @@ -// operations.c - Hand-written C bridge functions for libvips operations - -#include "lang.h" -#include "operations.h" - -#include - -static int is_16bit(VipsInterpretation interpretation); - -// Arithmetic - -int find_trim(VipsImage *in, int *left, int *top, int *width, int *height, - double threshold, double r, double g, double b) { - - if (in->Type == VIPS_INTERPRETATION_RGB16 || in->Type == VIPS_INTERPRETATION_GREY16) { - r = 65535 * r / 255; - g = 65535 * g / 255; - b = 65535 * b / 255; - } - - double background[3] = {r, g, b}; - VipsArrayDouble *vipsBackground = vips_array_double_new(background, 3); - - int code = vips_find_trim(in, left, top, width, height, "threshold", threshold, "background", vipsBackground, NULL); - - vips_area_unref(VIPS_AREA(vipsBackground)); - return code; -} - -int getpoint(VipsImage *in, double **vector, int n, int x, int y) { - return vips_getpoint(in, vector, &n, x, y, NULL); -} - -int minOp(VipsImage *in, double *out, int *x, int *y, int size) { - return vips_min(in, out, "x", x, "y", y, "size", size, NULL); -} - -// Color - -int is_colorspace_supported(VipsImage *in) { - return vips_colourspace_issupported(in) ? 1 : 0; -} - -int to_colorspace(VipsImage *in, VipsImage **out, VipsInterpretation space) { - return vips_colourspace(in, out, space, NULL); -} - -// https://libvips.github.io/libvips/API/8.6/libvips-colour.html#vips-icc-transform -int icc_transform(VipsImage *in, VipsImage **out, const char *output_profile, const char *input_profile, VipsIntent intent, - int depth, gboolean embedded) { - return vips_icc_transform( - in, out, output_profile, - "input_profile", input_profile ? input_profile : "none", - "intent", intent, - "depth", depth ? depth : 8, - "embedded", embedded, - NULL); -} - -// Conversion - -// background_for_bands fills vec with a background vector sized to the -// image's band count and returns the element count; libvips rejects -// vectors longer than the band count (e.g. "linear: vector must have 1 -// or 2 elements" for greyscale images). Greyscale images take the R -// value as the grey level: 1 band -> {r}, 2 bands -> {r, a}. -static int background_for_bands(VipsImage *in, double vec[4], double r, - double g, double b, double a) { - switch (in->Bands) { - case 1: - vec[0] = r; - return 1; - case 2: - vec[0] = r; - vec[1] = a; - return 2; - case 3: - vec[0] = r; - vec[1] = g; - vec[2] = b; - return 3; - default: - vec[0] = r; - vec[1] = g; - vec[2] = b; - vec[3] = a; - return 4; - } -} - -int embed_image(VipsImage *in, VipsImage **out, int left, int top, int width, - int height, int extend) { - return vips_embed(in, out, left, top, width, height, "extend", extend, NULL); -} - -int embed_image_background(VipsImage *in, VipsImage **out, int left, int top, int width, - int height, double r, double g, double b, double a) { - - double background[4]; - int n = background_for_bands(in, background, r, g, b, a); - VipsArrayDouble *vipsBackground = vips_array_double_new(background, n); - - int code = vips_embed(in, out, left, top, width, height, - "extend", VIPS_EXTEND_BACKGROUND, "background", vipsBackground, NULL); - - vips_area_unref(VIPS_AREA(vipsBackground)); - return code; -} - -int embed_multi_page_image(VipsImage *in, VipsImage **out, int left, int top, int width, - int height, int extend) { - VipsObject *base = VIPS_OBJECT(vips_image_new()); - int page_height = vips_image_get_page_height(in); - int in_width = in->Xsize; - int n_pages = in->Ysize / page_height; - - VipsImage **page = (VipsImage **) vips_object_local_array(base, n_pages); - VipsImage **embedded_page = (VipsImage **) vips_object_local_array(base, n_pages); - VipsImage **copy = (VipsImage **) vips_object_local_array(base, 1); - - // split image into cropped frames - for (int i = 0; i < n_pages; i++) { - if ( - vips_extract_area(in, &page[i], 0, page_height * i, in_width, page_height, NULL) || - vips_embed(page[i], &embedded_page[i], left, top, width, height, "extend", extend, NULL) - ) { - g_object_unref(base); - return -1; - } - } - // reassemble frames and set page height - // copy before modifying metadata - if( - vips_arrayjoin(embedded_page, ©[0], n_pages, "across", 1, NULL) || - vips_copy(copy[0], out, NULL) - ) { - g_object_unref(base); - return -1; - } - vips_image_set_int(*out, VIPS_META_PAGE_HEIGHT, height); - g_object_unref(base); - return 0; -} - -int embed_multi_page_image_background(VipsImage *in, VipsImage **out, int left, int top, int width, - int height, double r, double g, double b, double a) { - double background[4]; - int n = background_for_bands(in, background, r, g, b, a); - VipsArrayDouble *vipsBackground = vips_array_double_new(background, n); - - VipsObject *base = VIPS_OBJECT(vips_image_new()); - int page_height = vips_image_get_page_height(in); - int in_width = in->Xsize; - int n_pages = in->Ysize / page_height; - - VipsImage **page = (VipsImage **) vips_object_local_array(base, n_pages); - VipsImage **embedded_page = (VipsImage **) vips_object_local_array(base, n_pages); - VipsImage **copy = (VipsImage **) vips_object_local_array(base, 1); - - // split image into cropped frames - for (int i = 0; i < n_pages; i++) { - if ( - vips_extract_area(in, &page[i], 0, page_height * i, in_width, page_height, NULL) || - vips_embed(page[i], &embedded_page[i], left, top, width, height, - "extend", VIPS_EXTEND_BACKGROUND, "background", vipsBackground, NULL) - ) { - vips_area_unref(VIPS_AREA(vipsBackground)); - g_object_unref(base); - return -1; - } - } - // reassemble frames and set page height - // copy before modifying metadata - if( - vips_arrayjoin(embedded_page, ©[0], n_pages, "across", 1, NULL) || - vips_copy(copy[0], out, NULL) - ) { - vips_area_unref(VIPS_AREA(vipsBackground)); - g_object_unref(base); - return -1; - } - vips_image_set_int(*out, VIPS_META_PAGE_HEIGHT, height); - vips_area_unref(VIPS_AREA(vipsBackground)); - g_object_unref(base); - return 0; -} - - -int similarity(VipsImage *in, VipsImage **out, double scale, double angle, - double r, double g, double b, double a, double idx, double idy, - double odx, double ody) { - if (is_16bit(in->Type)) { - r = 65535 * r / 255; - g = 65535 * g / 255; - b = 65535 * b / 255; - a = 65535 * a / 255; - } - - double background[4]; - int n = background_for_bands(in, background, r, g, b, a); - VipsArrayDouble *vipsBackground = vips_array_double_new(background, n); - - int code = vips_similarity(in, out, "scale", scale, "angle", angle, - "background", vipsBackground, "idx", idx, "idy", - idy, "odx", odx, "ody", ody, NULL); - - vips_area_unref(VIPS_AREA(vipsBackground)); - return code; -} - -int crop(VipsImage *in, VipsImage **out, int left, int top, - int width, int height) { - // resolve image pages - int page_height = vips_image_get_page_height(in); - int n_pages = in->Ysize / page_height; - if (n_pages <= 1) { - return vips_crop(in, out, left, top, width, height, NULL); - } - - int in_width = in->Xsize; - VipsObject *base = VIPS_OBJECT(vips_image_new()); - VipsImage **page = (VipsImage **) vips_object_local_array(base, n_pages); - VipsImage **cropped_page = (VipsImage **) vips_object_local_array(base, n_pages); - VipsImage **copy = (VipsImage **) vips_object_local_array(base, 1); - // split image into cropped frames - for (int i = 0; i < n_pages; i++) { - if ( - vips_extract_area(in, &page[i], 0, page_height * i, in_width, page_height, NULL) || - vips_crop(page[i], &cropped_page[i], left, top, width, height, NULL) - ) { - g_object_unref(base); - return -1; - } - } - - // reassemble frames and set page height - // copy before modifying metadata - if( - vips_arrayjoin(cropped_page, ©[0], n_pages, "across", 1, NULL) || - vips_copy(copy[0], out, NULL) - ) { - g_object_unref(base); - return -1; - } - vips_image_set_int(*out, VIPS_META_PAGE_HEIGHT, height); - g_object_unref(base); - return 0; -} - -static int is_16bit(VipsInterpretation interpretation) { - return interpretation == VIPS_INTERPRETATION_RGB16 || - interpretation == VIPS_INTERPRETATION_GREY16; -} - -int composite_image(VipsImage **in, VipsImage **out, int n, int *mode, int *x, - int *y) { - VipsArrayInt *xs = vips_array_int_new(x, n - 1); - VipsArrayInt *ys = vips_array_int_new(y, n - 1); - - int code = vips_composite(in, out, n, mode, "x", xs, "y", ys, NULL); - - vips_area_unref(VIPS_AREA(xs)); - vips_area_unref(VIPS_AREA(ys)); - return code; -} - -int join(VipsImage *in1, VipsImage *in2, VipsImage **out, int direction) { - return vips_join(in1, in2, out, direction, NULL); -} - -int add_alpha(VipsImage *in, VipsImage **out) { - return vips_addalpha(in, out, NULL); -} - -// Create - -// https://libvips.github.io/libvips/API/current/libvips-create.html#vips-text -int text(VipsImage **out, TextOptions *o) { - return vips_text(out, o->Text, "font", o->Font, "width", o->Width, "height", o->Height, "align", o->Align, - "dpi", o->DPI, "rgba", o->RGBA, "justify", o->Justify, "spacing", o->Spacing, "wrap", o->Wrap, NULL); -} - -// Draw - -int draw_rect(VipsImage *in, double r, double g, double b, double a, int left, - int top, int width, int height, int fill) { - if (is_16bit(in->Type)) { - r = 65535 * r / 255; - g = 65535 * g / 255; - b = 65535 * b / 255; - a = 65535 * a / 255; - } - - double ink[4]; - int n = background_for_bands(in, ink, r, g, b, a); - return vips_draw_rect(in, ink, n, left, top, width, height, "fill", fill, - NULL); -} - -// Header - -unsigned long has_icc_profile(VipsImage *in) { - return vips_image_get_typeof(in, VIPS_META_ICC_NAME); -} - -unsigned long get_icc_profile(VipsImage *in, const void **data, - size_t *dataLength) { - return image_get_blob(in, VIPS_META_ICC_NAME, data, dataLength); -} - -gboolean remove_icc_profile(VipsImage *in) { - return vips_image_remove(in, VIPS_META_ICC_NAME); -} - -unsigned long has_iptc(VipsImage *in) { - return vips_image_get_typeof(in, VIPS_META_IPTC_NAME); -} - -char **image_get_fields(VipsImage *in) { return vips_image_get_fields(in); } - -void image_set_string(VipsImage *in, const char *name, const char *str) { - vips_image_set_string(in, name, str); -} - -unsigned long image_get_string(VipsImage *in, const char *name, - const char **out) { - return vips_image_get_string(in, name, out); -} - -unsigned long image_get_as_string(VipsImage *in, const char *name, char **out) { - return vips_image_get_as_string(in, name, out); -} - -void remove_field(VipsImage *in, char *field) { vips_image_remove(in, field); } - -int get_meta_orientation(VipsImage *in) { - int orientation = 0; - if (vips_image_get_typeof(in, VIPS_META_ORIENTATION) != 0) { - vips_image_get_int(in, VIPS_META_ORIENTATION, &orientation); - } - - return orientation; -} - -void remove_meta_orientation(VipsImage *in) { - vips_image_remove(in, VIPS_META_ORIENTATION); -} - -void set_meta_orientation(VipsImage *in, int orientation) { - vips_image_set_int(in, VIPS_META_ORIENTATION, orientation); -} - -// https://libvips.github.io/libvips/API/current/libvips-header.html#vips-image-get-n-pages -int get_image_n_pages(VipsImage *in) { - int n_pages = 0; - n_pages = vips_image_get_n_pages(in); - return n_pages; -} - -void set_image_n_pages(VipsImage *in, int n_pages) { - vips_image_set_int(in, VIPS_META_N_PAGES, n_pages); -} - -// https://www.libvips.org/API/current/libvips-header.html#vips-image-get-page-height -int get_page_height(VipsImage *in) { - int page_height = 0; - page_height = vips_image_get_page_height(in); - return page_height; -} - -void set_page_height(VipsImage *in, int height) { - vips_image_set_int(in, VIPS_META_PAGE_HEIGHT, height); -} - -int get_meta_loader(const VipsImage *in, const char **out) { - return vips_image_get_string(in, VIPS_META_LOADER, out); -} - -int get_background(VipsImage *in, double **out, int *n) { - return vips_image_get_array_double(in, "background", out, n); -} - -int get_image_delay(VipsImage *in, int **out) { - return vips_image_get_array_int(in, "delay", out, NULL); -} - -void set_image_delay(VipsImage *in, const int *array, int n) { - vips_image_set_array_int(in, "delay", array, n); -} - -int get_image_loop(VipsImage *in) { - int loop = 0; - if (vips_image_get_typeof(in, "loop") != 0) { - vips_image_get_int(in, "loop", &loop); - } - return loop; -} - -void set_image_loop(VipsImage *in, int loop) { - vips_image_set_int(in, "loop", loop); -} - -void image_set_double(VipsImage *in, const char *name, double i) { - vips_image_set_double(in, name, i); -} - -unsigned long image_get_double(VipsImage *in, const char *name, double *out) { - return vips_image_get_double(in, name, out); -} - -void image_set_int(VipsImage *in, const char *name, int i) { - vips_image_set_int(in, name, i); -} - -unsigned long image_get_int(VipsImage *in, const char *name, int *out) { - return vips_image_get_int(in, name, out); -} - -void image_set_blob(VipsImage *in, const char *name, const void *data, - size_t dataLength) { - vips_image_set_blob_copy(in, name, data, dataLength); -} - -unsigned long image_get_blob(VipsImage *in, const char *name, const void **data, - size_t *dataLength) { - if (vips_image_get_typeof(in, name) == 0) { - return 0; - } - - if (vips_image_get_blob(in, name, data, dataLength)) { - return -1; - } - - return 0; -} - -// Label - -int label(VipsImage *in, VipsImage **out, LabelOptions *o) { - double ones[3] = {1, 1, 1}; - VipsImage *base = vips_image_new(); - VipsImage **t = (VipsImage **)vips_object_local_array(VIPS_OBJECT(base), 9); - if (vips_text(&t[0], o->Text, "font", o->Font, "width", o->Width, "height", - o->Height, "align", o->Align, NULL) || - vips_linear1(t[0], &t[1], o->Opacity, 0.0, NULL) || - vips_cast(t[1], &t[2], VIPS_FORMAT_UCHAR, NULL) || - vips_embed(t[2], &t[3], o->OffsetX, o->OffsetY, t[2]->Xsize + o->OffsetX, - t[2]->Ysize + o->OffsetY, NULL)) { - g_object_unref(base); - return -1; - } - if (vips_black(&t[4], 1, 1, NULL) || - vips_linear(t[4], &t[5], ones, o->Color, 3, NULL) || - vips_cast(t[5], &t[6], VIPS_FORMAT_UCHAR, NULL) || - vips_copy(t[6], &t[7], "interpretation", in->Type, NULL) || - vips_embed(t[7], &t[8], 0, 0, in->Xsize, in->Ysize, "extend", - VIPS_EXTEND_COPY, NULL)) { - g_object_unref(base); - return -1; - } - if (vips_ifthenelse(t[3], t[8], in, out, "blend", TRUE, NULL)) { - g_object_unref(base); - return -1; - } - g_object_unref(base); - return 0; -} - -// Resample - -int resize_image(VipsImage *in, VipsImage **out, double scale, gdouble vscale, - int kernel) { - if (vscale > 0) { - return vips_resize(in, out, scale, "vscale", vscale, "kernel", kernel, - NULL); - } - - return vips_resize(in, out, scale, "kernel", kernel, NULL); -} - -int thumbnail(const char *filename, VipsImage **out, - int width, int height, int crop, int size) { - return vips_thumbnail(filename, out, width, "height", height, - "crop", crop, "size", size, NULL); -} - -int thumbnail_image(VipsImage *in, VipsImage **out, int width, int height, - int crop, int size) { - return vips_thumbnail_image(in, out, width, "height", height, "crop", crop, - "size", size, NULL); -} - -int thumbnail_buffer_with_option(void *buf, size_t len, VipsImage **out, - int width, int height, int crop, int size, - const char *option_string) { - return vips_thumbnail_buffer(buf, len, out, width, "height", height, - "crop", crop, "size", size, - "option_string", option_string, NULL); -} - -int thumbnail_buffer(void *buf, size_t len, VipsImage **out, - int width, int height, int crop, int size) { - return vips_thumbnail_buffer(buf, len, out, width, "height", height, - "crop", crop, "size", size, NULL); -} diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/operations.go b/vendor/github.com/davidbyttow/govips/v2/vips/operations.go deleted file mode 100644 index faf2321b64..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/operations.go +++ /dev/null @@ -1,1083 +0,0 @@ -package vips - -// #cgo CFLAGS: -std=c99 -// #include "operations.h" -import "C" -import ( - "errors" - "os" - "runtime" - "strings" - "unsafe" -) - -// Arithmetic - -// https://libvips.github.io/libvips/API/current/libvips-arithmetic.html#vips-find-trim -func vipsFindTrim(in *C.VipsImage, threshold float64, backgroundColor *Color) (int, int, int, int, error) { - incOpCounter("findTrim") - var left, top, width, height C.int - - if err := C.find_trim(in, &left, &top, &width, &height, C.double(threshold), C.double(backgroundColor.R), - C.double(backgroundColor.G), C.double(backgroundColor.B)); err != 0 { - return -1, -1, -1, -1, handleVipsError() - } - - return int(left), int(top), int(width), int(height), nil -} - -// https://libvips.github.io/libvips/API/current/libvips-arithmetic.html#vips-getpoint -func vipsGetPoint(in *C.VipsImage, n int, x int, y int) ([]float64, error) { - incOpCounter("getpoint") - var out *C.double - - if err := C.getpoint(in, &out, C.int(n), C.int(x), C.int(y)); err != 0 { - return nil, handleVipsError() - } - - // Copy from C memory into a Go slice, then free the C allocation. - result := make([]float64, n) - copy(result, unsafe.Slice((*float64)(unsafe.Pointer(out)), n)) - gFreePointer(unsafe.Pointer(out)) - return result, nil -} - -// https://www.libvips.org/API/current/libvips-arithmetic.html#vips-min -func vipsMin(in *C.VipsImage) (float64, int, int, error) { - incOpCounter("min") - var out C.double - var x, y C.int - - if err := C.minOp(in, &out, &x, &y, C.int(1)); err != 0 { - return 0, 0, 0, handleVipsError() - } - - return float64(out), int(x), int(y), nil -} - -// Color - -// Color represents an RGB -type Color struct { - R, G, B uint8 -} - -// ColorRGBA represents an RGB with alpha channel (A) -type ColorRGBA struct { - R, G, B, A uint8 -} - -// Interpretation represents VIPS_INTERPRETATION type -type Interpretation int - -// Interpretation enum -const ( - InterpretationError Interpretation = C.VIPS_INTERPRETATION_ERROR - InterpretationMultiband Interpretation = C.VIPS_INTERPRETATION_MULTIBAND - InterpretationBW Interpretation = C.VIPS_INTERPRETATION_B_W - InterpretationHistogram Interpretation = C.VIPS_INTERPRETATION_HISTOGRAM - InterpretationXYZ Interpretation = C.VIPS_INTERPRETATION_XYZ - InterpretationLAB Interpretation = C.VIPS_INTERPRETATION_LAB - InterpretationCMYK Interpretation = C.VIPS_INTERPRETATION_CMYK - InterpretationLABQ Interpretation = C.VIPS_INTERPRETATION_LABQ - InterpretationRGB Interpretation = C.VIPS_INTERPRETATION_RGB - InterpretationRGB16 Interpretation = C.VIPS_INTERPRETATION_RGB16 - InterpretationCMC Interpretation = C.VIPS_INTERPRETATION_CMC - InterpretationLCH Interpretation = C.VIPS_INTERPRETATION_LCH - InterpretationLABS Interpretation = C.VIPS_INTERPRETATION_LABS - InterpretationSRGB Interpretation = C.VIPS_INTERPRETATION_sRGB - InterpretationYXY Interpretation = C.VIPS_INTERPRETATION_YXY - InterpretationFourier Interpretation = C.VIPS_INTERPRETATION_FOURIER - InterpretationGrey16 Interpretation = C.VIPS_INTERPRETATION_GREY16 - InterpretationMatrix Interpretation = C.VIPS_INTERPRETATION_MATRIX - InterpretationScRGB Interpretation = C.VIPS_INTERPRETATION_scRGB - InterpretationHSV Interpretation = C.VIPS_INTERPRETATION_HSV -) - -// Intent represents VIPS_INTENT type -type Intent int - -// Intent enum -const ( - IntentPerceptual Intent = C.VIPS_INTENT_PERCEPTUAL - IntentRelative Intent = C.VIPS_INTENT_RELATIVE - IntentSaturation Intent = C.VIPS_INTENT_SATURATION - IntentAbsolute Intent = C.VIPS_INTENT_ABSOLUTE - IntentLast Intent = C.VIPS_INTENT_LAST -) - -func vipsIsColorSpaceSupported(in *C.VipsImage) bool { - return C.is_colorspace_supported(in) == 1 -} - -// https://libvips.github.io/libvips/API/current/libvips-colour.html#vips-colourspace -func vipsToColorSpace(in *C.VipsImage, interpretation Interpretation) (*C.VipsImage, error) { - incOpCounter("to_colorspace") - var out *C.VipsImage - - inter := C.VipsInterpretation(interpretation) - - if err := C.to_colorspace(in, &out, inter); err != 0 { - return nil, handleImageError(out) - } - - return out, nil -} - -func vipsICCTransform(in *C.VipsImage, outputProfile string, inputProfile string, intent Intent, depth int, - embedded bool) (*C.VipsImage, error) { - var out *C.VipsImage - var cInputProfile *C.char - var cEmbedded C.gboolean - - cOutputProfile := C.CString(outputProfile) - defer freeCString(cOutputProfile) - - if inputProfile != "" { - cInputProfile = C.CString(inputProfile) - defer freeCString(cInputProfile) - } - - if embedded { - cEmbedded = C.TRUE - } - - if res := C.icc_transform(in, &out, cOutputProfile, cInputProfile, C.VipsIntent(intent), C.int(depth), cEmbedded); res != 0 { - return nil, handleImageError(out) - } - - return out, nil -} - -// Composite - -// ImageComposite image to composite param -type ImageComposite struct { - Image *ImageRef - BlendMode BlendMode - X, Y int -} - -func toVipsCompositeStructs(r *ImageRef, datas []*ImageComposite) ([]*C.VipsImage, []C.int, []C.int, []C.int) { - ins := []*C.VipsImage{r.image} - modes := []C.int{} - xs := []C.int{} - ys := []C.int{} - - for _, image := range datas { - ins = append(ins, image.Image.image) - modes = append(modes, C.int(image.BlendMode)) - xs = append(xs, C.int(image.X)) - ys = append(ys, C.int(image.Y)) - } - - return ins, modes, xs, ys -} - -// Conversion - -// BandFormat represents VIPS_FORMAT type -type BandFormat int - -// BandFormat enum -const ( - BandFormatNotSet BandFormat = C.VIPS_FORMAT_NOTSET - BandFormatUchar BandFormat = C.VIPS_FORMAT_UCHAR - BandFormatChar BandFormat = C.VIPS_FORMAT_CHAR - BandFormatUshort BandFormat = C.VIPS_FORMAT_USHORT - BandFormatShort BandFormat = C.VIPS_FORMAT_SHORT - BandFormatUint BandFormat = C.VIPS_FORMAT_UINT - BandFormatInt BandFormat = C.VIPS_FORMAT_INT - BandFormatFloat BandFormat = C.VIPS_FORMAT_FLOAT - BandFormatComplex BandFormat = C.VIPS_FORMAT_COMPLEX - BandFormatDouble BandFormat = C.VIPS_FORMAT_DOUBLE - BandFormatDpComplex BandFormat = C.VIPS_FORMAT_DPCOMPLEX -) - -// BlendMode gives the various Porter-Duff and PDF blend modes. -// See https://libvips.github.io/libvips/API/current/libvips-conversion.html#VipsBlendMode -type BlendMode int - -// Constants define the various Porter-Duff and PDF blend modes. -// See https://libvips.github.io/libvips/API/current/libvips-conversion.html#VipsBlendMode -const ( - BlendModeClear BlendMode = C.VIPS_BLEND_MODE_CLEAR - BlendModeSource BlendMode = C.VIPS_BLEND_MODE_SOURCE - BlendModeOver BlendMode = C.VIPS_BLEND_MODE_OVER - BlendModeIn BlendMode = C.VIPS_BLEND_MODE_IN - BlendModeOut BlendMode = C.VIPS_BLEND_MODE_OUT - BlendModeAtop BlendMode = C.VIPS_BLEND_MODE_ATOP - BlendModeDest BlendMode = C.VIPS_BLEND_MODE_DEST - BlendModeDestOver BlendMode = C.VIPS_BLEND_MODE_DEST_OVER - BlendModeDestIn BlendMode = C.VIPS_BLEND_MODE_DEST_IN - BlendModeDestOut BlendMode = C.VIPS_BLEND_MODE_DEST_OUT - BlendModeDestAtop BlendMode = C.VIPS_BLEND_MODE_DEST_ATOP - BlendModeXOR BlendMode = C.VIPS_BLEND_MODE_XOR - BlendModeAdd BlendMode = C.VIPS_BLEND_MODE_ADD - BlendModeSaturate BlendMode = C.VIPS_BLEND_MODE_SATURATE - BlendModeMultiply BlendMode = C.VIPS_BLEND_MODE_MULTIPLY - BlendModeScreen BlendMode = C.VIPS_BLEND_MODE_SCREEN - BlendModeOverlay BlendMode = C.VIPS_BLEND_MODE_OVERLAY - BlendModeDarken BlendMode = C.VIPS_BLEND_MODE_DARKEN - BlendModeLighten BlendMode = C.VIPS_BLEND_MODE_LIGHTEN - BlendModeColorDodge BlendMode = C.VIPS_BLEND_MODE_COLOUR_DODGE - BlendModeColorBurn BlendMode = C.VIPS_BLEND_MODE_COLOUR_BURN - BlendModeHardLight BlendMode = C.VIPS_BLEND_MODE_HARD_LIGHT - BlendModeSoftLight BlendMode = C.VIPS_BLEND_MODE_SOFT_LIGHT - BlendModeDifference BlendMode = C.VIPS_BLEND_MODE_DIFFERENCE - BlendModeExclusion BlendMode = C.VIPS_BLEND_MODE_EXCLUSION -) - -// Gravity represents VIPS_GRAVITY type -type Gravity int - -// Gravity enum -const ( - GravityCentre Gravity = C.VIPS_COMPASS_DIRECTION_CENTRE - GravityNorth Gravity = C.VIPS_COMPASS_DIRECTION_NORTH - GravityEast Gravity = C.VIPS_COMPASS_DIRECTION_EAST - GravitySouth Gravity = C.VIPS_COMPASS_DIRECTION_SOUTH - GravityWest Gravity = C.VIPS_COMPASS_DIRECTION_WEST - GravityNorthEast Gravity = C.VIPS_COMPASS_DIRECTION_NORTH_EAST - GravityNorthWest Gravity = C.VIPS_COMPASS_DIRECTION_NORTH_WEST - GravitySouthEast Gravity = C.VIPS_COMPASS_DIRECTION_SOUTH_EAST - GravitySouthWest Gravity = C.VIPS_COMPASS_DIRECTION_SOUTH_WEST -) - -// Direction represents VIPS_DIRECTION type -type Direction int - -// Direction enum -const ( - DirectionHorizontal Direction = C.VIPS_DIRECTION_HORIZONTAL - DirectionVertical Direction = C.VIPS_DIRECTION_VERTICAL -) - -// Angle represents VIPS_ANGLE type -type Angle int - -// Angle enum -const ( - Angle0 Angle = C.VIPS_ANGLE_D0 - Angle90 Angle = C.VIPS_ANGLE_D90 - Angle180 Angle = C.VIPS_ANGLE_D180 - Angle270 Angle = C.VIPS_ANGLE_D270 -) - -// Angle45 represents VIPS_ANGLE45 type -type Angle45 int - -// Angle45 enum -const ( - Angle45_0 Angle45 = C.VIPS_ANGLE45_D0 - Angle45_45 Angle45 = C.VIPS_ANGLE45_D45 - Angle45_90 Angle45 = C.VIPS_ANGLE45_D90 - Angle45_135 Angle45 = C.VIPS_ANGLE45_D135 - Angle45_180 Angle45 = C.VIPS_ANGLE45_D180 - Angle45_225 Angle45 = C.VIPS_ANGLE45_D225 - Angle45_270 Angle45 = C.VIPS_ANGLE45_D270 - Angle45_315 Angle45 = C.VIPS_ANGLE45_D315 -) - -// ExtendStrategy represents VIPS_EXTEND type -type ExtendStrategy int - -// ExtendStrategy enum -const ( - ExtendBlack ExtendStrategy = C.VIPS_EXTEND_BLACK - ExtendCopy ExtendStrategy = C.VIPS_EXTEND_COPY - ExtendRepeat ExtendStrategy = C.VIPS_EXTEND_REPEAT - ExtendMirror ExtendStrategy = C.VIPS_EXTEND_MIRROR - ExtendWhite ExtendStrategy = C.VIPS_EXTEND_WHITE - ExtendBackground ExtendStrategy = C.VIPS_EXTEND_BACKGROUND -) - -// Interesting represents VIPS_INTERESTING type -// https://libvips.github.io/libvips/API/current/libvips-conversion.html#VipsInteresting -type Interesting int - -// Interesting constants represent areas of interest which smart cropping will crop based on. -const ( - InterestingNone Interesting = C.VIPS_INTERESTING_NONE - InterestingCentre Interesting = C.VIPS_INTERESTING_CENTRE - InterestingEntropy Interesting = C.VIPS_INTERESTING_ENTROPY - InterestingAttention Interesting = C.VIPS_INTERESTING_ATTENTION - InterestingLow Interesting = C.VIPS_INTERESTING_LOW - InterestingHigh Interesting = C.VIPS_INTERESTING_HIGH - InterestingAll Interesting = C.VIPS_INTERESTING_ALL - InterestingLast Interesting = C.VIPS_INTERESTING_LAST -) - -// https://libvips.github.io/libvips/API/current/libvips-conversion.html#vips-embed -func vipsEmbed(in *C.VipsImage, left, top, width, height int, extend ExtendStrategy) (*C.VipsImage, error) { - incOpCounter("embed") - var out *C.VipsImage - - if err := C.embed_image(in, &out, C.int(left), C.int(top), C.int(width), C.int(height), C.int(extend)); err != 0 { - return nil, handleImageError(out) - } - - return out, nil -} - -// https://libvips.github.io/libvips/API/current/libvips-conversion.html#vips-embed -func vipsEmbedBackground(in *C.VipsImage, left, top, width, height int, backgroundColor *ColorRGBA) (*C.VipsImage, error) { - incOpCounter("embed") - var out *C.VipsImage - - if err := C.embed_image_background(in, &out, C.int(left), C.int(top), C.int(width), - C.int(height), C.double(backgroundColor.R), - C.double(backgroundColor.G), C.double(backgroundColor.B), C.double(backgroundColor.A)); err != 0 { - return nil, handleImageError(out) - } - - return out, nil -} - -func vipsEmbedMultiPage(in *C.VipsImage, left, top, width, height int, extend ExtendStrategy) (*C.VipsImage, error) { - incOpCounter("embedMultiPage") - var out *C.VipsImage - - if err := C.embed_multi_page_image(in, &out, C.int(left), C.int(top), C.int(width), C.int(height), C.int(extend)); err != 0 { - return nil, handleImageError(out) - } - - return out, nil -} - -func vipsEmbedMultiPageBackground(in *C.VipsImage, left, top, width, height int, backgroundColor *ColorRGBA) (*C.VipsImage, error) { - incOpCounter("embedMultiPageBackground") - var out *C.VipsImage - - if err := C.embed_multi_page_image_background(in, &out, C.int(left), C.int(top), C.int(width), - C.int(height), C.double(backgroundColor.R), - C.double(backgroundColor.G), C.double(backgroundColor.B), C.double(backgroundColor.A)); err != 0 { - return nil, handleImageError(out) - } - - return out, nil -} - -// https://libvips.github.io/libvips/API/current/libvips-conversion.html#vips-flip -func vipsFlip(in *C.VipsImage, direction Direction) (*C.VipsImage, error) { - return vipsGenFlip(in, direction) -} - -// https://libvips.github.io/libvips/API/current/libvips-conversion.html#vips-extract-area -func vipsExtractArea(in *C.VipsImage, left, top, width, height int) (*C.VipsImage, error) { - return vipsGenExtractArea(in, left, top, width, height) -} - -func vipsExtractAreaMultiPage(in *C.VipsImage, left, top, width, height int) (*C.VipsImage, error) { - incOpCounter("extractAreaMultiPage") - - return vipsMapPages(in, func(page *C.VipsImage) (*C.VipsImage, error) { - return vipsGenExtractArea(page, left, top, width, height) - }) -} - -// vipsMapPages applies op to each loaded page of a multi-page image and -// restacks the results. Operations that act on the whole strip (flip, -// rot180, resize) would otherwise reorder or merge the frames. The page -// height of the result is taken from the first mapped page. -func vipsMapPages(in *C.VipsImage, op func(page *C.VipsImage) (*C.VipsImage, error)) (*C.VipsImage, error) { - pageHeight := vipsGetPageHeight(in) - nPages := int(in.Ysize) / pageHeight - if nPages < 1 { - nPages, pageHeight = 1, int(in.Ysize) - } - - pages := make([]*C.VipsImage, 0, nPages) - defer func() { - for _, p := range pages { - clearImage(p) - } - }() - for i := 0; i < nPages; i++ { - page, err := vipsGenExtractArea(in, 0, pageHeight*i, int(in.Xsize), pageHeight) - if err != nil { - return nil, err - } - mapped, err := op(page) - clearImage(page) - if err != nil { - return nil, err - } - pages = append(pages, mapped) - } - - across := 1 - joined, err := vipsGenArrayjoin(pages, &ArrayjoinOptions{Across: &across}) - if err != nil { - return nil, err - } - - out, err := vipsGenCopy(joined, nil) - clearImage(joined) - if err != nil { - return nil, err - } - - vipsSetPageHeight(out, int(pages[0].Ysize)) - return out, nil -} - -// http://libvips.github.io/libvips/API/current/libvips-resample.html#vips-similarity -func vipsSimilarity(in *C.VipsImage, scale float64, angle float64, color *ColorRGBA, - idx float64, idy float64, odx float64, ody float64) (*C.VipsImage, error) { - incOpCounter("similarity") - var out *C.VipsImage - - if err := C.similarity(in, &out, C.double(scale), C.double(angle), - C.double(color.R), C.double(color.G), C.double(color.B), C.double(color.A), - C.double(idx), C.double(idy), C.double(odx), C.double(ody)); err != 0 { - return nil, handleImageError(out) - } - - return out, nil -} - -// http://libvips.github.io/libvips/API/current/libvips-conversion.html#vips-smartcrop -func vipsSmartCrop(in *C.VipsImage, width int, height int, interesting Interesting) (*C.VipsImage, error) { - _, out, _, err := vipsGenSmartcrop(in, width, height, &SmartcropOptions{Interesting: &interesting}) - return out, err -} - -// http://libvips.github.io/libvips/API/current/libvips-conversion.html#vips-crop -func vipsCrop(in *C.VipsImage, left int, top int, width int, height int) (*C.VipsImage, error) { - incOpCounter("crop") - var out *C.VipsImage - - if err := C.crop(in, &out, C.int(left), C.int(top), C.int(width), C.int(height)); err != 0 { - return nil, handleImageError(out) - } - - return out, nil -} - -// https://libvips.github.io/libvips/API/current/libvips-conversion.html#vips-composite -func vipsComposite(ins []*C.VipsImage, modes []C.int, xs, ys []C.int) (*C.VipsImage, error) { - if len(ins) == 0 || len(modes) == 0 || len(xs) == 0 || len(ys) == 0 { - return nil, errors.New("vipsComposite: empty input slice") - } - incOpCounter("composite_multi") - var out *C.VipsImage - - if err := C.composite_image(&ins[0], &out, C.int(len(ins)), &modes[0], &xs[0], &ys[0]); err != 0 { - return nil, handleImageError(out) - } - - return out, nil -} - -// https://libvips.github.io/libvips/API/current/libvips-conversion.html#vips-join -func vipsJoin(input1 *C.VipsImage, input2 *C.VipsImage, dir Direction) (*C.VipsImage, error) { - incOpCounter("join") - var out *C.VipsImage - - // NOTE: do NOT unref input1/input2 here. They are borrowed from the - // caller's ImageRefs, which own those references and unref them in - // Close/finalize. vips_join takes its own refs on its inputs for the - // lifetime of the output. Unref'ing here drops refs we never owned, - // which double-frees the inputs once their ImageRefs are collected. - if err := C.join(input1, input2, &out, C.int(dir)); err != 0 { - return nil, handleVipsError() - } - return out, nil -} - -func vipsAddAlpha(in *C.VipsImage) (*C.VipsImage, error) { - incOpCounter("addalpha") - var out *C.VipsImage - - if err := C.add_alpha(in, &out); err != 0 { - return nil, handleImageError(out) - } - - return out, nil -} - -// Create - -type TextWrap int - -type TextParams struct { - Text string - Font string - Width int - Height int - Alignment Align - DPI int - RGBA bool - Justify bool - Spacing int - Wrap TextWrap -} - -type vipsTextOptions struct { - Text *C.char - Font *C.char - Width C.int - Height C.int - DPI C.int - RGBA C.gboolean - Justify C.gboolean - Spacing C.int - Alignment C.VipsAlign - Wrap C.VipsTextWrap -} - -// TextWrap enum -const ( - TextWrapWord TextWrap = C.VIPS_TEXT_WRAP_WORD - TextWrapChar TextWrap = C.VIPS_TEXT_WRAP_CHAR - TextWrapWordChar TextWrap = C.VIPS_TEXT_WRAP_WORD_CHAR - TextWrapNone TextWrap = C.VIPS_TEXT_WRAP_NONE -) - -// https://libvips.github.io/libvips/API/current/libvips-create.html#vips-text -func vipsText(params *TextParams) (*C.VipsImage, error) { - var out *C.VipsImage - - text := C.CString(params.Text) - defer freeCString(text) - - font := C.CString(params.Font) - defer freeCString(font) - - opts := vipsTextOptions{ - Text: text, - Font: font, - Width: C.int(params.Width), - Height: C.int(params.Height), - DPI: C.int(params.DPI), - Alignment: C.VipsAlign(params.Alignment), - Spacing: C.int(params.Spacing), - Wrap: C.VipsTextWrap(params.Wrap), - } - - if params.RGBA { - opts.RGBA = C.TRUE - } - - if params.Justify { - opts.Justify = C.TRUE - } - - err := C.text(&out, (*C.TextOptions)(unsafe.Pointer(&opts))) - if err != 0 { - return nil, handleImageError(out) - } - - return out, nil -} - -// Draw - -// https://libvips.github.io/libvips/API/current/libvips-draw.html#vips-draw-rect -func vipsDrawRect(in *C.VipsImage, color ColorRGBA, left int, top int, width int, height int, fill bool) error { - incOpCounter("draw_rect") - - fillBit := 0 - if fill { - fillBit = 1 - } - - if err := C.draw_rect(in, C.double(color.R), C.double(color.G), C.double(color.B), C.double(color.A), - C.int(left), C.int(top), C.int(width), C.int(height), C.int(fillBit)); err != 0 { - // draw_rect works in place: there's no output image to release, and - // the ref on in belongs to the caller's ImageRef. - return handleVipsError() - } - - return nil -} - -// Header - -func vipsHasICCProfile(in *C.VipsImage) bool { - return int(C.has_icc_profile(in)) != 0 -} - -func vipsGetICCProfile(in *C.VipsImage) ([]byte, bool) { - var bufPtr unsafe.Pointer - var dataLength C.size_t - - if int(C.get_icc_profile(in, &bufPtr, &dataLength)) != 0 { - return nil, false - } - - buf := C.GoBytes(bufPtr, C.int(dataLength)) - return buf, true -} - -func vipsRemoveICCProfile(in *C.VipsImage) bool { - return fromGboolean(C.remove_icc_profile(in)) -} - -func vipsHasIPTC(in *C.VipsImage) bool { - return int(C.has_iptc(in)) != 0 -} - -func vipsImageGetFields(in *C.VipsImage) (fields []string) { - const maxFields = 256 - - rawFields := C.image_get_fields(in) - defer C.g_strfreev(rawFields) - - cFields := (*[maxFields]*C.char)(unsafe.Pointer(rawFields))[:maxFields:maxFields] - - for _, field := range cFields { - if field == nil { - break - } - fields = append(fields, C.GoString(field)) - } - return -} - -func vipsImageGetExifData(in *C.VipsImage) map[string]string { - fields := vipsImageGetFields(in) - - exifData := map[string]string{} - for _, field := range fields { - if strings.HasPrefix(field, "exif") { - exifData[field] = vipsImageGetString(in, field) - } - } - - return exifData -} - -func vipsRemoveMetadata(in *C.VipsImage, keep ...string) { - fields := vipsImageGetFields(in) - - retain := append(keep, technicalMetadata...) - - for _, field := range fields { - if contains(retain, field) { - continue - } - - cField := C.CString(field) - - C.remove_field(in, cField) - - C.free(unsafe.Pointer(cField)) - } -} - -var technicalMetadata = []string{ - C.VIPS_META_ICC_NAME, - C.VIPS_META_ORIENTATION, - C.VIPS_META_N_PAGES, - C.VIPS_META_PAGE_HEIGHT, - "delay", - "loop", -} - -func contains(a []string, x string) bool { - for _, n := range a { - if x == n { - return true - } - } - return false -} - -func vipsGetMetaOrientation(in *C.VipsImage) int { - return int(C.get_meta_orientation(in)) -} - -func vipsRemoveMetaOrientation(in *C.VipsImage) { - C.remove_meta_orientation(in) -} - -func vipsSetMetaOrientation(in *C.VipsImage, orientation int) { - C.set_meta_orientation(in, C.int(orientation)) -} - -func vipsGetImageNPages(in *C.VipsImage) int { - return int(C.get_image_n_pages(in)) -} - -func vipsSetImageNPages(in *C.VipsImage, pages int) { - C.set_image_n_pages(in, C.int(pages)) -} - -func vipsGetPageHeight(in *C.VipsImage) int { - return int(C.get_page_height(in)) -} - -func vipsSetPageHeight(in *C.VipsImage, height int) { - C.set_page_height(in, C.int(height)) -} - -func vipsImageGetMetaLoader(in *C.VipsImage) (string, bool) { - var out *C.char - code := int(C.get_meta_loader(in, &out)) - return C.GoString(out), code == 0 -} - -func vipsImageGetDelay(in *C.VipsImage, n int) ([]int, error) { - incOpCounter("imageGetDelay") - var out *C.int - - if err := C.get_image_delay(in, &out); err != 0 { - return nil, handleVipsError() - } - return fromCArrayInt(out, n), nil -} - -func vipsImageSetDelay(in *C.VipsImage, data []C.int) error { - incOpCounter("imageSetDelay") - if n := len(data); n > 0 { - C.set_image_delay(in, &data[0], C.int(n)) - } - return nil -} - -func vipsImageGetLoop(in *C.VipsImage) int { - return int(C.get_image_loop(in)) -} - -func vipsImageSetLoop(in *C.VipsImage, loop int) { - C.set_image_loop(in, C.int(loop)) -} - -func vipsImageGetBackground(in *C.VipsImage) ([]float64, error) { - incOpCounter("imageGetBackground") - var out *C.double - var n C.int - - if err := C.get_background(in, &out, &n); err != 0 { - return nil, handleVipsError() - } - return fromCArrayDouble(out, int(n)), nil -} - -// vipsDetermineImageTypeFromMetaLoader determine the image type from vips-loader metadata -func vipsDetermineImageTypeFromMetaLoader(in *C.VipsImage) ImageType { - vipsLoader, ok := vipsImageGetMetaLoader(in) - if vipsLoader == "" || !ok { - return ImageTypeUnknown - } - if strings.HasPrefix(vipsLoader, "jpeg") { - return ImageTypeJPEG - } - if strings.HasPrefix(vipsLoader, "png") { - return ImageTypePNG - } - if strings.HasPrefix(vipsLoader, "gif") { - return ImageTypeGIF - } - if strings.HasPrefix(vipsLoader, "svg") { - return ImageTypeSVG - } - if strings.HasPrefix(vipsLoader, "webp") { - return ImageTypeWEBP - } - if strings.HasPrefix(vipsLoader, "jp2k") { - return ImageTypeJP2K - } - if strings.HasPrefix(vipsLoader, "jxl") { - return ImageTypeJXL - } - if strings.HasPrefix(vipsLoader, "magick") { - return ImageTypeMagick - } - if strings.HasPrefix(vipsLoader, "tiff") { - return ImageTypeTIFF - } - if strings.HasPrefix(vipsLoader, "heif") { - return ImageTypeHEIF - } - if strings.HasPrefix(vipsLoader, "pdf") { - return ImageTypePDF - } - return ImageTypeUnknown -} - -func vipsImageSetBlob(in *C.VipsImage, name string, data []byte) { - if len(data) == 0 { - return - } - - cField := C.CString(name) - defer freeCString(cField) - C.image_set_blob(in, cField, unsafe.Pointer(&data[0]), C.size_t(len(data))) -} - -func vipsImageGetBlob(in *C.VipsImage, name string) []byte { - var bufPtr unsafe.Pointer - var dataLength C.size_t - - cField := C.CString(name) - defer freeCString(cField) - if int(C.image_get_blob(in, cField, &bufPtr, &dataLength)) != 0 { - return nil - } - - buf := C.GoBytes(bufPtr, C.int(dataLength)) - return buf -} - -func vipsImageSetDouble(in *C.VipsImage, name string, f float64) { - cField := C.CString(name) - defer freeCString(cField) - - cDouble := C.double(f) - C.image_set_double(in, cField, cDouble) -} - -func vipsImageGetDouble(in *C.VipsImage, name string) float64 { - cField := C.CString(name) - defer freeCString(cField) - - var cDouble C.double - if int(C.image_get_double(in, cField, &cDouble)) == 0 { - return float64(cDouble) - } - - return 0 -} - -func vipsImageSetInt(in *C.VipsImage, name string, i int) { - cField := C.CString(name) - defer freeCString(cField) - - cInt := C.int(i) - C.image_set_int(in, cField, cInt) -} - -func vipsImageGetInt(in *C.VipsImage, name string) int { - cField := C.CString(name) - defer freeCString(cField) - - var cInt C.int - if int(C.image_get_int(in, cField, &cInt)) == 0 { - return int(cInt) - } - - return 0 -} - -func vipsImageSetString(in *C.VipsImage, name string, str string) { - cField := C.CString(name) - defer freeCString(cField) - - cStr := C.CString(str) - defer freeCString(cStr) - - C.image_set_string(in, cField, cStr) -} - -func vipsImageGetString(in *C.VipsImage, name string) string { - cField := C.CString(name) - defer freeCString(cField) - var cFieldValue *C.char - if int(C.image_get_string(in, cField, &cFieldValue)) == 0 { - return C.GoString(cFieldValue) - } - - return "" -} - -func vipsImageGetAsString(in *C.VipsImage, name string) string { - cField := C.CString(name) - defer freeCString(cField) - var cFieldValue *C.char - defer func() { freeCString(cFieldValue) }() - if int(C.image_get_as_string(in, cField, &cFieldValue)) == 0 { - return C.GoString(cFieldValue) - } - - return "" -} - -// Label - -// Align represents VIPS_ALIGN -type Align int - -// Direction enum -const ( - AlignLow Align = C.VIPS_ALIGN_LOW - AlignCenter Align = C.VIPS_ALIGN_CENTRE - AlignHigh Align = C.VIPS_ALIGN_HIGH -) - -// DefaultFont is the default font to be used for label texts created by govips -const DefaultFont = "sans 10" - -// LabelParams represents a text-based label -type LabelParams struct { - Text string - Font string - Width Scalar - Height Scalar - OffsetX Scalar - OffsetY Scalar - Opacity float32 - Color Color - Alignment Align -} - -type vipsLabelOptions struct { - Text *C.char - Font *C.char - Width C.int - Height C.int - OffsetX C.int - OffsetY C.int - Alignment C.VipsAlign - DPI C.int - Margin C.int - Opacity C.float - Color [3]C.double -} - -func labelImage(in *C.VipsImage, params *LabelParams) (*C.VipsImage, error) { - incOpCounter("label") - var out *C.VipsImage - - text := C.CString(params.Text) - defer freeCString(text) - - font := C.CString(params.Font) - defer freeCString(font) - - // todo: release color? - color := [3]C.double{C.double(params.Color.R), C.double(params.Color.G), C.double(params.Color.B)} - - w := params.Width.GetRounded(int(in.Xsize)) - h := params.Height.GetRounded(int(in.Ysize)) - offsetX := params.OffsetX.GetRounded(int(in.Xsize)) - offsetY := params.OffsetY.GetRounded(int(in.Ysize)) - - opts := vipsLabelOptions{ - Text: text, - Font: font, - Width: C.int(w), - Height: C.int(h), - OffsetX: C.int(offsetX), - OffsetY: C.int(offsetY), - Alignment: C.VipsAlign(params.Alignment), - Opacity: C.float(params.Opacity), - Color: color, - } - - // todo: release inline pointer? - err := C.label(in, &out, (*C.LabelOptions)(unsafe.Pointer(&opts))) - if err != 0 { - return nil, handleImageError(out) - } - - return out, nil -} - -// Resample - -// Kernel represents VipsKernel type -type Kernel int - -// Kernel enum -const ( - KernelAuto Kernel = -1 - KernelNearest Kernel = C.VIPS_KERNEL_NEAREST - KernelLinear Kernel = C.VIPS_KERNEL_LINEAR - KernelCubic Kernel = C.VIPS_KERNEL_CUBIC - KernelLanczos2 Kernel = C.VIPS_KERNEL_LANCZOS2 - KernelLanczos3 Kernel = C.VIPS_KERNEL_LANCZOS3 - KernelMitchell Kernel = C.VIPS_KERNEL_MITCHELL -) - -// Size represents VipsSize type -type Size int - -const ( - SizeBoth Size = C.VIPS_SIZE_BOTH - SizeUp Size = C.VIPS_SIZE_UP - SizeDown Size = C.VIPS_SIZE_DOWN - SizeForce Size = C.VIPS_SIZE_FORCE - SizeLast Size = C.VIPS_SIZE_LAST -) - -// https://libvips.github.io/libvips/API/current/libvips-resample.html#vips-resize -func vipsResizeWithVScale(in *C.VipsImage, hscale, vscale float64, kernel Kernel) (*C.VipsImage, error) { - incOpCounter("resize") - var out *C.VipsImage - - // libvips recommends Lanczos3 as the default kernel - if kernel == KernelAuto { - kernel = KernelLanczos3 - } - - if err := C.resize_image(in, &out, C.double(hscale), C.double(vscale), C.int(kernel)); err != 0 { - return nil, handleImageError(out) - } - - return out, nil -} - -func vipsThumbnail(in *C.VipsImage, width, height int, crop Interesting, size Size) (*C.VipsImage, error) { - incOpCounter("thumbnail") - var out *C.VipsImage - - if err := C.thumbnail_image(in, &out, C.int(width), C.int(height), C.int(crop), C.int(size)); err != 0 { - return nil, handleImageError(out) - } - - return out, nil -} - -// https://www.libvips.org/API/current/libvips-resample.html#vips-thumbnail -func vipsThumbnailFromFile(filename string, width, height int, crop Interesting, size Size, params *ImportParams) (*C.VipsImage, ImageType, error) { - var out *C.VipsImage - - filenameOption := filename - if params != nil { - filenameOption += "[" + params.OptionString() + "]" - } - - cFileName := C.CString(filenameOption) - defer freeCString(cFileName) - - if err := C.thumbnail(cFileName, &out, C.int(width), C.int(height), C.int(crop), C.int(size)); err != 0 { - err := handleImageError(out) - if src, err2 := os.ReadFile(filename); err2 == nil { - return vipsThumbnailFromBuffer(src, width, height, crop, size, params) - } - return nil, ImageTypeUnknown, err - } - - imageType := vipsDetermineImageTypeFromMetaLoader(out) - return out, imageType, nil -} - -// https://www.libvips.org/API/current/libvips-resample.html#vips-thumbnail-buffer -func vipsThumbnailFromBuffer(buf []byte, width, height int, crop Interesting, size Size, params *ImportParams) (*C.VipsImage, ImageType, error) { - src := buf - // Reference src here so it's not garbage collected during image initialization. - defer runtime.KeepAlive(src) - - var out *C.VipsImage - - var err C.int - - if params == nil { - err = C.thumbnail_buffer(unsafe.Pointer(&src[0]), C.size_t(len(src)), &out, C.int(width), C.int(height), C.int(crop), C.int(size)) - } else { - cOptionString := C.CString(params.OptionString()) - defer freeCString(cOptionString) - - err = C.thumbnail_buffer_with_option(unsafe.Pointer(&src[0]), C.size_t(len(src)), &out, C.int(width), C.int(height), C.int(crop), C.int(size), cOptionString) - } - if err != 0 { - err := handleImageError(out) - return nil, ImageTypeUnknown, err - } - - imageType := vipsDetermineImageTypeFromMetaLoader(out) - return out, imageType, nil -} diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/operations.h b/vendor/github.com/davidbyttow/govips/v2/vips/operations.h deleted file mode 100644 index e2fe167d9b..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/operations.h +++ /dev/null @@ -1,149 +0,0 @@ -// operations.h - Hand-written C bridge functions for libvips operations - -#ifndef OPERATIONS_H -#define OPERATIONS_H - -#include -#include -#include - -// Arithmetic -// https://libvips.github.io/libvips/API/current/libvips-arithmetic.html - -int find_trim(VipsImage *in, int *left, int *top, int *width, int *height, - double threshold, double r, double g, double b); -int getpoint(VipsImage *in, double **vector, int n, int x, int y); -int minOp(VipsImage *in, double *out, int *x, int *y, int size); - -// Color -// https://libvips.github.io/libvips/API/current/libvips-colour.html - -int is_colorspace_supported(VipsImage *in); -int to_colorspace(VipsImage *in, VipsImage **out, VipsInterpretation space); -int icc_transform(VipsImage *in, VipsImage **out, const char *output_profile, - const char *input_profile, VipsIntent intent, int depth, - gboolean embedded); - -// Conversion -// https://libvips.github.io/libvips/API/current/libvips-conversion.html - -int embed_image(VipsImage *in, VipsImage **out, int left, int top, int width, - int height, int extend); -int embed_image_background(VipsImage *in, VipsImage **out, int left, int top, - int width, int height, double r, double g, double b, double a); -int embed_multi_page_image(VipsImage *in, VipsImage **out, int left, int top, - int width, int height, int extend); -int embed_multi_page_image_background(VipsImage *in, VipsImage **out, int left, - int top, int width, int height, double r, double g, double b, - double a); -int crop(VipsImage *in, VipsImage **out, int left, int top, int width, - int height); -int similarity(VipsImage *in, VipsImage **out, double scale, double angle, - double r, double g, double b, double a, double idx, double idy, - double odx, double ody); -int composite_image(VipsImage **in, VipsImage **out, int n, int *mode, int *x, - int *y); -int join(VipsImage *in1, VipsImage *in2, VipsImage **out, int direction); -int add_alpha(VipsImage *in, VipsImage **out); - -// Create -// https://libvips.github.io/libvips/API/current/libvips-create.html - -typedef struct { - const char *Text; - const char *Font; - int Width; - int Height; - int DPI; - gboolean RGBA; - gboolean Justify; - int Spacing; - VipsAlign Align; - VipsTextWrap Wrap; -} TextOptions; - -int text(VipsImage **out, TextOptions *o); - -// Draw -// https://libvips.github.io/libvips/API/current/libvips-draw.html - -int draw_rect(VipsImage *in, double r, double g, double b, double a, int left, - int top, int width, int height, int fill); - -// Header -// https://libvips.github.io/libvips/API/current/libvips-header.html - -unsigned long has_icc_profile(VipsImage *in); -unsigned long get_icc_profile(VipsImage *in, const void **data, - size_t *dataLength); -int remove_icc_profile(VipsImage *in); - -unsigned long has_iptc(VipsImage *in); -char **image_get_fields(VipsImage *in); - -void image_set_string(VipsImage *in, const char *name, const char *str); -unsigned long image_get_string(VipsImage *in, const char *name, - const char **out); -unsigned long image_get_as_string(VipsImage *in, const char *name, char **out); - -void remove_field(VipsImage *in, char *field); - -int get_meta_orientation(VipsImage *in); -void remove_meta_orientation(VipsImage *in); -void set_meta_orientation(VipsImage *in, int orientation); -int get_image_n_pages(VipsImage *in); -void set_image_n_pages(VipsImage *in, int n_pages); -int get_page_height(VipsImage *in); -void set_page_height(VipsImage *in, int height); -int get_meta_loader(const VipsImage *in, const char **out); -int get_image_delay(VipsImage *in, int **out); -void set_image_delay(VipsImage *in, const int *array, int n); -int get_image_loop(VipsImage *in); -void set_image_loop(VipsImage *in, int loop); -int get_background(VipsImage *in, double **out, int *n); - -void image_set_blob(VipsImage *in, const char *name, const void *data, - size_t dataLength); -unsigned long image_get_blob(VipsImage *in, const char *name, const void **data, - size_t *dataLength); - -void image_set_double(VipsImage *in, const char *name, double i); -unsigned long image_get_double(VipsImage *in, const char *name, double *out); - -void image_set_int(VipsImage *in, const char *name, int i); -unsigned long image_get_int(VipsImage *in, const char *name, int *out); - -// Label - -typedef struct { - const char *Text; - const char *Font; - int Width; - int Height; - int OffsetX; - int OffsetY; - VipsAlign Align; - int DPI; - int Margin; - float Opacity; - double Color[3]; -} LabelOptions; - -int label(VipsImage *in, VipsImage **out, LabelOptions *o); - -// Resample -// https://libvips.github.io/libvips/API/current/libvips-resample.html - -int resize_image(VipsImage *in, VipsImage **out, double scale, gdouble vscale, - int kernel); -int thumbnail(const char *filename, VipsImage **out, int width, int height, - int crop, int size); -int thumbnail_image(VipsImage *in, VipsImage **out, int width, int height, - int crop, int size); -int thumbnail_buffer(void *buf, size_t len, VipsImage **out, int width, - int height, int crop, int size); -int thumbnail_buffer_with_option(void *buf, size_t len, VipsImage **out, - int width, int height, int crop, int size, - const char *option_string); - -#endif // OPERATIONS_H diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/stats.go b/vendor/github.com/davidbyttow/govips/v2/vips/stats.go deleted file mode 100644 index d3208c75cf..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/stats.go +++ /dev/null @@ -1,56 +0,0 @@ -package vips - -import "sync" - -// RuntimeStats is a data structure to house a map of govips operation counts -type RuntimeStats struct { - OperationCounts map[string]int64 -} - -var ( - operationCounter chan string - runtimeStats *RuntimeStats - statLock sync.RWMutex -) - -func incOpCounter(op string) { - if operationCounter != nil { - operationCounter <- op - } -} - -func collectStats() chan struct{} { - operationCounter = make(chan string, 100) - done := make(chan struct{}) - exit := false - go func() { - for !exit { - select { - case op := <-operationCounter: - statLock.Lock() - runtimeStats.OperationCounts[op] = runtimeStats.OperationCounts[op] + 1 - statLock.Unlock() - case <-done: - exit = true - break - } - } - }() - return done -} - -// ReadRuntimeStats returns operation counts for govips -func ReadRuntimeStats(stats *RuntimeStats) { - statLock.RLock() - defer statLock.RUnlock() - stats.OperationCounts = make(map[string]int64) - for k, v := range runtimeStats.OperationCounts { - stats.OperationCounts[k] = v - } -} - -func init() { - runtimeStats = &RuntimeStats{ - OperationCounts: make(map[string]int64), - } -} diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/stream.c b/vendor/github.com/davidbyttow/govips/v2/vips/stream.c deleted file mode 100644 index 66fc9b5950..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/stream.c +++ /dev/null @@ -1,316 +0,0 @@ -#include "stream.h" - -#include - -// Option setters shared with the buffer path, defined in foreign.c. -// Reusing them keeps streaming output identical to the buffer output. -extern int set_jpegload_options(VipsOperation *operation, LoadParams *params); -extern int set_pngload_options(VipsOperation *operation, LoadParams *params); -extern int set_webpload_options(VipsOperation *operation, LoadParams *params); -extern int set_tiffload_options(VipsOperation *operation, LoadParams *params); -extern int set_gifload_options(VipsOperation *operation, LoadParams *params); -extern int set_heifload_options(VipsOperation *operation, LoadParams *params); -extern int set_svgload_options(VipsOperation *operation, LoadParams *params); -extern int set_pdfload_options(VipsOperation *operation, LoadParams *params); -extern int set_jp2kload_options(VipsOperation *operation, LoadParams *params); -extern int set_jxlload_options(VipsOperation *operation, LoadParams *params); -extern int set_magickload_options(VipsOperation *operation, LoadParams *params); - -extern int set_jpegsave_options(VipsOperation *operation, SaveParams *params); -extern int set_pngsave_options(VipsOperation *operation, SaveParams *params); -extern int set_webpsave_options(VipsOperation *operation, SaveParams *params); -extern int set_heifsave_options(VipsOperation *operation, SaveParams *params); -extern int set_tiffsave_options(VipsOperation *operation, SaveParams *params); -extern int set_gifsave_options(VipsOperation *operation, SaveParams *params); - -// Trampolines: extract the registry handle from signal user_data and -// forward to the exported Go callbacks. Buffers are owned by libvips and -// only valid for the duration of the call. - -static gint64 source_read_handler(VipsSourceCustom *source, void *buffer, - gint64 length, void *user_data) { - (void)source; - return goSourceReadCb(GPOINTER_TO_INT(user_data), buffer, length); -} - -static gint64 source_seek_handler(VipsSourceCustom *source, gint64 offset, - int whence, void *user_data) { - (void)source; - return goSourceSeekCb(GPOINTER_TO_INT(user_data), offset, whence); -} - -static gint64 target_write_handler(VipsTargetCustom *target, const void *data, - gint64 length, void *user_data) { - (void)target; - return goTargetWriteCb(GPOINTER_TO_INT(user_data), (void *)data, length); -} - -static int target_end_handler(VipsTargetCustom *target, void *user_data) { - (void)target; - return goTargetEndCb(GPOINTER_TO_INT(user_data)); -} - -VipsSourceCustom *create_source_custom(int handle, int has_seek) { - VipsSourceCustom *source = vips_source_custom_new(); - if (!source) { - return NULL; - } - - g_signal_connect(source, "read", G_CALLBACK(source_read_handler), - GINT_TO_POINTER(handle)); - if (has_seek) { - g_signal_connect(source, "seek", G_CALLBACK(source_seek_handler), - GINT_TO_POINTER(handle)); - } - - return source; -} - -VipsTargetCustom *create_target_custom(int handle) { - VipsTargetCustom *target = vips_target_custom_new(); - if (!target) { - return NULL; - } - - g_signal_connect(target, "write", G_CALLBACK(target_write_handler), - GINT_TO_POINTER(handle)); - g_signal_connect(target, "end", G_CALLBACK(target_end_handler), - GINT_TO_POINTER(handle)); - - return target; -} - -int source_sniff_header(VipsSourceCustom *source, unsigned char *out, int len) { - const unsigned char *p = vips_source_sniff(VIPS_SOURCE(source), (size_t) len); - if (!p) { - return -1; - } - memcpy(out, p, (size_t) len); - return 0; -} - -static ImageType image_type_for_loader(const char *name) { - if (g_str_has_prefix(name, "jpegload")) return JPEG; - if (g_str_has_prefix(name, "pngload")) return PNG; - if (g_str_has_prefix(name, "webpload")) return WEBP; - if (g_str_has_prefix(name, "tiffload")) return TIFF; - if (g_str_has_prefix(name, "gifload")) return GIF; - if (g_str_has_prefix(name, "heifload")) return HEIF; - if (g_str_has_prefix(name, "svgload")) return SVG; - if (g_str_has_prefix(name, "pdfload")) return PDF; - if (g_str_has_prefix(name, "jp2kload")) return JP2K; - if (g_str_has_prefix(name, "jxlload")) return JXL; - if (g_str_has_prefix(name, "magickload")) return MAGICK; - return UNKNOWN; -} - -typedef int (*SetLoadOptionsFn)(VipsOperation *operation, LoadParams *params); - -static int set_noload_options(VipsOperation *operation, LoadParams *params) { - (void)operation; - (void)params; - return 0; -} - -static SetLoadOptionsFn load_options_for_type(ImageType imageType) { - switch (imageType) { - case JPEG: - return set_jpegload_options; - case PNG: - return set_pngload_options; - case WEBP: - return set_webpload_options; - case TIFF: - return set_tiffload_options; - case GIF: - return set_gifload_options; - case HEIF: - return set_heifload_options; - case SVG: - return set_svgload_options; - case PDF: - return set_pdfload_options; - case JP2K: - return set_jp2kload_options; - case JXL: - return set_jxlload_options; - case MAGICK: - return set_magickload_options; - default: - return set_noload_options; - } -} - -int load_from_source(VipsSourceCustom *source, LoadParams *params) { - // Sniffs the stream start to find a loader. This returns the GType - // class name (e.g. "VipsForeignLoadJpegSource"); resolve it to the - // operation nickname (e.g. "jpegload_source") for format mapping. - const char *className = vips_foreign_find_load_source(VIPS_SOURCE(source)); - if (!className) { - return 1; - } - const char *operationName = vips_nickname_find(g_type_from_name(className)); - if (!operationName) { - return 1; - } - - params->inputFormat = image_type_for_loader(operationName); - SetLoadOptionsFn setLoadOptions = load_options_for_type(params->inputFormat); - - VipsOperation *operation = vips_operation_new(operationName); - if (!operation) { - return 1; - } - - if (vips_object_set(VIPS_OBJECT(operation), "source", source, NULL)) { - g_object_unref(operation); - return 1; - } - - if (setLoadOptions(operation, params)) { - g_object_unref(operation); - return 1; - } - - // The deprecated "fail" bool does not make every loader reject - // truncated input (e.g. spng pads missing rows with only a warning). - // Streaming inputs are network-shaped, so when the caller asked for - // fail-on-error escalate to the modern fail_on property at the - // "truncated" level: truncated streams fail, ordinary warnings on - // valid images do not. - if (params->fail.is_set && params->fail.value.b && - g_object_class_find_property(G_OBJECT_GET_CLASS(operation), - "fail_on")) { - vips_object_set(VIPS_OBJECT(operation), "fail_on", - VIPS_FAIL_ON_TRUNCATED, NULL); - } - - // Build uncached: the cache key includes the unique source object, so - // a hit is impossible — caching would only pin the source and the - // lazy image in the operation cache past their natural lifetime. - if (vips_object_build(VIPS_OBJECT(operation))) { - vips_object_unref_outputs(VIPS_OBJECT(operation)); - g_object_unref(operation); - return 1; - } - - g_object_get(VIPS_OBJECT(operation), "out", ¶ms->outputImage, NULL); - - vips_object_unref_outputs(VIPS_OBJECT(operation)); - g_object_unref(operation); - - // The returned image is LAZY: libvips decodes on demand, pulling from - // the source during later operations. The Go side decides whether to - // materialize it now (memory or scratch disc, releasing the source - // early) or keep the source connected for sequential streaming. - return 0; -} - -gint64 image_decoded_size(VipsImage *in) { - return (gint64)VIPS_IMAGE_SIZEOF_PEL(in) * in->Xsize * in->Ysize; -} - -int copy_image_to_memory(VipsImage *in, VipsImage **out) { - VipsImage *memory = vips_image_copy_memory(in); - if (!memory) { - return 1; - } - *out = memory; - return 0; -} - -int write_image_to_disc(VipsImage *in, const char *path, VipsImage **out) { - // Render the full image to a vips-native (.v) scratch file in one - // sequential pass, then reopen it as a random-access image backed by - // the file. Decode/reader errors surface here, during the write pass. - if (vips_image_write_to_file(in, path, NULL)) { - return 1; - } - - VipsImage *disc = - vips_image_new_from_file(path, "access", VIPS_ACCESS_RANDOM, NULL); - if (!disc) { - return 1; - } - *out = disc; - return 0; -} - -typedef int (*SetSaveOptionsFn)(VipsOperation *operation, SaveParams *params); - -static int save_target(const char *operationName, SaveParams *params, - VipsTargetCustom *target, - SetSaveOptionsFn setSaveOptions) { - VipsOperation *operation = vips_operation_new(operationName); - if (!operation) { - return 1; - } - - if (vips_object_set(VIPS_OBJECT(operation), "in", params->inputImage, - "target", target, NULL)) { - g_object_unref(operation); - return 1; - } - - if (setSaveOptions(operation, params)) { - g_object_unref(operation); - return 1; - } - - // Same as save_buffer: "keep" overrides the deprecated "strip". - if (params->keepSet && - vips_object_set(VIPS_OBJECT(operation), "keep", params->keep, NULL)) { - g_object_unref(operation); - return 1; - } - - // Build uncached, mirroring load_from_source: the unique target - // object makes cache hits impossible. - if (vips_object_build(VIPS_OBJECT(operation))) { - vips_object_unref_outputs(VIPS_OBJECT(operation)); - g_object_unref(operation); - return 1; - } - - vips_object_unref_outputs(VIPS_OBJECT(operation)); - g_object_unref(operation); - - return 0; -} - -int save_jpeg_to_target(SaveParams *params, VipsTargetCustom *target) { - return save_target("jpegsave_target", params, target, set_jpegsave_options); -} - -int save_png_to_target(SaveParams *params, VipsTargetCustom *target) { - return save_target("pngsave_target", params, target, set_pngsave_options); -} - -int save_webp_to_target(SaveParams *params, VipsTargetCustom *target) { - return save_target("webpsave_target", params, target, set_webpsave_options); -} - -int save_heif_to_target(SaveParams *params, VipsTargetCustom *target) { - return save_target("heifsave_target", params, target, set_heifsave_options); -} - -// No save_tiff_to_target: libtiff requires seekable output, so the Go -// side always encodes TIFF through the buffer path. - -int save_gif_to_target(SaveParams *params, VipsTargetCustom *target) { - return save_target("gifsave_target", params, target, set_gifsave_options); -} - -void clear_source(VipsSourceCustom **source) { - if (source && *source) { - g_object_unref(*source); - *source = NULL; - } -} - -void clear_target(VipsTargetCustom **target) { - if (target && *target) { - g_object_unref(*target); - *target = NULL; - } -} diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/stream.go b/vendor/github.com/davidbyttow/govips/v2/vips/stream.go deleted file mode 100644 index f23d9a1889..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/stream.go +++ /dev/null @@ -1,842 +0,0 @@ -package vips - -// Streaming I/O via VipsSourceCustom/VipsTargetCustom. -// -// libvips worker threads pull/push bytes through C trampolines (stream.c) -// that dispatch to the exported Go callbacks below via integer handles in -// a global registry. Holding a registry reference also keeps the Go -// reader/writer alive while the C side may still call back into it. - -// #include "stream.h" -import "C" - -import ( - "errors" - "fmt" - "io" - "math" - "os" - "runtime" - "strconv" - "strings" - "sync" - "unsafe" -) - -// sourceEntry is the registry entry for one streaming load. The mutex -// serializes callback invocations so callers never need thread-safe -// readers, even though libvips may call from multiple worker threads. -type sourceEntry struct { - reader io.Reader - seeker io.Seeker // non-nil only when reader implements io.Seeker - mu sync.Mutex - lastErr error - - // size is the lazily resolved length of the seekable source, - // cached for clamping past-EOF seek targets. Guarded by mu. - size int64 - sizeKnown bool -} - -// sourceSizeLocked resolves and caches the source length without -// disturbing the current position. The entry mutex must be held. -func (e *sourceEntry) sourceSizeLocked() (int64, error) { - if e.sizeKnown { - return e.size, nil - } - cur, err := e.seeker.Seek(0, io.SeekCurrent) - if err != nil { - return 0, err - } - size, err := e.seeker.Seek(0, io.SeekEnd) - if err != nil { - return 0, err - } - if _, err := e.seeker.Seek(cur, io.SeekStart); err != nil { - return 0, err - } - e.size, e.sizeKnown = size, true - return size, nil -} - -// targetEntry is the registry entry for one streaming save. -type targetEntry struct { - writer io.Writer - mu sync.Mutex - lastErr error -} - -func (e *sourceEntry) takeErr() error { - e.mu.Lock() - defer e.mu.Unlock() - err := e.lastErr - e.lastErr = nil - return err -} - -func (e *targetEntry) takeErr() error { - e.mu.Lock() - defer e.mu.Unlock() - err := e.lastErr - e.lastErr = nil - return err -} - -// streamCallbacks maps integer handles to active source/target entries. -// The registry mutex only guards the maps; per-entry mutexes guard the -// actual I/O so the global lock is never held during a Read/Write. -var streamCallbacks = struct { - sync.Mutex - sources map[int]*sourceEntry - targets map[int]*targetEntry - nextHandle int -}{ - sources: make(map[int]*sourceEntry), - targets: make(map[int]*targetEntry), -} - -// allocStreamHandle returns the next free handle. Handles cross the CGo -// boundary as C int (via GLib's GINT_TO_POINTER), so they must stay -// within int32 range: wrap instead of overflowing, and skip any handle -// that is still registered after a wrap. The caller must hold the -// streamCallbacks lock. -func allocStreamHandle() int { - for { - streamCallbacks.nextHandle++ - if streamCallbacks.nextHandle > math.MaxInt32 { - streamCallbacks.nextHandle = 1 - } - h := streamCallbacks.nextHandle - if _, live := streamCallbacks.sources[h]; live { - continue - } - if _, live := streamCallbacks.targets[h]; live { - continue - } - return h - } -} - -func registerSource(r io.Reader) (int, *sourceEntry) { - entry := &sourceEntry{reader: r} - if s, ok := r.(io.Seeker); ok { - entry.seeker = s - } - - streamCallbacks.Lock() - defer streamCallbacks.Unlock() - handle := allocStreamHandle() - streamCallbacks.sources[handle] = entry - return handle, entry -} - -func deregisterSource(handle int) { - streamCallbacks.Lock() - defer streamCallbacks.Unlock() - delete(streamCallbacks.sources, handle) -} - -func lookupSource(handle int) *sourceEntry { - streamCallbacks.Lock() - defer streamCallbacks.Unlock() - return streamCallbacks.sources[handle] -} - -func registerTarget(w io.Writer) (int, *targetEntry) { - entry := &targetEntry{writer: w} - - streamCallbacks.Lock() - defer streamCallbacks.Unlock() - handle := allocStreamHandle() - streamCallbacks.targets[handle] = entry - return handle, entry -} - -func deregisterTarget(handle int) { - streamCallbacks.Lock() - defer streamCallbacks.Unlock() - delete(streamCallbacks.targets, handle) -} - -func lookupTarget(handle int) *targetEntry { - streamCallbacks.Lock() - defer streamCallbacks.Unlock() - return streamCallbacks.targets[handle] -} - -//export goSourceReadCb -func goSourceReadCb(handle C.int, buffer unsafe.Pointer, length C.gint64) C.gint64 { - if length <= 0 { - return 0 - } - buf := unsafe.Slice((*byte)(buffer), int(length)) - return C.gint64(sourceRead(int(handle), buf)) -} - -//export goSourceSeekCb -func goSourceSeekCb(handle C.int, offset C.gint64, whence C.int) C.gint64 { - return C.gint64(sourceSeek(int(handle), int64(offset), int(whence))) -} - -//export goTargetWriteCb -func goTargetWriteCb(handle C.int, data unsafe.Pointer, length C.gint64) C.gint64 { - if length <= 0 { - return 0 - } - buf := unsafe.Slice((*byte)(data), int(length)) - return C.gint64(targetWrite(int(handle), buf)) -} - -//export goTargetEndCb -func goTargetEndCb(handle C.int) C.int { - return C.int(targetEnd(int(handle))) -} - -func sourceRead(handle int, buf []byte) int64 { - entry := lookupSource(handle) - if entry == nil { - return -1 - } - - entry.mu.Lock() - defer entry.mu.Unlock() - - // (0, nil) is allowed by the io.Reader contract; retry rather than - // returning 0, which libvips would treat as EOF. Bound the retries so - // a pathological reader that returns (0, nil) forever fails the load - // instead of pinning a libvips worker thread inside this callback. - const maxZeroReads = 100 - for i := 0; i < maxZeroReads; i++ { - n, err := entry.reader.Read(buf) - if n > 0 { - // A non-EOF error alongside n>0 will surface on the next call. - return int64(n) - } - if errors.Is(err, io.EOF) { - return 0 - } - if err != nil { - entry.lastErr = err - return -1 - } - } - entry.lastErr = fmt.Errorf("reader returned (0, nil) %d times in a row", maxZeroReads) - return -1 -} - -func sourceSeek(handle int, offset int64, whence int) int64 { - entry := lookupSource(handle) - if entry == nil || entry.seeker == nil { - return -1 - } - - entry.mu.Lock() - defer entry.mu.Unlock() - - size, err := entry.sourceSizeLocked() - if err != nil { - entry.lastErr = err - return -1 - } - - // Resolve the absolute target ourselves. libvips whence values are - // SEEK_SET/SEEK_CUR/SEEK_END, matching io.SeekStart/Current/End. - var base int64 - switch whence { - case io.SeekStart: - base = 0 - case io.SeekCurrent: - cur, err := entry.seeker.Seek(0, io.SeekCurrent) - if err != nil { - entry.lastErr = err - return -1 - } - base = cur - case io.SeekEnd: - base = size - default: - return -1 - } - - target := base + offset - if target < 0 { - // POSIX lseek rejects negative positions (EINVAL) without - // affecting the stream; treat it as a probe, not a stream - // error, so it is not wrapped into the load error later. - return -1 - } - if target > size { - // POSIX permits seeking beyond EOF, and codecs probe container - // structures that way (libheif seeks past the final HEIC box). - // Report the requested position: libvips itself range-checks it - // against the source length and turns it into the failure the - // heif glue's wait_for_file_size protocol relies on. Park the - // underlying seeker at EOF so strict io.Seeker implementations - // are never asked for an out-of-range position; any read then - // returns 0 bytes. One divergence from POSIX: a subsequent - // SEEK_CUR resolves from EOF, not from the reported past-EOF - // position. That is fine in practice because libvips' codec glue - // only ever follows a past-EOF probe with an absolute seek. - if _, err := entry.seeker.Seek(size, io.SeekStart); err != nil { - entry.lastErr = err - return -1 - } - return target - } - - pos, err := entry.seeker.Seek(target, io.SeekStart) - if err != nil { - entry.lastErr = err - return -1 - } - return pos -} - -func targetWrite(handle int, buf []byte) int64 { - entry := lookupTarget(handle) - if entry == nil { - return -1 - } - - entry.mu.Lock() - defer entry.mu.Unlock() - - n, err := entry.writer.Write(buf) - if err != nil { - entry.lastErr = err - return -1 - } - return int64(n) -} - -func targetEnd(handle int) int { - entry := lookupTarget(handle) - if entry == nil { - return -1 - } - - entry.mu.Lock() - defer entry.mu.Unlock() - - if entry.lastErr != nil { - return -1 - } - return 0 -} - -// streamSourceRef ties a live VipsSourceCustom (and its registry entry) -// to a sequentially stream-loaded ImageRef. The image pulls pixels from -// the source on demand, so both stay alive until the image is closed or -// materialized. -type streamSourceRef struct { - handle int - entry *sourceEntry - source *C.VipsSourceCustom -} - -func (s *streamSourceRef) release() { - C.clear_source(&s.source) - deregisterSource(s.handle) -} - -// streamMaterialize holds the knobs for the default (random-access) -// load path: decoded images at most threshold bytes are materialized in -// memory, larger ones in a scratch file on disc. -var streamMaterialize = struct { - sync.RWMutex - scratchDir string // "" → os.TempDir() - threshold int64 // <0 → resolve from VIPS_DISC_THRESHOLD / default -}{threshold: -1} - -// defaultDiscThreshold mirrors the libvips default for -// VIPS_DISC_THRESHOLD: decoded images above 100 MB go to disc. -const defaultDiscThreshold = 100 << 20 - -// SetStreamScratchDir sets the directory used for scratch files when a -// stream-loaded image is materialized to disc (see -// SetStreamDiscThreshold). An empty string restores the default -// (os.TempDir()). Scratch files are unlinked as soon as the decoded -// image has been written and reopened, so on the happy path they never -// outlive the ImageRef; a crash mid-materialization can leave one -// behind in this directory. -func SetStreamScratchDir(dir string) { - streamMaterialize.Lock() - defer streamMaterialize.Unlock() - streamMaterialize.scratchDir = dir -} - -// SetStreamDiscThreshold sets the decoded-size threshold (in bytes) -// above which LoadImageFromReader materializes images to a scratch file -// on disc instead of memory. Zero sends every image to disc. A negative -// value restores the default: the VIPS_DISC_THRESHOLD environment -// variable (number with optional k/m/g suffix) or 100 MB. -func SetStreamDiscThreshold(bytes int64) { - streamMaterialize.Lock() - defer streamMaterialize.Unlock() - streamMaterialize.threshold = bytes -} - -func streamDiscThresholdBytes() int64 { - streamMaterialize.RLock() - t := streamMaterialize.threshold - streamMaterialize.RUnlock() - if t >= 0 { - return t - } - if env := os.Getenv("VIPS_DISC_THRESHOLD"); env != "" { - if v, ok := parseVipsSize(env); ok { - return v - } - } - return defaultDiscThreshold -} - -func streamScratchDir() string { - streamMaterialize.RLock() - defer streamMaterialize.RUnlock() - if streamMaterialize.scratchDir != "" { - return streamMaterialize.scratchDir - } - return os.TempDir() -} - -// parseVipsSize parses libvips-style size strings: a number with an -// optional k/m/g suffix (powers of 1024). -func parseVipsSize(s string) (int64, bool) { - s = strings.TrimSpace(strings.ToLower(s)) - mult := int64(1) - switch { - case strings.HasSuffix(s, "k"): - mult, s = 1<<10, s[:len(s)-1] - case strings.HasSuffix(s, "m"): - mult, s = 1<<20, s[:len(s)-1] - case strings.HasSuffix(s, "g"): - mult, s = 1<<30, s[:len(s)-1] - } - v, err := strconv.ParseFloat(strings.TrimSpace(s), 64) - if err != nil || v < 0 { - return 0, false - } - return int64(v * float64(mult)), true -} - -// materializeImage renders the lazy image in to either memory or a -// scratch file on disc, depending on its decoded size and the configured -// threshold. The returned image no longer reads from the source. -func materializeImage(in *C.VipsImage) (*C.VipsImage, error) { - decoded := int64(C.image_decoded_size(in)) - - if decoded <= streamDiscThresholdBytes() { - var out *C.VipsImage - if C.copy_image_to_memory(in, &out) != 0 { - return nil, handleVipsError() - } - return out, nil - } - - f, err := os.CreateTemp(streamScratchDir(), "govips-scratch-*.v") - if err != nil { - return nil, fmt.Errorf("streaming load: create scratch file: %w", err) - } - path := f.Name() - _ = f.Close() - - cPath := C.CString(path) - defer C.free(unsafe.Pointer(cPath)) - - var out *C.VipsImage - code := C.write_image_to_disc(in, cPath, &out) - // Unlink immediately: the open file keeps the data alive until the - // image is closed. (A crash during write_image_to_disc itself can - // still leave the scratch file behind; see SetStreamScratchDir.) - _ = os.Remove(path) - if code != 0 { - return nil, handleVipsError() - } - return out, nil -} - -// sequentialAccess reports whether params request sequential streaming. -func sequentialAccess(params *ImportParams) bool { - if !params.Access.IsSet() { - return false - } - a := params.Access.Get() - return a == AccessSequential || a == AccessSequentialUnbuffered -} - -// LoadImageFromReader loads an image from the given io.Reader using -// libvips streaming (VipsSourceCustom). If r also implements io.Seeker, -// seek is exposed to libvips for efficient random-access loading. -// Otherwise libvips uses sequential mode with automatic header buffering -// (see SetPipeReadLimit). -// -// By default the image is fully materialized before this function -// returns — in memory when its decoded size is at most the disc -// threshold, otherwise in an unlinked scratch file (see -// SetStreamDiscThreshold and SetStreamScratchDir). The reader is -// consumed during this call and is not retained; callers may close it -// immediately. Decode errors (including truncated input) surface here. -// -// If params.Access is AccessSequential, the image is instead loaded -// lazily: libvips pulls compressed bytes from r on demand while later -// operations consume pixels, so peak memory stays bounded by libvips -// line caches regardless of image size. The reader MUST stay open until -// the ImageRef is closed (Close releases it). Only operations that read -// pixels strictly top-to-bottom are valid on such images — see the -// "Streaming" section of the README. Decode errors surface from the -// operation that first consumes the pixels (typically SaveToWriter or -// Export*), not from this function. -// -// In every mode the returned ImageRef has no buffer backing: the full -// compressed input is never held in Go memory. (NewImageFromReader, by -// contrast, slurps the whole reader into a buffer via io.ReadAll before -// decoding; prefer this function when input size matters.) -// -// Error strictness: when params.FailOnError is set, streaming loads use -// libvips' fail_on=truncated, which is slightly laxer than the -// fail_on=error used by the buffer loaders — truncated input always -// errors deterministically, but some recoverable decode warnings that -// the buffer path would reject are tolerated. -// -// params may be nil for default import settings. -func LoadImageFromReader(r io.Reader, params *ImportParams) (*ImageRef, error) { - if r == nil { - return nil, errors.New("reader is nil") - } - if err := startupIfNeeded(); err != nil { - return nil, err - } - if params == nil { - params = NewImportParams() - } - - incOpCounter("load_source") - - handle, entry := registerSource(r) - - source := C.create_source_custom(C.int(handle), C.int(boolToInt(entry.seeker != nil))) - if source == nil { - deregisterSource(handle) - return nil, handleVipsError() - } - - // Sniff the signature up front (buffered and rewound, not consumed): - // the loader nickname alone cannot express sub-formats — AVIF loads - // via heifload, BMP/PSD via magickload — but the buffer path reports - // them via DetermineImageType, and the streaming path must match. - var header [12]byte - headerKnown := C.source_sniff_header(source, (*C.uchar)(unsafe.Pointer(&header[0])), C.int(len(header))) == 0 - - loadParams := createImportParams(ImageTypeUnknown, params) - - if code := C.load_from_source(source, &loadParams); code != 0 { - err := wrapStreamError("streaming load", handleImageError(loadParams.outputImage), entry.takeErr()) - C.clear_source(&source) - deregisterSource(handle) - return nil, err - } - - lazy := loadParams.outputImage - format := ImageType(loadParams.inputFormat) - originalFormat := format - if headerKnown && (format == ImageTypeHEIF || format == ImageTypeMagick) { - if sniffed := DetermineImageType(header[:]); sniffed != ImageTypeUnknown { - originalFormat = sniffed - if !isNeedToChangeLoaderToMagick(sniffed) { - format = sniffed - } - } - } - - if sequentialAccess(params) { - ref := newImageRef(lazy, format, originalFormat, nil) - ref.streamSource = &streamSourceRef{handle: handle, entry: entry, source: source} - govipsLog("govips", LogLevelDebug, fmt.Sprintf("created sequential imageRef %p from reader", ref)) - return ref, nil - } - - // Default path: materialize now so the source (and the caller's - // reader) can be released before returning. Upstream resources - // (file handles, HTTP connections) are freed early. - out, err := materializeImage(lazy) - clearImage(lazy) - C.clear_source(&source) - deregisterSource(handle) - if err != nil { - return nil, wrapStreamError("streaming load", err, entry.takeErr()) - } - - ref := newImageRef(out, format, originalFormat, nil) - govipsLog("govips", LogLevelDebug, fmt.Sprintf("created imageRef %p from reader", ref)) - return ref, nil -} - -// materialize converts a sequentially stream-loaded image into a -// materialized one (memory or scratch disc, by threshold) and releases -// its source, making random-access operations valid. It is a no-op for -// images that are already materialized. -func (r *ImageRef) materialize() error { - r.lock.Lock() - - if r.image == nil { - r.lock.Unlock() - return errors.New("attempt to materialize a closed ImageRef") - } - src := r.streamSource - if src == nil { - r.lock.Unlock() - return nil - } - - out, err := materializeImage(r.image) - if err != nil { - r.lock.Unlock() - return wrapStreamError("streaming load", err, src.entry.takeErr()) - } - - clearImage(r.image) - r.image = out - r.streamSource = nil - r.lock.Unlock() - - src.release() - return nil -} - -// SaveToWriter encodes the image in the specified format and writes the -// encoded bytes directly to w using libvips streaming (VipsTargetCustom). -// The writer receives chunks of encoded data as they are produced and is -// not retained after SaveToWriter returns. -// -// Supported formats: ImageTypeJPEG, ImageTypePNG, ImageTypeWEBP, -// ImageTypeHEIF, ImageTypeTIFF, ImageTypeGIF. Output is byte-identical to -// the corresponding Export* method with equivalent parameters. -// -// TIFF is encoded in memory and written in a single chunk, because the -// TIFF container requires seekable output; all other formats stream -// encoded chunks to w as they are produced. -// -// params may be nil for the format's default export settings; the format -// argument takes precedence over params.Format. For access to the full -// set of format-specific options, use the typed variants -// (SaveToWriterJpeg, SaveToWriterPng, SaveToWriterWebp, SaveToWriterTiff, -// SaveToWriterHeif, SaveToWriterGif). -func (r *ImageRef) SaveToWriter(w io.Writer, format ImageType, params *ExportParams) error { - return r.saveToWriter(w, format, func(in *C.VipsImage) (C.struct_SaveParams, func(), error) { - return streamSaveParams(in, format, params) - }) -} - -// SaveToWriterJpeg streams the image to w as JPEG with the full set of -// JPEG export options. Behaves like SaveToWriter; params may be nil for -// defaults. Output is byte-identical to ExportJpeg. -func (r *ImageRef) SaveToWriterJpeg(w io.Writer, params *JpegExportParams) error { - if params == nil { - params = NewJpegExportParams() - } - p := *params - return r.saveToWriter(w, ImageTypeJPEG, func(in *C.VipsImage) (C.struct_SaveParams, func(), error) { - sp, err := newSaveParamsJPEG(in, p) - return sp, func() {}, err - }) -} - -// SaveToWriterPng streams the image to w as PNG with the full set of PNG -// export options (Palette, Dither, Bitdepth, Filter, ...). Behaves like -// SaveToWriter; params may be nil for defaults. Output is byte-identical -// to ExportPng. -func (r *ImageRef) SaveToWriterPng(w io.Writer, params *PngExportParams) error { - if params == nil { - params = NewPngExportParams() - } - p := *params - return r.saveToWriter(w, ImageTypePNG, func(in *C.VipsImage) (C.struct_SaveParams, func(), error) { - sp, err := newSaveParamsPNG(in, p) - return sp, func() {}, err - }) -} - -// SaveToWriterWebp streams the image to w as WebP with the full set of -// WebP export options (NearLossless, IccProfile, TargetSize, ...). -// Behaves like SaveToWriter; params may be nil for defaults. Output is -// byte-identical to ExportWebp. -func (r *ImageRef) SaveToWriterWebp(w io.Writer, params *WebpExportParams) error { - if params == nil { - params = NewWebpExportParams() - } - p := *params - return r.saveToWriter(w, ImageTypeWEBP, func(in *C.VipsImage) (C.struct_SaveParams, func(), error) { - return newSaveParamsWebP(in, p) - }) -} - -// SaveToWriterTiff writes the image to w as TIFF with the full set of -// TIFF export options (Compression, Predictor, Tile, ...). Like the TIFF -// path of SaveToWriter, the image is encoded in memory and written in a -// single chunk (libtiff requires seekable output). params may be nil for -// defaults. Output is byte-identical to ExportTiff. -func (r *ImageRef) SaveToWriterTiff(w io.Writer, params *TiffExportParams) error { - if params == nil { - params = NewTiffExportParams() - } - p := *params - return r.saveToWriter(w, ImageTypeTIFF, func(in *C.VipsImage) (C.struct_SaveParams, func(), error) { - sp, err := newSaveParamsTIFF(in, p) - return sp, func() {}, err - }) -} - -// SaveToWriterHeif streams the image to w as HEIF with the full set of -// HEIF export options (Bitdepth, Effort, ...). Behaves like SaveToWriter; -// params may be nil for defaults. Output is byte-identical to ExportHeif. -func (r *ImageRef) SaveToWriterHeif(w io.Writer, params *HeifExportParams) error { - if params == nil { - params = NewHeifExportParams() - } - p := *params - return r.saveToWriter(w, ImageTypeHEIF, func(in *C.VipsImage) (C.struct_SaveParams, func(), error) { - sp, err := newSaveParamsHEIF(in, p) - return sp, func() {}, err - }) -} - -// SaveToWriterGif streams the image to w as GIF with the full set of GIF -// export options (Dither, Effort, Bitdepth, ...). Behaves like -// SaveToWriter; params may be nil for defaults. Output is byte-identical -// to ExportGIF. -func (r *ImageRef) SaveToWriterGif(w io.Writer, params *GifExportParams) error { - if params == nil { - params = NewGifExportParams() - } - p := *params - return r.saveToWriter(w, ImageTypeGIF, func(in *C.VipsImage) (C.struct_SaveParams, func(), error) { - sp, err := newSaveParamsGIF(in, p) - return sp, func() {}, err - }) -} - -// saveToWriter is the shared core of SaveToWriter and its typed -// variants: it locks the image, builds the C save params via -// buildParams, and runs the streaming (or, for TIFF, buffered) save. -func (r *ImageRef) saveToWriter(w io.Writer, format ImageType, buildParams func(*C.VipsImage) (C.struct_SaveParams, func(), error)) error { - if w == nil { - return errors.New("writer is nil") - } - - r.lock.Lock() - defer r.lock.Unlock() - defer runtime.KeepAlive(r) - - if r.image == nil { - return errors.New("attempt to save a closed ImageRef") - } - - saveParams, cleanup, err := buildParams(r.image) - if err != nil { - return err - } - defer cleanup() - - incOpCounter("save_" + ImageTypes[format] + "_target") - - if format == ImageTypeTIFF { - // libtiff requires a seekable, readable output stream (it - // rewrites IFD offsets after encoding), which a plain io.Writer - // cannot provide. Encode through the buffer path and emit a - // single write; the bytes are identical to ExportTiff. - buf, err := vipsSaveToBuffer(saveParams) - if err != nil { - var ioErr error - if r.streamSource != nil { - // Sequential decode runs during this encode; surface - // the reader's error like the streaming-target path. - ioErr = r.streamSource.entry.takeErr() - } - return wrapStreamError("streaming save", err, ioErr) - } - if _, err := w.Write(buf); err != nil { - return fmt.Errorf("streaming save: writer error: %w", err) - } - return nil - } - - handle, entry := registerTarget(w) - defer deregisterTarget(handle) - - target := C.create_target_custom(C.int(handle)) - if target == nil { - return handleVipsError() - } - defer C.clear_target(&target) - - var code C.int - switch format { - case ImageTypeJPEG: - code = C.save_jpeg_to_target(&saveParams, target) - case ImageTypePNG: - code = C.save_png_to_target(&saveParams, target) - case ImageTypeWEBP: - code = C.save_webp_to_target(&saveParams, target) - case ImageTypeHEIF: - code = C.save_heif_to_target(&saveParams, target) - // ImageTypeTIFF is handled by the buffer-path early return above. - case ImageTypeGIF: - code = C.save_gif_to_target(&saveParams, target) - } - - if code != 0 { - ioErr := entry.takeErr() - if ioErr == nil && r.streamSource != nil { - // For sequentially stream-loaded images the decode runs - // during this save; surface the reader's error too. - ioErr = r.streamSource.entry.takeErr() - } - return wrapStreamError("streaming save", handleVipsError(), ioErr) - } - if ioErr := entry.takeErr(); ioErr != nil { - return fmt.Errorf("streaming save: writer error: %w", ioErr) - } - return nil -} - -// streamSaveParams builds the C save parameters for SaveToWriter using -// the same ExportParams mapping as (*ImageRef).Export (via the shared -// *ParamsFromExport helpers) and the same C-struct population as the -// Export* buffer savers, so streaming output stays byte-identical to the -// buffer path. The returned cleanup must be called after the save -// completes. -func streamSaveParams(in *C.VipsImage, format ImageType, params *ExportParams) (C.struct_SaveParams, func(), error) { - noop := func() {} - - switch format { - case ImageTypeJPEG: - p, err := newSaveParamsJPEG(in, *jpegParamsFromExport(params)) - return p, noop, err - case ImageTypePNG: - p, err := newSaveParamsPNG(in, *pngParamsFromExport(params)) - return p, noop, err - case ImageTypeWEBP: - return newSaveParamsWebP(in, *webpParamsFromExport(params)) - case ImageTypeHEIF: - p, err := newSaveParamsHEIF(in, *heifParamsFromExport(params)) - return p, noop, err - case ImageTypeTIFF: - p, err := newSaveParamsTIFF(in, *tiffParamsFromExport(params)) - return p, noop, err - case ImageTypeGIF: - p, err := newSaveParamsGIF(in, *gifParamsFromExport(params)) - return p, noop, err - default: - return C.struct_SaveParams{}, noop, fmt.Errorf("streaming save does not support format %q", ImageTypes[format]) - } -} - -// wrapStreamError combines the libvips error with the original Go -// reader/writer error, when one was stored during a callback. -func wrapStreamError(op string, vipsErr, ioErr error) error { - if ioErr != nil { - return fmt.Errorf("%s: %w (caused by: %w)", op, vipsErr, ioErr) - } - return vipsErr -} diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/stream.h b/vendor/github.com/davidbyttow/govips/v2/vips/stream.h deleted file mode 100644 index 459f1302cf..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/stream.h +++ /dev/null @@ -1,85 +0,0 @@ -// Streaming I/O via VipsSourceCustom/VipsTargetCustom. -// C declarations for the callback bridge between libvips worker threads -// and Go io.Reader/io.Writer instances registered in stream.go. - -#ifndef STREAM_H -#define STREAM_H - -#include "foreign.h" - -// Exported Go callbacks, defined in stream.go via //export. -// Called by the static C trampolines in stream.c. The handle identifies -// an entry in the Go-side callback registry. The buffer/data pointers are -// owned by libvips and are only valid for the duration of the call; Go -// must not retain them. - -// Reads up to length bytes into buffer. Returns bytes read, 0 on EOF, -// -1 on error. -extern gint64 goSourceReadCb(int handle, void *buffer, gint64 length); - -// Seeks the underlying reader. Returns the new absolute offset, or -1 on -// error or if the reader does not support seeking. -extern gint64 goSourceSeekCb(int handle, gint64 offset, int whence); - -// Writes length bytes from data. Returns bytes written, -1 on error. -extern gint64 goTargetWriteCb(int handle, void *data, gint64 length); - -// Signals end of output. Returns 0 on success, -1 on error. -extern int goTargetEndCb(int handle); - -// Creates a VipsSourceCustom with the "read" trampoline connected, and the -// "seek" trampoline too when has_seek is non-zero. The handle is stored as -// signal user_data. Returns a new reference owned by the caller; release -// with clear_source. Returns NULL on failure. -VipsSourceCustom *create_source_custom(int handle, int has_seek); - -// Creates a VipsTargetCustom with the "write" and "end" trampolines -// connected. The handle is stored as signal user_data. Returns a new -// reference owned by the caller; release with clear_target. Returns NULL -// on failure. -VipsTargetCustom *create_target_custom(int handle); - -// Detects the image format by sniffing the source, then loads it. -// Borrows source (does not take ownership). On success returns 0, sets -// params->inputFormat to the detected format, and stores a new VipsImage -// reference in params->outputImage owned by the caller. The image is -// LAZY: it pulls from the source on demand until materialized, so the -// source must stay alive (and registered) until the image is either -// materialized or closed. On failure returns non-zero with the error in -// the vips error buffer. -int load_from_source(VipsSourceCustom *source, LoadParams *params); - -// Returns the decoded (uncompressed) pixel size of in, in bytes. -gint64 image_decoded_size(VipsImage *in); - -// Renders in into a memory image. Borrows in; on success stores a new -// reference in *out owned by the caller. Returns non-zero on failure. -int copy_image_to_memory(VipsImage *in, VipsImage **out); - -// Renders in into the vips-native file at path (one sequential pass), -// then reopens it read-only with random access. Borrows in; on success -// stores a new reference in *out owned by the caller; the caller may -// unlink path immediately (the open file keeps the data alive). -// Returns non-zero on failure. -int write_image_to_disc(VipsImage *in, const char *path, VipsImage **out); - -// Encode params->inputImage to the target. Both the image and the target -// are borrowed (the caller retains ownership). Return 0 on success, -// non-zero on failure with the error in the vips error buffer. -int save_jpeg_to_target(SaveParams *params, VipsTargetCustom *target); -int save_png_to_target(SaveParams *params, VipsTargetCustom *target); -int save_webp_to_target(SaveParams *params, VipsTargetCustom *target); -int save_heif_to_target(SaveParams *params, VipsTargetCustom *target); -int save_gif_to_target(SaveParams *params, VipsTargetCustom *target); - -// Copies the first len bytes of the source into out without consuming -// them (vips_source_sniff buffers and rewinds). Returns non-zero if the -// stream is shorter than len or unreadable. Call before loading so the -// sniff window is still rewindable for every source kind. -int source_sniff_header(VipsSourceCustom *source, unsigned char *out, int len); - -// Unrefs *source / *target and sets it to NULL. NULL-safe. -void clear_source(VipsSourceCustom **source); -void clear_target(VipsTargetCustom **target); - -#endif // STREAM_H diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/test_resources.go b/vendor/github.com/davidbyttow/govips/v2/vips/test_resources.go deleted file mode 100644 index b2e91e4cd3..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/test_resources.go +++ /dev/null @@ -1,6 +0,0 @@ -package vips - -// relative to "/vips/.." -const ( - resources = "../resources/" -) diff --git a/vendor/github.com/davidbyttow/govips/v2/vips/transcode.go b/vendor/github.com/davidbyttow/govips/v2/vips/transcode.go deleted file mode 100644 index d23de1156b..0000000000 --- a/vendor/github.com/davidbyttow/govips/v2/vips/transcode.go +++ /dev/null @@ -1,104 +0,0 @@ -package vips - -import ( - "errors" - "fmt" - "io" -) - -// TranscodeOptions configures TranscodeStream. -type TranscodeOptions struct { - // Format is the output image type. ImageTypeUnknown keeps the - // input format (which must be one of the streaming-save formats: - // JPEG, PNG, WebP, HEIF, TIFF, GIF). - Format ImageType - - // ImportParams configures the load. The Access field is ignored: - // TranscodeStream picks the access mode itself. - ImportParams *ImportParams - - // ExportParams configures the encode; nil uses the format's - // defaults, exactly like SaveToWriter. - ExportParams *ExportParams - - // AutoRotate applies the EXIF orientation to the pixels and clears - // the orientation tag. Orientations that need a non-sequential - // transform (3-8: 180° and 90°/270° families) force the image to be - // materialized first — see the package streaming documentation. - AutoRotate bool -} - -// TranscodeStream decodes an image from r, optionally applies EXIF -// auto-rotation, and encodes it to w in the requested format. Encoded -// bytes are handed to w in chunks as they are produced and are -// byte-identical to the corresponding Export* method with the same -// parameters. -// -// The pipeline picks the cheapest decode strategy automatically: -// -// - Sequential fast path: when no random-access transform is needed -// (AutoRotate false, or EXIF orientation is 1 or 2), pixels flow -// from r to w in one pass. Peak memory is bounded by libvips line -// caches, independent of both file size and pixel count. -// - Materialized path: when AutoRotate requires a rotation, the -// decoded image is first rendered to memory or to an unlinked -// scratch file, depending on its decoded size and the configured -// threshold (SetStreamDiscThreshold, SetStreamScratchDir). -// -// Reader/decode errors (including truncated input) surface from this -// call: on the sequential path during the encode (the first full pass -// over the pixels), on the materialized path during materialization. -// In both cases the original reader/writer error is wrapped and -// matchable with errors.Is. -// -// govips knows nothing about the destination: w is the chunk callback. -// Compose on the consumer side with io.MultiWriter (hash while -// writing), io.Pipe (bridge to reader-shaped sinks), or io.Copy. -func TranscodeStream(r io.Reader, w io.Writer, opts *TranscodeOptions) error { - if r == nil { - return errors.New("transcode: reader is nil") - } - if w == nil { - return errors.New("transcode: writer is nil") - } - if opts == nil { - opts = &TranscodeOptions{} - } - - importParams := NewImportParams() - if opts.ImportParams != nil { - *importParams = *opts.ImportParams - } - importParams.Access.Set(AccessSequential) - - img, err := LoadImageFromReader(r, importParams) - if err != nil { - return fmt.Errorf("transcode: %w", err) - } - defer img.Close() - - if opts.AutoRotate { - // Orientation is header metadata, available before any pixel is - // decoded. Orientations 1 (none) and 2 (horizontal flip) are - // sequential-safe; everything else transposes or reverses line - // order and needs random access. - if img.Orientation() >= 3 { - if err := img.materialize(); err != nil { - return fmt.Errorf("transcode: %w", err) - } - } - if err := img.AutoRotate(); err != nil { - return fmt.Errorf("transcode: autorotate: %w", err) - } - } - - format := opts.Format - if format == ImageTypeUnknown { - format = img.Format() - } - - if err := img.SaveToWriter(w, format, opts.ExportParams); err != nil { - return fmt.Errorf("transcode: %w", err) - } - return nil -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 454c19cffb..e7b2b171cc 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -361,9 +361,6 @@ github.com/cyphar/filepath-securejoin/internal/consts # github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc ## explicit github.com/davecgh/go-spew/spew -# github.com/davidbyttow/govips/v2 v2.20.0 -## explicit; go 1.25.0 -github.com/davidbyttow/govips/v2/vips # github.com/deckarep/golang-set v1.8.0 ## explicit; go 1.17 github.com/deckarep/golang-set