Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

689
Visualizações
Error: Input buffer contains unsupported image format when trying to use Next JS next-optimize-image

I was using the default component to optimize images in my Next JS app but found out that the site can't be hosted anywhere else apart from Vercel if the default Image Optimization component is used. Apart from that, the site can't also be exported to be hosted on other web hosting platforms.

The drawbacks with the inbuilt Image Component led me to the next-optimized-images package which includes image optimization and other benefits as the inbuilt Next Image component.

It requires me to create a babel.rc with the following configuration:

{
  "presets": ["next/babel"],
  "plugins": ["react-optimized-image/plugin"]
}

I also modified my next.config.js to the following:

const withOptimizedImages = require('next-optimized-images');

module.exports = withOptimizedImages({
  /* config for next-optimized-images */

  // your config for other plugins or the general next.js here...
  webpack(config) {
    config.module.rules.push({
      test: /\.svg$/,
      use: ["@svgr/webpack"]
    });

    return config;
  },
  reactStrictMode: true,
});

The next-optimized-image inbuilt Img component can be utilized like this:

import Img from 'react-optimized-image';
// react-optimized-image is specified in the docs explicitly
import HeroImage from '../../../public/images/dashboard-on-mobile-and-desktop-screen.png'

export default function Hero(){
  return (
    <>
      <Img  src={HeroImage} sizes={[614]}/>
    </>
  )
}

After doing all these and I run npm run dev, I get the following errors in my console:

(node:22516) UnhandledPromiseRejectionWarning: Error: Input buffer contains unsupported image format
(Use `node --trace-warnings ...` to show where the warning was created)
(node:22516) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by 
rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:22516) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

How do I fix this problem? Thanks in advance

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I was having the same issue with a PNG image.

First, I just opened it with Paint and saved it again as PNG. I could see something had changed with git, but I was still getting the same error.

Then, I opened it with Gimp and exported it again as PNG and it worked.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda