Home / Godot / G28

Godot error: Image width must be greater than 0. — cause and fix

When a script creates an Image, calls resize, or fills a bitmap, the width passed in is ze

ID
G28
Engine
Godot
Verification
源码原文(core/io/image.cpp:1289)
Frequency
未公开

Original message (verbatim)

Image width must be greater than 0.

Placeholders such as %s / %d are kept verbatim from the engine source and are not replaced with concrete values.

Trigger

When a script creates an Image, calls resize, or fills a bitmap, the width passed in is zero or negative, and Image validation rejects the operation.

Typical cause

Image::resize/set_data checks p_width <= 0; an invalid width cannot allocate a pixel buffer, so ERR_FAIL_COND_MSG aborts the call.

Step-by-step fix

  1. Check the width variable source and ensure it is a positive pixel value.
  2. Fix any expression that derives width from node size or atlas frame and yields zero.
  3. Log and assert the width and height are non-zero before creating the image.

Source links

Per-entry sources and capture date are listed at /sources#G28.

Related errors

Related Godot errors

Need an offline quick-reference checklist?

Atlas error library Pro pack: 123 error references (110 single + 13 merged) plus a quick-fix guide, $19 one-time purchase, delivered as electronic files.

View Pro pack / order

Back to the all-errors index Checkout and buy the Pro pack — $19.00