Re: pdf images rasterized incorrectly only in graphics preview

2016-07-10 Thread Paul A . Rubin
Derek Lamb  boulder.swri.edu> writes:


> Instead, I quickly found the Mac page on the Lyx wiki 
> (https://wiki.lyx.org/Mac/Mac) and followed the instructions there for "On 
> screen quality of included PDF files", namely defining a new converter to use 
> the Mac's builtin "sips" function (of which I had not been aware).  Doing
that 
> led to the PDF image converting to PNG quite nicely, problem solved.
> 
> Thanks again for pointing me down the right path.

You're welcome. You might check the ticket system and, if nobody has already
brought this up, file an enhancement request to modify the configuration
script so that it detects whether you are on a Mac (it may do this already)
and, if so, sets up a PDF (graphics) converter using sips. That seems like a
reasonable thing to do in general.

Cheers,
Paul



Re: pdf images rasterized incorrectly only in graphics preview

2016-07-09 Thread Derek Lamb
Paul A. Rubin writes:

> 
> You might try the following.
> 
> Good luck!
> 
> Paul
> 
> 

Hi Paul,

Thank you for the very detailed instructions.  Looking at the debug output, it 
became clear that Lyx went through the entire list of 10 or so converters 
(ending with xpm) and failed to find any way to convert a PDF (graphics) file 
to one of those formats.  It ended up trying to use the default converter 
convertDefault.py.

Looking at the list of Converters, I confirmed that, indeed, there was no 
converter that started with "PDF (graphics)" !!! This was quite surprising to 
me.  I had no 'pdftops' binary.  After some searching, I realized that comes 
with xpdf, or now poppler.  I could have installed either of those through 
MacPorts and gone on my way.

Instead, I quickly found the Mac page on the Lyx wiki 
(https://wiki.lyx.org/Mac/Mac) and followed the instructions there for "On 
screen quality of included PDF files", namely defining a new converter to use 
the Mac's builtin "sips" function (of which I had not been aware).  Doing that 
led to the PDF image converting to PNG quite nicely, problem solved.

Thanks again for pointing me down the right path.

Derek



Re: pdf images rasterized incorrectly only in graphics preview

2016-07-09 Thread Paul A . Rubin
You might try the following. Prepare a tiny test document with one of the
offending images, and nothing else, to minimize the amount of output through
which you will wade.

Open a terminal and run the command "lyx -dbg graphics", which should open
LyX while spewing a bunch of stuff to the terminal window. You might want to
position the windows so that both are visible. Any output in the terminal up
to this point can be ignored.

Now open your test document, which will send the terminal into another
paroxysm of printing. Scroll forward to find a line like the following:

"Attempting to convert image file: mygraphicfile.pdf"

Soon thereafter should be something like the following:

"Format.cpp (435):  got format from MIME type: application/pdf -> pdf6"

"pdf6" is LyX's short name for the file format it calls "PDF (graphics)".
Presumably it will recognize your image as such.

Once LyX recognizes you've inserted a PDF image, it will try to convert it
to a format that it can display in the GUI. Look for a line like the following:

"The image loader can load the following directly:"

This will be followed by a list of graphics formats LyX likes. You'll need
to scroll back to that list in a minute.

Scroll further forward and you should see LyX attempting to convert your PDF
image to each of those LyX-friendly formats in order. There should be lines
like the following:

"graphics/GraphicsCacheItem.cpp (342): Unable to convert from pdf6 to bmp"
"graphics/GraphicsCacheItem.cpp (342): Unable to convert from pdf6 to gif"

When the list stops, the first of the LyX-friendly formats that does not
have an "unable to convert" message is apparently the one LyX ended up using.

I just ran a small test in which the last failure message was for "pgm"
format. The next format in the list of supported formats was "png", so LyX
apparently converted my PDF image to PNG in order to display it in the GUI.
Now go to Tools > Preferences... > File Handling > Converters and scroll
until you find a converter from the format LyX believes your image to be
(probably "PDF (graphics)") to the format it used for display. As if this
were not already sufficiently complex, you may not find that converter, in
which case LyX goes through a chain of two or more conversions. For instance
(at least on my system), there is no converter from "PDF (graphics)" to PNG.
The only conversion out of "PDF (graphics)" is to EPS; there is then a
converter defined from EPS to PNG.

Assuming you have survived to this point and found a conversion path, look
at the "Converter:" box for each step of the path. In my case, they read

pdftops -eps -f 1 -l 1 $$i $$o (to go from "PDF (graphics)" to EPS

and 

convert $$i $$o (to go from EPS to PNG).

If you've made it this far, chances are one of those conversions is mucking
up your image. You can try manually run each conversion in a terminal and
then viewing the output file of the conversion in some appropriate file
viewer to see if it has turned into mush yet. You will need to substitute
the name and path of your PDF image for $$i in the first conversion step,
and give a name and path to use for the output as $$o in the first
conversion step. If additional conversions occur, each subsequent $$i is the
previous $$o and each new $$o is some new temporary file.

Good luck!

Paul