Grok Imagine takes JPG or PNG up to 20 MiB: convert iPhone HEIC

xAI lists jpg, jpeg and png inputs up to 20 MiB for Grok Imagine. iPhone HEIC photos need converting first; here is a short script before an edit on Sume.

4 min readSume
All posts

xAI's models page says supported image file types are jpg/jpeg or png, with a maximum image size of 20 MiB. iPhones often save HEIC, which is not on that list, so convert before you send. The same habit helps on the Sume image API, whose reference URLs must be public HTTPS and which does not document HEIC as an input.

What the vendor says

From xAI's models page.

Grok Imagine input facts, read 2026-10-02
ItemWhat the page says
File typesjpg/jpeg or png.
Maximum size20MiB.
Pricegrok-imagine-image $0.02, grok-imagine-image-2.0 $0.04, grok-imagine-image-quality $0.05 per image.

Convert and check

The script converts HEIC to JPEG and checks the size limit. It uses pillow-heif, installed with pip install pillow pillow-heif.

import os, sys
from PIL import Image
from pillow_heif import register_heif_opener

register_heif_opener()
src = sys.argv[1]
dst = os.path.splitext(src)[0] + ".jpg"
Image.open(src).convert("RGB").save(dst, quality=90)
size = os.path.getsize(dst)
print(dst, size, "ok" if size <= 20 * 1024 * 1024 else "too large")

Then host it

After conversion, upload the file somewhere public over HTTPS and use that URL as an input_references entry. Localhost, private-network and non-HTTPS URLs are rejected before submission.

If the file is too large

Resize the long edge and lower the JPEG quality until it is under the limit. Check the edited result to make sure the smaller source still holds the detail you need.

Sources

Related posts

More in Developers

All Developers posts

Written by Sume