davidbyttow / govips

A lightning fast image processing and resizing library for Go
MIT License
1.31k stars 203 forks source link

VipsJpeg: Wrong JPEG library version: library is 90, caller expects 80 #429

Closed ishdutt closed 7 months ago

ishdutt commented 7 months ago

When running this package within a Gin backend server, an error occurs stating:

VipsJpeg: Wrong JPEG library version: library is 90, caller expects 80

When running the same code as a script, it works fine and there is no error.

Steps to Reproduce: Run a Gin backend server with github.com/davidbyttow/govips package. Attempt to process JPEG images within the server.

Expected Behavior: The server should run successfully without encountering any version mismatch errors related to the JPEG library.

Actual Behavior: The server encounters the VipsJpeg: Wrong JPEG library version error, indicating a mismatch between the JPEG library versions.

Additional Context: govips version: vips-8.15.0 Operating System: Ubuntu 22.04.1 arm64 Go version: go1.22.2

Sample Code:

    vips.Startup(nil)
    defer vips.Shutdown()

    daata, _ := os.ReadFile("sample.jpg")

    inputImage, err := vips.NewImageFromBuffer(daata)
    checkError(err)
    defer inputImage.Close()
    checkError(inputImage.OptimizeICCProfile())

    ep := vips.NewJpegExportParams()
    ep.StripMetadata = true
    ep.Quality = 75
    ep.Interlace = true
    ep.OptimizeCoding = true
    ep.SubsampleMode = vips.VipsForeignSubsampleAuto
    ep.TrellisQuant = true
    ep.OvershootDeringing = true
    ep.OptimizeScans = true
    ep.QuantTable = 3

    imageBytes, _, err := inputImage.ExportJpeg(ep)
    checkError(err)
    checkError(os.WriteFile("optim.jpg", imageBytes, 0644))

Debug Logs (From script):

        2024/04/29 11:41:12 [VIPS.info] found /usr/local/lib/aarch64-linux-gnu/vips-modules-8.15
        2024/04/29 11:41:12 [VIPS.info] using configure-time prefix
        2024/04/29 11:41:12 [VIPS.info] VIPS_PREFIX = /usr/local
        2024/04/29 11:41:12 [VIPS.info] VIPS_LIBDIR = /usr/local/lib/aarch64-linux-gnu
        2024/04/29 11:41:12 [VIPS.info] prefix = /usr/local
        2024/04/29 11:41:12 [VIPS.info] libdir = /usr/local/lib/aarch64-linux-gnu
        2024/04/29 11:41:12 [VIPS.info] searching "/usr/local/lib/aarch64-linux-gnu/vips-modules-8.15"
        2024/04/29 11:41:12 [VIPS.info] loading "/usr/local/lib/aarch64-linux-gnu/vips-modules-8.15/vips-openslide.so"
        2024/04/29 11:41:12 [VIPS.info] loading "/usr/local/lib/aarch64-linux-gnu/vips-modules-8.15/vips-heif.so"
        2024/04/29 11:41:12 [VIPS.info] loading "/usr/local/lib/aarch64-linux-gnu/vips-modules-8.15/vips-magick.so"
        2024/04/29 11:41:12 [VIPS.info] loading "/usr/local/lib/aarch64-linux-gnu/vips-modules-8.15/vips-poppler.so"
        2024/04/29 11:41:12 [VIPS.info] searching "/usr/local/lib/aarch64-linux-gnu/vips-plugins-8.15"
        2024/04/29 11:41:12 [govips.info] vips 8.15.0 started with concurrency=1 cache_max_files=0 cache_max_mem=52428800 cache_max=100
        2024/04/29 11:41:12 [govips.info] registered image type loader type=tiff
        2024/04/29 11:41:12 [govips.info] registered image type loader type=heif
        2024/04/29 11:41:12 [govips.info] registered image type loader type=heif
        2024/04/29 11:41:12 [govips.info] registered image type loader type=svg
        2024/04/29 11:41:12 [govips.info] registered image type loader type=jpeg
        2024/04/29 11:41:12 [govips.info] registered image type loader type=magick
        2024/04/29 11:41:12 [govips.info] registered image type loader type=pdf
        2024/04/29 11:41:12 [govips.info] registered image type loader type=png
        2024/04/29 11:41:12 [govips.info] registered image type loader type=webp
        2024/04/29 11:41:12 [govips.info] registered image type loader type=jp2k
        2024/04/29 11:41:12 [govips.info] registered image type loader type=gif

Logs (Gin Backend Server):

2024/04/30 05:45:51 [govips.info] vips 8.15.0 started with concurrency=1 cache_max_files=0 cache_max_mem=52428800 cache_max=100
2024/04/30 05:45:51 [govips.info] registered image type loader type=tiff
2024/04/30 05:45:51 [govips.info] registered image type loader type=webp
2024/04/30 05:45:51 [govips.info] registered image type loader type=heif
2024/04/30 05:45:51 [govips.info] registered image type loader type=gif
2024/04/30 05:45:51 [govips.info] registered image type loader type=magick
2024/04/30 05:45:51 [govips.info] registered image type loader type=svg
2024/04/30 05:45:51 [govips.info] registered image type loader type=heif
2024/04/30 05:45:51 [govips.info] registered image type loader type=jp2k
2024/04/30 05:45:51 [govips.info] registered image type loader type=jpeg
2024/04/30 05:45:51 [govips.info] registered image type loader type=pdf
2024/04/30 05:45:51 [govips.info] registered image type loader type=png
tonimelisma commented 7 months ago

Hey @ishdutt I feel like this is probably an issue with your environment, not govips? What libjpeg is being linked, can you check ldd etc and what's installed in the environment?

ishdutt commented 7 months ago

@tonimelisma yeah most probably it's because of libvips package installed on Ubuntu. Since we are getting same error when using this package https://github.com/h2non/bimg which internally uses libvips. These are the version of packages being used:

Vips version: vips-8.15.0
Operating System: Ubuntu 22.04.1 arm64
Go version: go1.22.2

This is ldd for vips package:

        linux-vdso.so.1 (0x0000ffff8e25b000)
        libvips.so.42 => /usr/local/lib/aarch64-linux-gnu/libvips.so.42 (0x0000ffff8dcd0000)
        libglib-2.0.so.0 => /lib/aarch64-linux-gnu/libglib-2.0.so.0 (0x0000ffff8db80000)
        libgobject-2.0.so.0 => /lib/aarch64-linux-gnu/libgobject-2.0.so.0 (0x0000ffff8db00000)
        libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000ffff8d950000)
        /lib/ld-linux-aarch64.so.1 (0x0000ffff8e222000)
        libgio-2.0.so.0 => /lib/aarch64-linux-gnu/libgio-2.0.so.0 (0x0000ffff8d750000)
        libgmodule-2.0.so.0 => /lib/aarch64-linux-gnu/libgmodule-2.0.so.0 (0x0000ffff8d730000)
        libexpat.so.1 => /lib/aarch64-linux-gnu/libexpat.so.1 (0x0000ffff8d6f0000)
        libz.so.1 => /lib/aarch64-linux-gnu/libz.so.1 (0x0000ffff8d6c0000)
        libfftw3.so.3 => /lib/aarch64-linux-gnu/libfftw3.so.3 (0x0000ffff8d5f0000)
        libcfitsio.so.9 => /lib/aarch64-linux-gnu/libcfitsio.so.9 (0x0000ffff8d2f0000)
        libimagequant.so.0 => /lib/aarch64-linux-gnu/libimagequant.so.0 (0x0000ffff8d2d0000)
        libcgif.so.0 => /lib/aarch64-linux-gnu/libcgif.so.0 (0x0000ffff8d2b0000)
        libexif.so.12 => /lib/aarch64-linux-gnu/libexif.so.12 (0x0000ffff8d250000)
        libjpeg.so.8 => /lib/aarch64-linux-gnu/libjpeg.so.8 (0x0000ffff8d1f0000)
        libpng16.so.16 => /lib/aarch64-linux-gnu/libpng16.so.16 (0x0000ffff8d1a0000)
        libwebp.so.7 => /lib/aarch64-linux-gnu/libwebp.so.7 (0x0000ffff8d140000)
        libwebpmux.so.3 => /lib/aarch64-linux-gnu/libwebpmux.so.3 (0x0000ffff8d120000)
        libwebpdemux.so.2 => /lib/aarch64-linux-gnu/libwebpdemux.so.2 (0x0000ffff8d100000)
        libpangocairo-1.0.so.0 => /lib/aarch64-linux-gnu/libpangocairo-1.0.so.0 (0x0000ffff8d0e0000)
        libpango-1.0.so.0 => /lib/aarch64-linux-gnu/libpango-1.0.so.0 (0x0000ffff8d060000)
        libcairo.so.2 => /lib/aarch64-linux-gnu/libcairo.so.2 (0x0000ffff8cf30000)
        libpangoft2-1.0.so.0 => /lib/aarch64-linux-gnu/libpangoft2-1.0.so.0 (0x0000ffff8cf00000)
        libfontconfig.so.1 => /lib/aarch64-linux-gnu/libfontconfig.so.1 (0x0000ffff8cea0000)
        libtiff.so.5 => /lib/aarch64-linux-gnu/libtiff.so.5 (0x0000ffff8ce00000)
        librsvg-2.so.2 => /lib/aarch64-linux-gnu/librsvg-2.so.2 (0x0000ffff8c460000)
        libmatio.so.11 => /lib/aarch64-linux-gnu/libmatio.so.11 (0x0000ffff8c3e0000)
        liblcms2.so.2 => /lib/aarch64-linux-gnu/liblcms2.so.2 (0x0000ffff8c370000)
        libIlmImf-2_5.so.25 => /lib/aarch64-linux-gnu/libIlmImf-2_5.so.25 (0x0000ffff8c0b0000)
        libopenjp2.so.7 => /lib/aarch64-linux-gnu/libopenjp2.so.7 (0x0000ffff8c040000)
        liborc-0.4.so.0 => /lib/aarch64-linux-gnu/liborc-0.4.so.0 (0x0000ffff8bfa0000)
        libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000ffff8bf00000)
        libgcc_s.so.1 => /lib/aarch64-linux-gnu/libgcc_s.so.1 (0x0000ffff8bed0000)
        libpcre.so.3 => /lib/aarch64-linux-gnu/libpcre.so.3 (0x0000ffff8be50000)
        libffi.so.8 => /lib/aarch64-linux-gnu/libffi.so.8 (0x0000ffff8be30000)
        libmount.so.1 => /lib/aarch64-linux-gnu/libmount.so.1 (0x0000ffff8bdd0000)
        libselinux.so.1 => /lib/aarch64-linux-gnu/libselinux.so.1 (0x0000ffff8bd90000)
        libcurl-gnutls.so.4 => /lib/aarch64-linux-gnu/libcurl-gnutls.so.4 (0x0000ffff8bce0000)
        libbz2.so.1.0 => /lib/aarch64-linux-gnu/libbz2.so.1.0 (0x0000ffff8bcb0000)
        libgomp.so.1 => /lib/aarch64-linux-gnu/libgomp.so.1 (0x0000ffff8bc50000)
        libharfbuzz.so.0 => /lib/aarch64-linux-gnu/libharfbuzz.so.0 (0x0000ffff8bb70000)
        libfribidi.so.0 => /lib/aarch64-linux-gnu/libfribidi.so.0 (0x0000ffff8bb40000)
        libthai.so.0 => /lib/aarch64-linux-gnu/libthai.so.0 (0x0000ffff8bb20000)
        libpixman-1.so.0 => /lib/aarch64-linux-gnu/libpixman-1.so.0 (0x0000ffff8baa0000)
        libfreetype.so.6 => /lib/aarch64-linux-gnu/libfreetype.so.6 (0x0000ffff8b9d0000)
        libxcb-shm.so.0 => /lib/aarch64-linux-gnu/libxcb-shm.so.0 (0x0000ffff8b9b0000)
        libxcb.so.1 => /lib/aarch64-linux-gnu/libxcb.so.1 (0x0000ffff8b970000)
        libxcb-render.so.0 => /lib/aarch64-linux-gnu/libxcb-render.so.0 (0x0000ffff8b950000)
        libXrender.so.1 => /lib/aarch64-linux-gnu/libXrender.so.1 (0x0000ffff8b930000)
        libX11.so.6 => /lib/aarch64-linux-gnu/libX11.so.6 (0x0000ffff8b7e0000)
        libXext.so.6 => /lib/aarch64-linux-gnu/libXext.so.6 (0x0000ffff8b7b0000)
        libuuid.so.1 => /lib/aarch64-linux-gnu/libuuid.so.1 (0x0000ffff8b790000)
        libzstd.so.1 => /lib/aarch64-linux-gnu/libzstd.so.1 (0x0000ffff8b6c0000)
        liblzma.so.5 => /lib/aarch64-linux-gnu/liblzma.so.5 (0x0000ffff8b680000)
        libjbig.so.0 => /lib/aarch64-linux-gnu/libjbig.so.0 (0x0000ffff8b660000)
        libdeflate.so.0 => /lib/aarch64-linux-gnu/libdeflate.so.0 (0x0000ffff8b630000)
        libcairo-gobject.so.2 => /lib/aarch64-linux-gnu/libcairo-gobject.so.2 (0x0000ffff8b610000)
        libgdk_pixbuf-2.0.so.0 => /lib/aarch64-linux-gnu/libgdk_pixbuf-2.0.so.0 (0x0000ffff8b5d0000)
        libxml2.so.2 => /lib/aarch64-linux-gnu/libxml2.so.2 (0x0000ffff8b3e0000)
        libhdf5_serial.so.103 => /lib/aarch64-linux-gnu/libhdf5_serial.so.103 (0x0000ffff8b010000)
        libImath-2_5.so.25 => /lib/aarch64-linux-gnu/libImath-2_5.so.25 (0x0000ffff8afe0000)
        libIlmThread-2_5.so.25 => /lib/aarch64-linux-gnu/libIlmThread-2_5.so.25 (0x0000ffff8afc0000)
        libHalf-2_5.so.25 => /lib/aarch64-linux-gnu/libHalf-2_5.so.25 (0x0000ffff8af60000)
        libIex-2_5.so.25 => /lib/aarch64-linux-gnu/libIex-2_5.so.25 (0x0000ffff8aed0000)
        libstdc++.so.6 => /lib/aarch64-linux-gnu/libstdc++.so.6 (0x0000ffff8aca0000)
        libblkid.so.1 => /lib/aarch64-linux-gnu/libblkid.so.1 (0x0000ffff8ac50000)
        libpcre2-8.so.0 => /lib/aarch64-linux-gnu/libpcre2-8.so.0 (0x0000ffff8abb0000)
        libnghttp2.so.14 => /lib/aarch64-linux-gnu/libnghttp2.so.14 (0x0000ffff8ab70000)
        libidn2.so.0 => /lib/aarch64-linux-gnu/libidn2.so.0 (0x0000ffff8ab40000)
        librtmp.so.1 => /lib/aarch64-linux-gnu/librtmp.so.1 (0x0000ffff8ab10000)
        libssh.so.4 => /lib/aarch64-linux-gnu/libssh.so.4 (0x0000ffff8aa90000)
        libpsl.so.5 => /lib/aarch64-linux-gnu/libpsl.so.5 (0x0000ffff8aa60000)
        libnettle.so.8 => /lib/aarch64-linux-gnu/libnettle.so.8 (0x0000ffff8aa00000)
        libgnutls.so.30 => /lib/aarch64-linux-gnu/libgnutls.so.30 (0x0000ffff8a7f0000)
        libgssapi_krb5.so.2 => /lib/aarch64-linux-gnu/libgssapi_krb5.so.2 (0x0000ffff8a790000)
        libldap-2.5.so.0 => /lib/aarch64-linux-gnu/libldap-2.5.so.0 (0x0000ffff8a720000)
        liblber-2.5.so.0 => /lib/aarch64-linux-gnu/liblber-2.5.so.0 (0x0000ffff8a700000)
        libbrotlidec.so.1 => /lib/aarch64-linux-gnu/libbrotlidec.so.1 (0x0000ffff8a6e0000)
        libgraphite2.so.3 => /lib/aarch64-linux-gnu/libgraphite2.so.3 (0x0000ffff8a6b0000)
        libdatrie.so.1 => /lib/aarch64-linux-gnu/libdatrie.so.1 (0x0000ffff8a690000)
        libXau.so.6 => /lib/aarch64-linux-gnu/libXau.so.6 (0x0000ffff8a670000)
        libXdmcp.so.6 => /lib/aarch64-linux-gnu/libXdmcp.so.6 (0x0000ffff8a650000)
        libicuuc.so.70 => /lib/aarch64-linux-gnu/libicuuc.so.70 (0x0000ffff8a440000)
        libcrypto.so.3 => /lib/aarch64-linux-gnu/libcrypto.so.3 (0x0000ffff8a050000)
        libcurl.so.4 => /lib/aarch64-linux-gnu/libcurl.so.4 (0x0000ffff89fa0000)
        libsz.so.2 => /lib/aarch64-linux-gnu/libsz.so.2 (0x0000ffff89f80000)
        libunistring.so.2 => /lib/aarch64-linux-gnu/libunistring.so.2 (0x0000ffff89dc0000)
        libhogweed.so.6 => /lib/aarch64-linux-gnu/libhogweed.so.6 (0x0000ffff89d60000)
        libgmp.so.10 => /lib/aarch64-linux-gnu/libgmp.so.10 (0x0000ffff89cd0000)
        libp11-kit.so.0 => /lib/aarch64-linux-gnu/libp11-kit.so.0 (0x0000ffff89b80000)
        libtasn1.so.6 => /lib/aarch64-linux-gnu/libtasn1.so.6 (0x0000ffff89b50000)
        libkrb5.so.3 => /lib/aarch64-linux-gnu/libkrb5.so.3 (0x0000ffff89a70000)
        libk5crypto.so.3 => /lib/aarch64-linux-gnu/libk5crypto.so.3 (0x0000ffff89a30000)
        libcom_err.so.2 => /lib/aarch64-linux-gnu/libcom_err.so.2 (0x0000ffff89a10000)
        libkrb5support.so.0 => /lib/aarch64-linux-gnu/libkrb5support.so.0 (0x0000ffff899f0000)
        libsasl2.so.2 => /lib/aarch64-linux-gnu/libsasl2.so.2 (0x0000ffff899c0000)
        libbrotlicommon.so.1 => /lib/aarch64-linux-gnu/libbrotlicommon.so.1 (0x0000ffff89980000)
        libbsd.so.0 => /lib/aarch64-linux-gnu/libbsd.so.0 (0x0000ffff89950000)
        libicudata.so.70 => /lib/aarch64-linux-gnu/libicudata.so.70 (0x0000ffff87d20000)
        libssl.so.3 => /lib/aarch64-linux-gnu/libssl.so.3 (0x0000ffff87c70000)
        libaec.so.0 => /lib/aarch64-linux-gnu/libaec.so.0 (0x0000ffff87c50000)
        libkeyutils.so.1 => /lib/aarch64-linux-gnu/libkeyutils.so.1 (0x0000ffff87c30000)
        libresolv.so.2 => /lib/aarch64-linux-gnu/libresolv.so.2 (0x0000ffff87c00000)
        libmd.so.0 => /lib/aarch64-linux-gnu/libmd.so.0 (0x0000ffff87be0000)
tonimelisma commented 7 months ago

Right. I'd look more into the environment. I'm closing this for now since it doesn't seem to be an issue with govips.