Edit one region of a large photo: crop, edit, stitch back in Pillow

Crop the part you want changed, edit it with Ideogram 4.5 on Sume, then resize and feather it back into the full-resolution photo with Pillow. Code included.

5 min readSume
All posts

To edit one region of a large photo without sending the whole frame, cut out the region, edit the crop, and paste the result back over the original with a feathered edge. Morphic describes Ideogram 4.5 as handling large photos with its own crop-and-stitch edits; this is the same idea done on your side, so the rest of the picture is the original file, not a model output. It works with any Sume model that accepts input_references.

The steps

The key rule: only edit a crop that you can describe on its own. "Change the sign on the shop front to OPEN" works. "Change the second window from the left" does not, because the crop may not contain the first window.

  • Pick a pixel box (left, top, right, bottom) a little larger than the area to change, so there is context around it.
  • Save the crop as PNG, host it at a public HTTPS URL, and send it as the first input_references entry.
  • Leave aspect_ratio out so the result keeps the crop's shape.
  • Download the output, resize it to the box size, and paste it with a blurred mask.

The stitch

This function reads your original and the edited crop, resizes the crop to the box, builds a mask that is solid inside and fades over feather pixels at the edge, and pastes. It runs as written with Pillow installed.

from PIL import Image, ImageFilter

def stitch(original_path, edited_crop_path, box, out_path, feather=24):
    left, top, right, bottom = box  # pixel box you cropped from the original
    base = Image.open(original_path).convert("RGB")
    crop = Image.open(edited_crop_path).convert("RGB")
    crop = crop.resize((right - left, bottom - top), Image.LANCZOS)
    mask = Image.new("L", crop.size, 0)
    mask.paste(255, (feather, feather, crop.width - feather, crop.height - feather))
    mask = mask.filter(ImageFilter.GaussianBlur(feather / 2))
    base.paste(crop, (left, top), mask)  # the blurred edge hides the seam
    base.save(out_path)

# stitch("photo.png", "edited_crop.png", (1000, 500, 1800, 1100), "final.png")

Why this is worth the extra step

A full-frame edit returns a whole new image, and every pixel in it came from the model. The stitch means that outside your box every pixel is the original, as long as you save as PNG and not a lossy format. That is the property Flux 3 Image advertises, with unchanged pixels preserved across steps, and you get it here on any model. The trade is a visible seam if the crop's colour or light differs from the surround, which is why the box should include context and the edge should be feathered.

Keep the crop lossless. Save it as PNG before upload, since a JPEG crop adds block artefacts that the model may treat as texture and carry into the edit. Download the edited crop in PNG as well when the model offers output_format.

Size matters too. A crop of 800x600 is a small, cheap job, and the edit runs at the model's native strength on that area. Ideogram 4.5 is priced per image regardless of size, so a crop costs the same $0.0375 at low quality on Sume as a whole frame would.

Where the seam shows

For a ready check on how much of the frame changed, use the pixel diff recipe. The seam theory in more detail is in hiding the seam with a feathered composite.

Seam problems and fixes for a stitched edit (read 2026-10-07)
SymptomLikely causeFix
Hard line at the box edgeFeather too smallRaise feather; widen the box
Colour step across the edgeModel shifted white balanceEdit a larger box; match mean colour before pasting
Softer texture inside the boxCrop was resizedSend the crop at its native size; avoid scaling up
Object cut at the edgeBox too tightAdd margin around the target

Sources

Related posts

More in Developers

All Developers posts

Written by Sume