Generalinclude pictures with wrong scale

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
nphaibk
Posts: 23
Joined: Fri Sep 19, 2008 4:34 pm

include pictures with wrong scale

Post by nphaibk »

Hi all,

I have 2 pictures with the same size (712x484). I used \includegraphics(width=6.5cm){filename) to add them into my paper but the pictures appearing in the pdf document have different heights.

In my opinion, because the pictures have the same size and I set the same widths, their heights should be the same. Has anybody met this problem? Please give me a solution for this. Many thanks in advance.

Hai

Recommended reading 2024:

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

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

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

include pictures with wrong scale

Post by localghost »

If you could provide these graphics files (as attachment), we could examine them and test that ourself. Without that it is very difficult to get a clue. Perhaps an additional piece of code in the sense of a minimal working example (MWE) could also be helpful.


Best regards
Thorsten¹
nphaibk
Posts: 23
Joined: Fri Sep 19, 2008 4:34 pm

Re: include pictures with wrong scale

Post by nphaibk »

Thanks Thorsten for your reply. Here are the pics and the MWE and the pdf result as well.
Attachments
D164-2K.PNG
D164-2K.PNG (196.94 KiB) Viewed 5076 times
D152-2K.png
D152-2K.png (201.11 KiB) Viewed 5077 times
test.tex
(300 Bytes) Downloaded 196 times
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

include pictures with wrong scale

Post by localghost »

At first I was really at a loss, because I never faced such a problem. But then I had the idea of examining the files with GIMP. What I found out is that the two images have different resolutions in x- and y-direction. Here are the facts.
  • d152-2k.png
    • x-resolution: 72.009 px/in
    • y-resolution: 72.009 px/in
  • d164-2k.png
    • x-resolution: 74.981 px/in
    • y-resolution: 67.996 px/in
Where px/in means pixels per inch. Any other image manipulation software should yield the same results. All you have to do now is adjust the resolutions to the same values. The reason for the wrong representation in the final output is the fixed relation between pixel and postscript point (px and pp).
brlnd
Posts: 15
Joined: Wed Sep 17, 2008 6:50 pm

include pictures with wrong scale

Post by brlnd »

An alternative to editing the (wrongly set) aspect ratio within the file using GIMP, you may explicitly set the height as well in the includegraphics call,

Code: Select all

 \includegraphics[width=6cm,height=4.08cm]{d152-2k}
where I calculated 4.08cm by hand (assuming 1:1 aspect ratio for the pixels in the original picture).
nphaibk
Posts: 23
Joined: Fri Sep 19, 2008 4:34 pm

Re: include pictures with wrong scale

Post by nphaibk »

Thank you very much.

That's the perfect answer. I knew that I was wrong, not Latex but I did not know what it was.

Hai
Post Reply