Repository navigation
feat(libvips): add my-media-libvips, a media_image plugin with libvips - #19
Merged
Merged
Conversation
It makes the same outputs as my-media-imagemagick, about ten times faster on a 12-megapixel photo. The plugin links libvips (cgo) and processes each image in a worker, a process of its own binary, so that a decoder that crashes takes down one call, a cancelled call kills its worker, and the memory of an image goes back with it. Only the loaders of the accepted formats are left unblocked, and the limits are checked before a pixel is decoded, the frames of a GIF and a WebP read from their blocks and chunks. An APNG is not declared: libvips reads its default image, as the server reads one when the plugin does not declare APNG. go vet type-checks the cgo, so the lint job installs libvips-dev. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A new plugin,
my-media-libvips, that implementsMediaService.Process(media_image) with libvips. It makes the same outputs asmy-media-imagemagick(formats, sizes, metadata removal, blurhash, the same bytes for the same input).MY_MEDIA_LIBVIPS_WORKER=1for each call. A decoder that crashes takes down that call only, a cancelled call kills its worker, and the memory of an image goes back to the system when the worker exits.frames.goreads them from the blocks of a GIF and the chunks of a WebP.Differences from my-media-imagemagick
my-media-imagemagick/apng.gocould move tointernal/media.-concurrencydefaults to 2 (the server sends at most two image calls at once), and each worker gets NumCPU / concurrency threads.CI
go vettype-checks the cgo, so the lint job installslibvips-dev. The workflow change makes this PR test every plugin.Test plan
go test -race ./...in the test stage of the image: 14 tests, none skipped (photo, wide gamut, transparent avatar, opaque PNG, emoji, GIF and WebP animations, APNG, AVIF and HEIC, HEIC rotated once, refusals, cancellation)./scripts/lint.shin a container with libvips-devgo run -C tools ./cmd/contract -plugin my-media-libvipswithmyv0.1.0-rc.12: 24 passed🤖 Generated with Claude Code