skip to Main Content

I’m converting a tif file to pdf with imagemagick:

Imagemagick version: 7.1.0-13

Imagemagick command: magick convert -density 80 -page a4 -limit map 3GB -limit memory 3GB tiff:- pdf:-

This has been working good until meeting this guy:
https://drive.google.com/file/d/1AJjN8F2RoKViE56ZE7I9XDYTJ-HefUaA/view

Which converted it to this pdf:
https://drive.google.com/file/d/1C3Dfd7fGvgJFqJwKbOoLPB-om80gc3PP/view

Now if you view the result on a browser, like chrome, you see multiple empty pages:
enter image description here

However opening the file with adobe reader I get this instead:

enter image description here

And what it’s weird, with vs studio, the file looks good:
enter image description here

For viewing the pdf on visual studio I’m using this extension:
enter image description here

Now the question is, how do I fix this?

[edited] Even after upgrading the library it doesn’t work, maybe missing dependency?
OP: debian

DockerFile building the image:

FROM debian
WORKDIR /usr/src/app
RUN apt-get update -qq &&
  apt-get install -y -qq 
  chrpath debhelper dh-exec dpkg-dev g++ ghostscript gsfonts libbz2-dev 
  libdjvulibre-dev libexif-dev libfftw3-dev libfontconfig1-dev libfreetype6-dev 
  libjpeg-dev liblcms2-dev liblqr-1-0-dev libltdl-dev liblzma-dev libopenexr-dev 
  libpango1.0-dev libperl-dev libpng-dev librsvg2-bin librsvg2-dev libtiff-dev libwebp-dev 
  libwmf-dev libx11-dev libxext-dev libxml2-dev libxt-dev pkg-config pkg-kde-tools zlib1g-dev
RUN apt-get install wget 
# Install ImageMagick Platform-independent build dependencies
RUN apt-get update -qq &&
  apt-get install -y -qq 
  doxygen doxygen-latex graphviz jdupes libxml2-utils xsltproc
# Install and Configure ImageMagick
RUN wget https://github.com/ImageMagick/ImageMagick/archive/refs/tags/7.1.0-28.tar.gz -P /opt
RUN tar xvf /opt/7.1.0-28.tar.gz -C /opt
RUN /opt/ImageMagick-7.1.0-28/configure --with-modules --enable-shared
RUN make -j 2 /opt/ImageMagick-7.1.0-28
RUN make install /opt/ImageMagick-7.1.0-28/
RUN make distclean
RUN ldconfig /usr/local/lib
RUN rm /opt/7.1.0-28.tar.gz
[edited 2] libtiff version: 4.2.0-1
enter image description here

2

Answers


  1. Chosen as BEST ANSWER

    It was ImageMagick's bug. They fixed it on the new version https://github.com/ImageMagick/ImageMagick/issues/5256#event-6929844600


  2. In IM 7, use magick not magick convert. Add +repage after reading the TIFF

    magick input2.tif[0] +repage -density 80 -page a4 input2.pdf
    

    works fine for me on IM 7.1.0.28 Q16 Mac OSX Sierra.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search