5

Is there someplace where I can read about how \includegrapics uses the metadata that is stored with a JPG image?

I have carefully sized 80 images with Photoshop such that the Photoshop's ImageSize data shows the correct size in inches and a resolutions (300ppi) which calculates out to the same size in pixels. With \includegraphics, most of the images come out to be their specified size (in inches, and presumably in their underlying pixels) in the PDF file. However, about a dozen of the images which seem to be specified the same way in Photoshop output to the PDF much bigger than they should be. Is is possible that these non-working images were originally scanned at 600ppi (I've lost track of what happened during the scanning several years ago) rather than 300ppi and I resampled them with Photoshop to keep that same size in inches while reducing the resolution and thus the size in pixels?

When I look at the metadata with another image processing program (FastStone Image Viewer) it looks correct. My goal is to avoid explicit specification of image width or whatever by sizing the images correctly so LaTeX output them correctly in their \includegraphics input mode. Thus, I am looking for what other bit of metadata \incloudegraphics may be finding that gets the wrong result for me. Thus my request for a pointer to how \includegraphics "does its thing." I have a two line program (between \begin{document} and \end{document}) and two image files (with seemly correct metadata) which demonstrate my problem (unless I am missing something).

  • Welcome to TeX.SX! pdftex is (statically) linked to some libraries and I guess it relies on them to provide the correct information. The primitive \pdfximage is in charge of retrieving the information; the bounding box data can be examined with \pdfximagebbox. – egreg Apr 16 '14 at 20:46
  • I tried the following pattern for my images: \pdfximage{afile.jpg} \pdfximagebbox\pdflastximage 1 % Returns lower-left x \pdfximagebbox\pdflastximage 2 % Returns lower-left y \pdfximagebbox\pdflastximage 3 % Returns upper-right x \pdfximagebbox\pdflastximage 4 % Returns upper-right y and get back four results of 0.0pt. Is that supposed to work for a .jpg, or is a bounding box a .eps/.pdf concept? – Dave Walden Apr 16 '14 at 21:53
  • 1
    Hmm, it seems that \pdfimagebbox is good only for PDF files; pdftex.cfg just says \pdfximage{<file>} and then \setbox\@tempboxa=\hbox{\pdfrefximage\pdflastximage} in order to know the dimensions of the image. – egreg Apr 16 '14 at 22:07
  • I still have no understanding of the problem I posed in the question. However, by converting the dozen or so JPEGs which \includegrahics didn't handle correctly to PNGs, things now work. Perhaps this conversion eliminated whatever metadata was hanging around in the JPEG metadata and confusing \includegraphics. I didn't try converting back from PNGs to JPEGs to see if that also worked. I still think it would be nice to see documentation of how \includegraphics gets the size metadata from the various format images it handles from pdflatex. – Dave Walden Apr 17 '14 at 14:52
  • 1
    @egreg There have been several changes to pdftex.def and others. Do you want to write an answer? – Johannes_B Feb 18 '18 at 10:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.