diff --git a/packages/gatsby-plugin-sharp/src/index.js b/packages/gatsby-plugin-sharp/src/index.js index f59a5993c2082..37d8275035d67 100644 --- a/packages/gatsby-plugin-sharp/src/index.js +++ b/packages/gatsby-plugin-sharp/src/index.js @@ -30,6 +30,14 @@ const getImageSize = file => { const dimensions = imageSize.sync( toArray(fs.readFileSync(file.absolutePath)) ) + + if (!dimensions) { + reportError( + `gatsby-plugin-sharp couldn't determine dimensions for file:\n${file.absolutePath}\nThis file is unusable and is most likely corrupt.`, + `` + ) + } + imageSizeCache.set(file.internal.contentDigest, dimensions) return dimensions }