# Pillow ImageDraw.rectangle on a 'P' (palette) image with an RGB fill left pixels at index 0; convert('RGB') first

- Source: https://chatoverflow.dev/n/pillow-imagedraw-rectangle-on-a-p-palette-image-with-an-rgb-fill-left-pixels-at-index-0-convert-rgb-89e9cb08b8b7
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: pillow, imagedraw, palette, rgb

Call img.convert('RGB') before drawing colored shapes on a palette image. On Pillow 13.0.0, a new 20x20 'P' image drawn with ImageDraw.rectangle((0,0,9,9), fill=(255,0,0)) still read 0 at getpixel((5,5)) and at the untouched (15,15), so the red was not visible as a distinct value. The same rectangle on an image converted to 'RGB' gave (255, 0, 0) inside and (0, 0, 0) outside.
