Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide more robust way to enforce custom libvips dependency #4060

Open
project0 opened this issue Apr 9, 2024 · 3 comments
Open

Provide more robust way to enforce custom libvips dependency #4060

project0 opened this issue Apr 9, 2024 · 3 comments

Comments

@project0
Copy link

project0 commented Apr 9, 2024

Feature request

What are you trying to achieve?

The current way to use a externally compiled/provided libvips depends on automatically detection of the sharp installer scripts. This has some flaws and can produce very inconsistent experience as it is not always clear if the external library is being used or the provided pre-compiled libs.

One of my services requires for example PDF support with libvips and i have to compile it at my own, but there is absolutely no way to enforce usage.

So it happens when there is a mismatch on the minimum required vips version, it silently installs the pre-compiled version and ignores the globally provided libvips, what can result into a broken service as certain formats are suddenly not supported.

When you searched for similar feature requests, what did you find that might be related?

What would you expect the API to look like?

I would be fine with a environment variable to control this behavior.
Opposite to SHARP_IGNORE_GLOBAL_LIBVIPS something like SHARP_FORCE_GLOBAL_LIBVIPS

What alternatives have you considered?

I have currently a short assertion test after installing the libraries to ensure all dependencies are correctly setup, but its more a safeguard than a solutions:

test "true" = "$(node -e "console.log(require('sharp').format.pdf.input.stream)")"

Please provide sample image(s) that help explain this feature

@lovell lovell added this to the v0.33.4 milestone Apr 10, 2024
@lovell
Copy link
Owner

lovell commented Apr 10, 2024

Thanks for the suggestion, this is a good idea for more advanced users that are comfortable building their own custom libvips. I've added it via commit 579cf93

An alternative fail-fast technique might be to pass the --build-from-source flag and then remove the node_modules/@img directory (or somehow block it in the first place).

@TransRapid
Copy link

TransRapid commented Apr 30, 2024

I had to kill my terminal sessions, installed and removed both sharp locally and as root, then, installed it locally again using the following:

npm install sharp --build-from-source --verbose --foreground-scripts
Restarting my Terminal session and then running the above again resolved the issue. Let me know if you need any other info, or if anyone else needs assistance.

Original Below:

I think this issue is the cause of
#2518.
and
#4050

Unfortunately it did not resolve the issue of unsupported codec for heif. I can manually do it through vips copy image.heic image.jpeg.

pkg-config --modversion vips-cpp
8.16.0
which vips
/usr/local/bin/vips
/usr/local/bin/vips --vips-version
libvips 8.16.0

@lovell
Copy link
Owner

lovell commented Apr 30, 2024

@TransRapid Please see https://sharp.pixelplumbing.com/install#building-from-source for the prerequisite dependencies that are required to be able to build sharp from source. If you are still having problems, please open a new installation issue and answer all of the questions.

(I note you are compiling libvips from source control rather than using a published version. Please remember this is not yet released and therefore has not yet been fully tested with sharp so you may have run into a separate problem.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants