Tx · LaTeX & TikZ

Why Does a Black-and-White JPG Appear Black in a PDFLaTeX Document?

Published By the 9to5Science editorial team

At a glance

  1. 1. Check the image

    Open the JPG in another viewer and inspect its color space; black-and-white images can still be stored as CMYK or YCCK.

  2. 2. Convert the file

    Make a new PNG or standard sRGB JPEG with an image editor or ImageMagick.

  3. 3. Include the converted file

    Use graphicx and include the new file with includegraphics.

  4. 4. Check the output

    Compile a minimal document and compare the resulting PDF in another viewer.

A black-and-white JPG can be grayscale, RGB, CMYK, or another encoded color form. If it looks correct in an image viewer but becomes black after pdflatex includes it, first suspect a color-space or color-profile compatibility problem—not a LaTeX command that changes the image to black.

The most reliable fix is to convert a copy of the image to PNG or standard sRGB JPEG, then include the converted file. The steps below also help distinguish an inclusion problem from an image that is already black.

Check whether the image itself is black

Open the JPG in a separate image viewer. If it is black there too, the source file or its decoding may be at fault; check it in another viewer or recreate/export a copy before troubleshooting LaTeX. If it looks correct there but not in the PDF, the issue is more likely to involve how the image is encoded or interpreted during PDF creation or viewing.

You can also inspect its metadata. With ImageMagick, run:

magick identify -verbose picture.jpg

Look for the Colorspace field and any profile information. A black-and-white picture may still be stored as CMYK, and some JPEGs use CMYK-related YCCK encoding. These formats can cause compatibility problems in some image-to-PDF workflows. Grayscale and RGB files are generally safer choices for a simple document.

Convert the image and include it

For a basic colorspace conversion with ImageMagick, convert the file to PNG in sRGB:

magick picture.jpg -colorspace sRGB picture.png

The -colorspace option converts based on ImageMagick’s interpretation of the source colorspace; by itself, it is not a substitute for converting through an embedded or known ICC profile. If the JPG has an embedded ICC profile or a known CMYK profile, use a color-managed editor or explicitly convert from the correct source profile to sRGB. Keep the original as a backup. Conversion can change the file’s appearance if its color profile is missing or unusual, so check the new PNG in an image viewer before using it. You can also use an image editor’s export function and explicitly choose PNG or RGB/sRGB JPEG.

Then include the converted file with graphicx:

\documentclass{article}
\usepackage{graphicx}

\begin{document}
\includegraphics[width=0.7\linewidth]{picture.png}
\end{document}

Compile with pdflatex. A minimal document is useful because it rules out unrelated document settings. If the PNG displays correctly in this test, replace the original JPG in your full document.

Why conversion can help

JPEG describes how image data is stored, not just whether the picture is black and white. A file that appears monochrome may contain grayscale samples, RGB channels, or CMYK data. It may also include a color profile or use a less common encoding. When the PDF producer or PDF viewer interprets that information differently than the image viewer does, the displayed colors can be wrong—including appearing almost entirely black.

Converting the image asks an image-processing program to decode the original and write a new file in a more commonly supported format. PNG is a useful test format because it avoids JPEG’s CMYK/YCCK encoding issue and does not add further lossy compression. For photographs, an sRGB JPEG can be suitable too.

Other checks

If conversion does not fix the problem, try these checks:

  1. Compile a minimal file. Use only \documentclass, graphicx, and \includegraphics as above. This helps identify conflicts or options in the larger document.
  2. Check for draft mode. A draft option usually shows a placeholder rather than turning the actual image black. Remove draft from the document class or graphicx options if it is enabled.
  3. Try another PDF viewer. A display problem in one viewer does not prove that the PDF data itself is wrong.
  4. Check the converted image outside LaTeX. If the PNG is black before inclusion, the conversion settings or the source file need attention.
  5. Use the correct file name. Make sure LaTeX is including the converted file, not an older file with the same base name in another directory.

Common mistakes

  • Assuming “black-and-white” means grayscale. It describes the appearance, not necessarily the file’s stored color space.
  • Changing the image’s LaTeX size or placement. Width and positioning options do not repair incorrect color interpretation.
  • Renaming the JPG to .png. A new extension does not convert the file format; export or convert it instead.
  • Overwriting the original during conversion. Keep the source file so you can compare results and retry with different settings.

If a grayscale or sRGB conversion still appears black in the minimal example, check the PDF viewer and the image metadata, then test with a known-good PNG. That separates a source-image problem from an issue elsewhere in the document or PDF workflow.

References

  1. The LaTeX Graphics Bundle: graphicx and the graphics package
  2. ImageMagick Documentation

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.