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

Corrupted vipsthumbnail image #1807

Closed
adamu opened this issue Sep 4, 2020 · 3 comments
Closed

Corrupted vipsthumbnail image #1807

adamu opened this issue Sep 4, 2020 · 3 comments
Labels

Comments

@adamu
Copy link

adamu commented Sep 4, 2020

I'm seeing vipsthumbnail produce valid but obviously incorrect thumbnails for some SVS files. Strangely, it only seems to apply when running in an Alpine container. Running the same command with the same vips version on OSX is working fine.

Here's an example of an incorrect thumbnail (blue rectangle added by me to hide medical data). The white areas directly above and to the left of the rectangle are incorrect and not in the original image:

image

Unfortunately I can't provide the original image here.

To Reproduce
Dockerfile:

FROM openjdk:14-alpine

ARG OPENSLIDE_VERSION=3.4.1
ARG VIPS_VERSION=8.10.0

WORKDIR /root

RUN apk add --virtual build-deps build-base zlib-dev libpng-dev jpeg-dev tiff-dev openjpeg-dev gdk-pixbuf-dev \
    sqlite-dev cairo-dev libxml2-dev libgsf-dev libexif-dev \
    # Download, build, and install Openslide
    && wget https://github.com/openslide/openslide/releases/download/v$OPENSLIDE_VERSION/openslide-$OPENSLIDE_VERSION.tar.gz \
    && tar xzf openslide-$OPENSLIDE_VERSION.tar.gz \
    && cd openslide-$OPENSLIDE_VERSION && ./configure && make && make install && cd .. && rm -rf openslide-$OPENSLIDE_VERSION* \
    # Download, build, and install Vips
    && wget https://github.com/libvips/libvips/releases/download/v$VIPS_VERSION/vips-$VIPS_VERSION.tar.gz \
    && tar xzf vips-$VIPS_VERSION.tar.gz \
    && cd vips-$VIPS_VERSION && ./configure && make V=0 && make && make install && cd .. && rm -rf vips-$VIPS_VERSION* \
    # Cleanup build deps
    && apk del build-deps \
    # Add runtime deps
    && apk add --virtual run-deps zlib libpng jpeg tiff openjpeg gdk-pixbuf sqlite-libs cairo libxml2 libgsf libexif

ENTRYPOINT "/bin/sh"
  1. docker build -t weird_thumbnail:latest .
  2. docker run -it weird_thumbnail:latest
  3. Copy svs to docker container
  4. vipsthumbnail --size=512 -o %s-thumbnail.jpg weird_thumbnail.svs

Additional context
I'm not sure how to provide enough useful information without the original image. Maybe I could email a download link (but I'll need to check if that's possible first). Here are the operation cache dumps:

Working on OSX (produces good thumbnail):

Operation cache:
0x7fcf7805a4f0 - openslideload("weird_thumbnail.svs",((VipsImage*) 0x7fcf7881b1b0),nickname="openslideload",description="load file with OpenSlide",flags=((VipsForeignFlags) VIPS_FOREIGN_PARTIAL))
0x7fcf78076ff0 - embed(((VipsImage*) 0x7fcf7881bca0),((VipsImage*) 0x7fcf7885c320),0,0,2149,669,nickname="embed",description="embed an image in a larger image",extend=((VipsExtend) VIPS_EXTEND_COPY))
0x7fcf78092cb0 - resize(((VipsImage*) 0x7fcf7881b660),((VipsImage*) 0x7fcf7881b980),0.238472,nickname="resize",description="resize an image",vscale=0.238472)
0x7fcf78065130 - colourspace(((VipsImage*) 0x7fcf7881b340),((VipsImage*) 0x7fcf7881b4d0),((VipsInterpretation) VIPS_INTERPRETATION_sRGB),nickname="colourspace",description="convert to a new colorspace")
0x7fcf78091200 - reduceh(((VipsImage*) 0x7fcf7885c4b0),((VipsImage*) 0x7fcf7885caf0),1.000000,2.096680,nickname="reduceh",description="shrink an image horizontally",kernel=((VipsKernel) VIPS_KERNEL_LANCZOS3))
0x7fcf78097650 - unpremultiply(((VipsImage*) 0x7fcf7881b980),((VipsImage*) 0x7fcf78863020),nickname="unpremultiply",description="unpremultiply image alpha")
0x7fcf780a8200 - cast(((VipsImage*) 0x7fcf78863980),((VipsImage*) 0x7fcf78863ca0),((VipsBandFormat) VIPS_FORMAT_UCHAR),nickname="cast",description="cast an image")
0x7fcf78078960 - shrinkh(((VipsImage*) 0x7fcf7881bca0),((VipsImage*) 0x7fcf7885c190),1,2,nickname="shrinkh",description="shrink an image horizontally")
0x7fcf780a5d70 - flatten(((VipsImage*) 0x7fcf788637f0),((VipsImage*) 0x7fcf78863980),nickname="flatten",background=0 ,description="flatten alpha out of an image")
0x7fcf76c197c0 - tilecache(((VipsImage*) 0x7fcf788694d0),((VipsImage*) 0x7fcf78869660),nickname="tilecache",description="cache an image as a set of tiles",tile-width=240,tile-height=240,max-tiles=22,threaded=TRUE)
0x7fcf78073f80 - shrinkv(((VipsImage*) 0x7fcf7881bb10),((VipsImage*) 0x7fcf7881bca0),1,2,nickname="shrinkv",description="shrink an image vertically")
0x7fcf780a0d90 - colourspace(((VipsImage*) 0x7fcf78863660),((VipsImage*) 0x7fcf788637f0),((VipsInterpretation) VIPS_INTERPRETATION_sRGB),nickname="colourspace",description="convert to a new colorspace")
0x7fcf7809bee0 - cast(((VipsImage*) 0x7fcf78863020),((VipsImage*) 0x7fcf78863340),((VipsBandFormat) VIPS_FORMAT_UCHAR),nickname="cast",description="cast an image")
0x7fcf78080e80 - embed(((VipsImage*) 0x7fcf7885c640),((VipsImage*) 0x7fcf7885c7d0),0,5,1074,682,nickname="embed",description="embed an image in a larger image",extend=((VipsExtend) VIPS_EXTEND_COPY))
0x7fcf780703c0 - embed(((VipsImage*) 0x7fcf7881bb10),((VipsImage*) 0x7fcf7881be30),0,0,2147,1338,nickname="embed",description="embed an image in a larger image",extend=((VipsExtend) VIPS_EXTEND_COPY))
0x7fcf7808f7a0 - embed(((VipsImage*) 0x7fcf7885cc80),((VipsImage*) 0x7fcf7885ce10),5,0,1087,319,nickname="embed",description="embed an image in a larger image",extend=((VipsExtend) VIPS_EXTEND_COPY))
0x7fcf780848e0 - reducev(((VipsImage*) 0x7fcf7885c190),((VipsImage*) 0x7fcf7885c4b0),1.000000,2.096680,nickname="reducev",description="shrink an image vertically",kernel=((VipsKernel) VIPS_KERNEL_LANCZOS3))
0x7fcf78069c00 - premultiply(((VipsImage*) 0x7fcf7881b4d0),((VipsImage*) 0x7fcf7881b660),nickname="premultiply",description="premultiply image alpha")
0x7fcf780629d0 - openslideload("weird_thumbnail.svs",((VipsImage*) 0x7fcf7881b340),nickname="openslideload",description="load file with OpenSlide",level=3,flags=((VipsForeignFlags) VIPS_FOREIGN_PARTIAL),access=((VipsAccess) VIPS_ACCESS_SEQUENTIAL))

Not working on Alpine Docker container (produces bad thumbnail):

vipsthumbnail --vips-cache-dump --size=512 -o %s-thumbnail.jpg weird_thumbnail.svs
Operation cache:
0x5617a580b220 - reducev(((VipsImage*) 0x5617a57e51a0),((VipsImage*) 0x5617a57e54c0),1.000000,2.096680,nickname="reducev",description="shrink an image vertically",kernel=((VipsKernel) VIPS_KERNEL_LANCZOS3))
0x5617a57f6340 - embed(((VipsImage*) 0x5617a5731c90),((VipsImage*) 0x5617a57e5330),0,0,2149,669,nickname="embed",description="embed an image in a larger image",extend=((VipsExtend) VIPS_EXTEND_COPY))
0x5617a57f8b80 - shrinkh(((VipsImage*) 0x5617a5731c90),((VipsImage*) 0x5617a57e51a0),1,2,nickname="shrinkh",description="shrink an image horizontally")
0x5617a57bc760 - openslideload("weird_thumbnail.svs",((VipsImage*) 0x5617a57311a0),nickname="openslideload",description="load file with OpenSlide",flags=((VipsForeignFlags) VIPS_FOREIGN_PARTIAL))
0x5617a5820ee0 - resize(((VipsImage*) 0x5617a5731650),((VipsImage*) 0x5617a5731970),0.238472,nickname="resize",description="resize an image",vscale=0.238472)
0x5617a583af60 - colourspace(((VipsImage*) 0x5617a5822640),((VipsImage*) 0x5617a58227d0),((VipsInterpretation) VIPS_INTERPRETATION_sRGB),nickname="colourspace",description="convert to a new colorspace")
0x5617a5842fe0 - flatten(((VipsImage*) 0x5617a58227d0),((VipsImage*) 0x5617a5822960),nickname="flatten",background=0 ,description="flatten alpha out of an image")
0x5617a5831920 - cast(((VipsImage*) 0x5617a5822000),((VipsImage*) 0x5617a5822320),((VipsBandFormat) VIPS_FORMAT_UCHAR),nickname="cast",description="cast an image")
0x5617a57f20c0 - shrinkv(((VipsImage*) 0x5617a5731b00),((VipsImage*) 0x5617a5731c90),1,2,nickname="shrinkv",description="shrink an image vertically")
0x5617a581e840 - reduceh(((VipsImage*) 0x5617a57e54c0),((VipsImage*) 0x5617a57e5b00),1.000000,2.096680,nickname="reduceh",description="shrink an image horizontally",kernel=((VipsKernel) VIPS_KERNEL_LANCZOS3))
0x5617a57ec840 - embed(((VipsImage*) 0x5617a5731b00),((VipsImage*) 0x5617a5731e20),0,0,2147,1338,nickname="embed",description="embed an image in a larger image",extend=((VipsExtend) VIPS_EXTEND_COPY))
0x5617a581c200 - embed(((VipsImage*) 0x5617a57e5c90),((VipsImage*) 0x5617a57e5e20),5,0,1087,319,nickname="embed",description="embed an image in a larger image",extend=((VipsExtend) VIPS_EXTEND_COPY))
0x5617a5805d00 - embed(((VipsImage*) 0x5617a57e5650),((VipsImage*) 0x5617a57e57e0),0,5,1074,682,nickname="embed",description="embed an image in a larger image",extend=((VipsExtend) VIPS_EXTEND_COPY))
0x5617a57df480 - premultiply(((VipsImage*) 0x5617a57314c0),((VipsImage*) 0x5617a5731650),nickname="premultiply",description="premultiply image alpha")
0x5617a582ace0 - unpremultiply(((VipsImage*) 0x5617a5731970),((VipsImage*) 0x5617a5822000),nickname="unpremultiply",description="unpremultiply image alpha")
0x5617a57ca120 - openslideload("weird_thumbnail.svs",((VipsImage*) 0x5617a5731330),nickname="openslideload",description="load file with OpenSlide",level=3,flags=((VipsForeignFlags) VIPS_FOREIGN_PARTIAL),access=((VipsAccess) VIPS_ACCESS_SEQUENTIAL))
0x5617a57d79a0 - colourspace(((VipsImage*) 0x5617a5731330),((VipsImage*) 0x5617a57314c0),((VipsInterpretation) VIPS_INTERPRETATION_sRGB),nickname="colourspace",description="convert to a new colorspace")
0x5617a5847b20 - cast(((VipsImage*) 0x5617a5822960),((VipsImage*) 0x5617a5822c80),((VipsBandFormat) VIPS_FORMAT_UCHAR),nickname="cast",description="cast an image")
0x5617a5cfdf40 - tilecache(((VipsImage*) 0x5617a58444b0),((VipsImage*) 0x5617a5844640),nickname="tilecache",description="cache an image as a set of tiles",tile-width=240,tile-height=240,max-tiles=22,threaded=TRUE)
@adamu adamu added the bug label Sep 4, 2020
@jcupitt
Copy link
Member

jcupitt commented Sep 4, 2020

Hi @adamu,

It looks like you've been bitten by this bug:

#1401

tldr: update pixman to 0.40 or later.

@jcupitt jcupitt added question and removed bug labels Sep 4, 2020
@adamu
Copy link
Author

adamu commented Sep 4, 2020

@jcupitt you're a legend! Tried it on an Alpine 3.12 image which has pixman 0.40 in the package manager, and the thumbnail was fine 🎉

Unfortunately the JDK 14 image I'm using is on Alpine 3.10 which only has pixman 0.38 available, so I'll have to work around that.

Thanks for the prompt help as always!

@adamu adamu closed this as completed Sep 4, 2020
@jcupitt
Copy link
Member

jcupitt commented Sep 4, 2020

Kleis found the bug, not me! But I'm glad it's working.

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

No branches or pull requests

2 participants