Skip to content
EPUBCheck · Package and ZIP container

EPUBCheck PKG-022: image extension mismatch

Updated:

EPUBCheck PKG-022 is a warning message: “Wrong file extension for image. The image is a "…" file but has the file extension "…".” An image's extension does not match its real format, for example a PNG file named .jpg. Most reading apps still show it, but tools that trust the extension or the manifest media type can fail.

The official message

Wrong file extension for image. The image is a "%1$s" file but has the file extension "%2$s".

Default severity
Warning. The EPUB is still valid, but something is likely to cause problems in some reading apps. EPUBCheck exits with 0 unless you pass --failonwarnings.
EPUBCheck version
5.4.0

%1$s, %2$s… are filled in with the file, value or element EPUBCheck found.

Typical causes

  • Images renamed instead of converted.
  • Tools that save in one format but keep the old extension.

How to fix it

  1. Either rename the file to the right extension or convert it to the format its name says.
  2. Make the manifest media type match the real format too (image/png, image/jpeg…).
  3. After renaming, update every reference to the file: the manifest in the package document, links and image sources in the XHTML, and url() references in the CSS.

When it's not this

If the image cannot be decoded at all, the message is PKG-021.

Terms used here

Other PKG messages

  • PKG-021 Corrupted image file encountered.
  • PKG-023 Validating the EPUB against version 2.0, default validation profile will be used.
  • PKG-020 OPF file "…" could not be found.
  • PKG-025 Publication resource must not be located in the META-INF directory
  • PKG-018 The EPUB file could not be found.
  • PKG-026 Obfuscated resource must be a Font Core Media Type (was declared as "…" in "…").

Sources

Message text and severity from EPUBCheck 5.4.0 (W3C, BSD-3-Clause). Explanation by EpubCC.

FAQ

What does EPUBCheck PKG-022 mean?

EPUBCheck PKG-022 is a warning message: “Wrong file extension for image. The image is a "…" file but has the file extension "…".” An image's extension does not match its real format, for example a PNG file named .jpg. Most reading apps still show it, but tools that trust the extension or the manifest media type can fail.

Is PKG-022 an error?

PKG-022 is reported as warning by default. The EPUB is still valid, but something is likely to cause problems in some reading apps. EPUBCheck exits with 0 unless you pass --failonwarnings.