xqms / graphicscache

Caching & DPI control for the LaTeX graphicx package
BSD 3-Clause "New" or "Revised" License
10 stars 5 forks source link

Error on MacOs BigSur -- GhostScript 9.54.0 #18

Closed Opware2000 closed 2 years ago

Opware2000 commented 3 years ago

Hello. With the default options (\usepackage{graphicscache}) I have an error related to the cache system not found (?) by ghostscript.

Rendering 710A59C3B41DD70E4A7F6B4218E0AC78: icons/evergreen-tree.png with args: width=50.0pt (master file) With compression: DCTEncodeError: /undefined in .setpdfwrite
Operand stack:

Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--
Dictionary stack:
   --dict:729/1123(ro)(G)--   --dict:0/20(G)--   --dict:75/200(L)--
Current allocation mode is local
GPL Ghostscript 9.54.0: Unrecoverable error, exit code 1

This error is not present if I use the option [compress=false] (for example during a second compilation) I have as expected the PDF file in cache

Already have 2FD5CFBA3068AF6DA012FDB8E89DF0B1: icons/evergreen-tree.png

OS : macOs Big Sur GhostScript version 9.54.0 (installed via HomeBrew)

Opware2000 commented 3 years ago

I forgot to mention that I compile with XeLaTeX (and of course with -shell-escape)

xqms commented 3 years ago

Hey, thanks for the report!

This is probably because the .setpdfwrite operator has been removed from GhostScript (see for example https://github.com/GravityMedia/Ghostscript/issues/6). It seems it's not really necessary anyway, so I'll look into dropping it.

It's interesting that you can compile with XeLaTeX - last time I checked it was missing some crucial commands I'm using.

Opware2000 commented 3 years ago

Thanks for your answer. I just tested on a copy of graphicscache.sty where I removed the parts

'.setpdfwrite <<
          /AutoFilterColorImages false
          /EncodeColorImages true
          /ColorImageFilter /\graphicscache@compress@mode\space
          /ColorImageDict << /ColorTransform 1 /QFactor \graphicscache@qfactor\space /Blend 1 /HSamples [1 1 1 1] /VSamples [1 1 1 1] >>
          /ColorImageResolution \graphicscache@dpi\space
          /AutoFilterGrayImages false
          /EncodeGrayImages true
          /GrayImageFilter /graphicscache@compress@mode\space
          /GrayImageDict << /ColorTransform 1 /QFactor \graphicscache@qfactor\space /Blend 1 /HSamples [1 1 1 1] /VSamples [1 1 1 1] >>
          /GrayImageResolution \graphicscache@dpi\space
        >> setdistillerparams'

My doc compiles correctly with XeLaTeX without error. However, I may have been a bit rough.

xqms commented 3 years ago

I think you just have to remove the .setpdfwrite itself. Otherwise you lose the DPI specification. So it should be

'<<
          /AutoFilterColorImages false
          /EncodeColorImages true
          /ColorImageFilter /\graphicscache@compress@mode\space
          /ColorImageDict << /ColorTransform 1 /QFactor \graphicscache@qfactor\space /Blend 1 /HSamples [1 1 1 1] /VSamples [1 1 1 1] >>
          /ColorImageResolution \graphicscache@dpi\space
          /AutoFilterGrayImages false
          /EncodeGrayImages true
          /GrayImageFilter /graphicscache@compress@mode\space
          /GrayImageDict << /ColorTransform 1 /QFactor \graphicscache@qfactor\space /Blend 1 /HSamples [1 1 1 1] /VSamples [1 1 1 1] >>
          /GrayImageResolution \graphicscache@dpi\space
        >> setdistillerparams'
Opware2000 commented 3 years ago

It works great!

First compilation: 25 seconds Second compilation: 12 seconds

(no particular parameters, just the use of \usepackage{graphicscache} )

xqms commented 3 years ago

Thanks for testing :+1: I'll integrate that in the next days.