[racket] Possibility of speeding up Scribble to PDF when there's lots of images?

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Jan 6 08:54:05 EST 2014

How are the images produced in your Scribble program/document?

If you're referencing ".png" files via `image`, then if you could just
reference ".pdf" files instead. In particular, you could write `image*`
that converts a ".png" to ".pdf" and calls `image`.

If you're generating bitmaps some other way, the right change may be to
generate a value that is convertable to 'pdf-bytres instead of just
'png-bytes, since the Latex/PDF renderer tries 'pdf-bytes before
'png-bytes.


If you'd like to experiment with changing Scribble, see

  scribble-pkgs/scribble-lib/scribble/latex-render.rkt

in the Racket repository, around line 342. You could add a convert of
PNG to PDF via using `pdf-dc%`.


At Mon, 6 Jan 2014 16:09:57 +1100, Daniel Prager wrote:
> As I've added more and more images to my Scribble output I've noticed
> empirically a considerable slowdown.
> 
> Currently it takes around 56 seconds to process my main file (which
> includes around 36 figures); 8 seconds when I commented out all the images.
> 
> In hunting for the main bottleneck I came across this post --
> http://tex.stackexchange.com/questions/39929/fast-png-embedding-using-pdflatex--
> which says "PNG are recompressed during the pdfTeX run in general, but
> in some cases, a direct copy is possible, which is much faster".
> 
> Conditions are given under which pngs recompression should not be induced,
> but a straightforward albeit indirect alternative method is also suggested
> -- use "convert" (part of ImgeMagick) to pre-process the pngs into pdfs. A
> quick test of the latter with a single image gave me a speedup using
> Scribble from around 3.2s with straight inclusion of a png to 2.8s
> including a pre-processed pdf of the same image (pre-processing with
> convert is very fast, btw), suggesting that this may well be a significant
> source of slow-down.
> 
> Now, based on this I expect that I'll be able to get a reasonable speed-up
> by saving out pngs, convert-ing them, and @image{}-ing the files back into
> my Scribble, but I was wondering whether someone might have other tips
> and/or whether there's any prospect of snappier image inclusion in the
> standard pipeline: e.g. by ensuring that pngs are output in a format that
> isn't recompressed or incorporating the convert trick into the conventional
> Scribble to pdf pipeline.
> 
> 
> Thanks
> 
> Dan
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

Posted on the users mailing list.