LyXScaling of images in output PDF

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
jdefoe
Posts: 4
Joined: Sun Mar 13, 2011 9:21 pm

Scaling of images in output PDF

Post by jdefoe »

When using PNG-files in my lyx document, they get scaled (up) in the exported pdf. I'm exporting with pdflatex, and have not enabled scaling as far as I can tell.

I'm currently using Lyx 2.0.0 RC1 on Ubuntu, but I've experienced the same problem with Lyx 1.6.9 on Windows.

SOLVED: I suggest you simply read through the whole thread for a solution if you're having the same issues as me. Many thanks to meho_r and localghost for the help, much appreciated.
Last edited by jdefoe on Tue Apr 12, 2011 10:52 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Re: Scaling of images in output PDF

Post by meho_r »

This is unusual. Can you create an example .lyx file, put it into a ZIP archive together with a sample PNG image and the PDF output, and attach them to your next post, please?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Scaling of images in output PDF

Post by localghost »

jdefoe wrote:When using PNG-files in my lyx document, they get scaled (up) in the exported pdf. […]
You have to take the relation between postscript point and pixel into account (1.333… or 0.75, respectively) [1]. So try to scale the concerned picture(s) to three quarters of the original size while including. In LaTeX this would be done by the graphicx package.

Code: Select all

\includegraphics[scale=0.75]{‹filename›}
[1] Postscript Point Conversion


Best regards and welcome to the board
Thorsten
jdefoe
Posts: 4
Joined: Sun Mar 13, 2011 9:21 pm

Scaling of images in output PDF

Post by jdefoe »

Attached is the example file as requested. I booted up my Windows-laptop to create the file with lyx 1.6.9, because lyx 2.x.x files are incompatible with earlier versions.

Another thing I notice is that it takes up to several minutes to create the PDF-file with pdflatex with the 1.6.9 version on Windows, compared to my current Ubuntu desktop where it only takes a couple of seconds.

Edit: Sorry, I was composing this post so I didn't notice the last answer there. I'll try that right away!

Edit2: Thank you very much for pointing out the relation between postscript point and pixel Thorsten, and for the welcome.

This is exactly my problem indeed. I can't seem to get the scale function to work though, as I get this output:

Code: Select all

LaTeX Error: Missing \begin{document}.

\includegraphics[scale=0.75]{skisse01.png}
You're in trouble here.  Try typing  <return>  to proceed.
If that doesn't work, type  X <return>  to quit.
I assume I'm doing something wrong here?

Edit3: It hits me that when using PNG-files some sort of scaling probably is inevitable. So my next question would be, is there a format more appropriate for figures? I'm thinking the best solution would be some sort of scaleable (vector) format?
Attachments
example.zip
The example files as requested.
(4.32 KiB) Downloaded 213 times
Last edited by jdefoe on Mon Apr 11, 2011 8:05 pm, edited 1 time in total.
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Re: Scaling of images in output PDF

Post by meho_r »

To put it simple: the image isn't scaled at all. To see for yourself, open it in an image editor (e.g. GIMP) and take a look at it's size: it is 140.05 x 128 mm, exactly as it appears in the PDF output. However, the resolution is terrible: ~50 dpi which is far below a minimum.

Suggestions:
1. Always prepare the image in an image editor before using it in your document
2. At least 300 dpi resolution is required for images which should be printed
3. Use vector graphics whenever you can instead of bitmap graphics. This image you attached would look much better if you exported it as an SVG or PDF file instead of PNG.
Attachments
example-1.zip
An example file. LyX 2.0.0rc2 or greater needed.
(8.02 KiB) Downloaded 219 times
jdefoe
Posts: 4
Joined: Sun Mar 13, 2011 9:21 pm

Re: Scaling of images in output PDF

Post by jdefoe »

Well, it becomes more and more evident to me that I have a lot to learn. Clearly my image is far too low resolution for print, but I'm left with one question in this regard. Lyx (or its back end) must be doing some kind of scaling with my low resolution PNG-image, as it should turn out really small in the final PDF-file, instead it turns out really big (see picture attached for example).

I'm really thankful for your suggestions by the way, and I will most certainly stick with those formats where possible. Also thank you for taking the time to supply an example.
Attachments
How the output PDF-file looks like.
How the output PDF-file looks like.
Screenshot-1.png (18.22 KiB) Viewed 13554 times
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Scaling of images in output PDF

Post by localghost »

jdefoe wrote:[…] Lyx (or its back end) must be doing some kind of scaling with my low resolution PNG-image, as it should turn out really small in the final PDF-file, instead it turns out really big (see picture attached for example). […]
TeX (the back-end) is not interested to do anything with image files but to just include them. The seeming scale is just a result of the relation I mentioned in my last reply. The DPI value influences only the printed output but does not really affect the appearance in the electronic document.

The best way to check that is to include a small screen capture into a document and try to let it appear in the document as it appears on the screen.

But as already mentioned, it can't do any harm to have a plan for including image files into a LaTeX document. Some pre-processing might be necessary to get the desired result.
jdefoe
Posts: 4
Joined: Sun Mar 13, 2011 9:21 pm

Re: Scaling of images in output PDF

Post by jdefoe »

Ok, well, this has clarified a lot for me. I'll stick with scalable image-formats from now on, or higher resolution PNGs if that's the only alternative.

Seems as if my problem has been solved, so I'll do the necessary changes to the thread. Thanks a lot!
CSMR
Posts: 44
Joined: Fri Oct 10, 2008 10:44 pm

Re: Scaling of images in output PDF

Post by CSMR »

I don't understand.
On an image inserted in Lyx, double click, and you should be presented with scaling and clipping options. If they are there and don't work, report it as a bug.
Post Reply