[softwarelist] Potential TransPDF improvements

  • From: Peter Newble <pcnewble@xxxxxxxxx>
  • To: davidpilling@xxxxxxxxxxxxx
  • Date: Thu, 24 Jan 2019 18:48:20 +0000

One problem with the TransPDF filter (Windows), which I also used to experience 
with !OEPS when importing EPSs under RISC OS, is that the preview image 
inevitably has a solid background (i.e. no alpha channel) even if the EPS/PDF 
has a transparent background. If the EPS or PDF is placed in a transparent 
frame it will print correctly to a Postscript device but be displayed 
incorrectly on screen with a white background. Using built-in EPS previews this 
is unavoidable. Using GhostScript to produce a preview for either EPSs or PDFs 
a transparent background could be possible, because Ovation Pro correctly 
displays transparent TIFFs, but GhostScript doesn’t produce TIFFs with an alpha 
channel, hence the white background. However, it would produce PNGs with an 
alpha channel, by changing '-sDEVICE= tiff24nc’ to '-sDEVICE=pngalpha’ (in the 
second line of transpdf.txt). But of course Ovation Pro doesn’t display PNGs 
directly, so it would be necessary to add an extra step to TransPDF then to 
translate that PNG to a TIFF. That ought to be possible by whatever means the 
TransPNG filter already uses to convert PNGs to TIFFs, except that the TransPNG 
filter too ignores any alpha channel and also gives a white background.

Imagemagick (https://www.imagemagick.org ;<https://www.imagemagick.org/>) is a 
superb utility for Linux/Windows/OS X which does everything (and far more) for 
which one might use ChangeFSI on RISC OS. If it is installed in Windows 
alongside Ghostscript (and the path to it perhaps included in transpdf.txt just 
as the path to Ghostscript currently is) this could be done adding the simple 
Imagemagick command ‘convert <previewfile.png> <previewfile.tif>’ to convert 
the PNG output from the GhostScript command generated using the second line of 
transpdf.txt to an alpha-channel TIFF to be used as the preview.  And 
similarly, Imagemagick could be used in TransPNG to make a better job of 
importing PNGs than the present version does. (At present I always convert 
TIFFs to PNG to avoid this problem.)

In fact, Imagemagick could be used for the first stage of making the TIFF 
preview, anti-aliased and with transparency, directly from the PDF without 
going via GhostScript. The equivalent to the GhostScript command generated by 
line 2 of transpdf.txt, to convert the first page of a PDF to TIFF:

<ghostscriptpath>\gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=tiff24nc 
-dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sOutputFile=outfile.tif -r300 -q 
-dFirstPage=1 -dLastPage=1 infile.pdf

(but anti-aliased and with an alpha channel if necessary, by default) would be:

<imagemagickpath>\convert -density 300 -depth 8 infile.pdf[0] outfile.tif

‘-depth 8’ seems to be necessary because otherwise it defaults to a 
16-bits-per-channel (e.g. 48-bit RGB) TIFF which Ovation Pro will not handle. 
That’s not necessary when converting from PNG to TIFF because by default it 
preserves resolution and bit depth when converting between raster formats.

That produces a transparent TIFF which Ovation Pro displays correctly, 
therefore ought to be suitable as a preview image for a PDF (or EPS).

This would be a better way than the present one to generate the TIFF preview 
but GhostScript is still needed as before to convert from PDF to EPS for 
printing because ImageMagick creates raster images only; although it will 
output PDFs or EPSs they contain just a rasterised version of the input file.

Because the Ovation Pro filters are supplied as ready-built .exe files this is 
not something I can experiment further with, unfortunately.


Peter.

Other related posts: