Skip to content

"Invalid JPG, no size found" when JPG image contains a thumbnail frame #323

@Rivers47

Description

@Rivers47

I was trying to use an JPEG with 11ty-img that results in the following error

Eleventy Fatal Error (CLI):
[11ty] 1. Having trouble writing to "./public/blog.html" from "./src/blog.md" (via EleventyTemplateError)
[11ty] 2. Transform `@11ty/eleventy/html-transformer` encountered an error when transforming ./src/blog.md. (via EleventyTransformError)
[11ty] 3. Eleventy Image error (statsOnly): `image-size` on "src/test.jpg" failed. Original error: Invalid JPG, no size found
[11ty] 
[11ty] Original error stack trace: Error: Eleventy Image error (statsOnly): `image-size` on "src/test.jpg" failed. Original error: Invalid JPG, no size found
[11ty]     at Image.getStatsOnly (/blog/node_modules/@11ty/eleventy-img/src/image.js:829:13)
[11ty]     at /blog/node_modules/@11ty/eleventy-img/src/image.js:848:23
[11ty]     at run (/blog/node_modules/p-queue/dist/index.js:157:104)
[11ty]     at PQueue._tryToStartAnother (/blog/node_modules/p-queue/dist/index.js:105:17)
[11ty]     at PQueue._next (/blog/node_modules/p-queue/dist/index.js:48:14)
[11ty]     at run (/blog/node_modules/p-queue/dist/index.js:168:22)
[11ty]     at process.processTicksAndRejections (node:internal/process/task_queues:104:5)

mediainfo shows that there are two images, with the second one being the thumbnail, in the JPEG.

Image #1
Format                                   : JPEG
Width                                    : 4 096 pixels
Height                                   : 3 072 pixels
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Compression mode                         : Lossy
Stream size                              : 4.92 MiB (89%)
ColorSpace_ICC                           : RGB
colour_primaries_ICC_Description         : Display P3

Image #2
Type                                     : Thumbnail
Format                                   : JPEG
Muxing mode                              : Exif
Width                                    : 176 pixels
Height                                   : 128 pixels
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Compression mode                         : Lossy
Stream size                              : 39.6 KiB (1%)

Extracting the actual image with ffmpeg resolves the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions