tif to pdf 400 pages: WritePDFImage: Assertion `image->exception.reason != (const char *) ((void *)0)' failed.

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
User avatar
qubodup
Posts: 31
Joined: 2009-10-07T13:11:41-07:00
Authentication code: 8675309

tif to pdf 400 pages: WritePDFImage: Assertion `image->exception.reason != (const char *) ((void *)0)' failed.

Post by qubodup »

Hello,

I get this error

Code: Select all

convert: coders/pdf.c:1814: WritePDFImage: Assertion `image->exception.reason != (const char *) ((void *)0)' failed.
Aborted
when I try to convert 400 tif files to a pdf via

Code: Select all

convert -limit memory 2gb -limit map 2gb -density 300 *tif -compress jpeg -quality 100 400.pdf
on Arch Linux with ImageMagick 6.9.1-10 Q16 x86_64 2015-08-05 on Arch Linux.

Any ideas why this is? Is my use not appropriate? Does anybody have suggestions for alternatives to create large jpeg-compressed pdf files from tif images on Linux?

PS: the commands are based on suggestions from viewtopic.php?t=23225

PPS:If I do:

Code: Select all

for i in *tif; do convert -density 300 $i -compress jpeg -quality 100 $i.jpg; echo $i done; done
pdfjoin *jpg 400.pdf
Then it fails on the second part with

Code: Select all

  pdfjam: Calling pdflatex...
  pdfjam: FAILED.
          The call to 'pdflatex' resulted in an error.
          If '--no-tidy' was used, you can examine the
          log file at
                  /var/tmp/pdfjam-ass4wk/a.log
          to try to diagnose the problem.
  pdfjam ERROR: Output file not written
Last edited by qubodup on 2015-08-12T00:15:26-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: tif to pdf 400 pages: WritePDFImage: Assertion `image->exception.reason != (const char *) ((void *)0)' failed.

Post by fmw42 »

Suggestion, see if it happens if you use some other compression method. Also is there a smaller limited number of input files that work?
User avatar
qubodup
Posts: 31
Joined: 2009-10-07T13:11:41-07:00
Authentication code: 8675309

Re: tif to pdf 400 pages: WritePDFImage: Assertion `image->exception.reason != (const char *) ((void *)0)' failed.

Post by qubodup »

fmw42 wrote:Suggestion, see if it happens if you use some other compression method. Also is there a smaller limited number of input files that work?
Thank you for suggesting this!

Trying around...

Converting 404 (7GB in total) .tif files to .pdf with zip compression:

Code: Select all

convert -density 300 -limit memory 0 -limit map 0 *tif -compress zip tif2zip.pdf
convert: unable to extend cache `in9192.tif': No space left on device @ error/cache.c/OpenPixelCache/3719.
convert: unable to extend cache `in9193.tif': No space left on device @ error/cache.c/OpenPixelCache/3719.
[...]
this is with /tmp/ being 4.0G in size.

If I run it as

Code: Select all

MAGICK_TMPDIR=/home/qubodup/it/ convert -density 300 -limit memory 0 -limit map 0 *tif -compress zip tif2zip.pdf
while having 43G available, it will also run out of size.

Converting 404 Gray & sRGB jpeg files (size: 3923x4557) between 0.5 and 9MB in size each, 2.7G total.

Code: Select all

$ convert -density 300 *jpg -compress zip jpgtozip.pdf
Killed
Another try:

Code: Select all

convert -density 300 -limit memory 0 -limit map 0 *jpg -compress none jpg2none.pdf
convert: unable to extend cache `in9192.tif': No space left on device @ error/cache.c/OpenPixelCache/3719.
[...]
It seems like all these messages just indicate running out of storage space, although only the zip compression seems to give a clear error message.

Solution

The end result file would probably be too huge for me, so rather than trying to work with subsets, I scaled down the images to 1961x2278 and converted them to pdf with jpeg or zip compression, based on their colorspace (jpeg seems to be ineffective for greyscale b/w) and then merged into one pdf file successfuly using pdfjoin

Code: Select all

for file in *tif; do
  FORMAT=`identify -format %[colorspace] $file`
  if [ $FORMAT = "Gray" ]; then
    COMPRESSION=zip
  else
    COMPRESSION=jpeg
  fi
  convert $file -density 72 -compress $COMPRESSION $file.pdf
  echo $file done
done

pdfjoin --outfile 404pages.pdf *pdf
The size of all tif files is 2042M.
The size of all pdf files is 275M.
The joined pdf size file is 272M.
Post Reply