Replace an image with a resized version

Is there a way (e.g. with a script) to resize a selected image in place?

Possibly. Imagick comes to mind, and there are probably programs out there that can be Apple Scripted to do it, eg GraphicConverter.
But why would you want to do that? Scaling images always reduces their quality (down: less detail; up: more pixelation).

In the database? In a document?

In the database.

The images are referenced in Markdown documents, so they really don’t need to be bigger than 2048x2048 or similar.

DEVONthink includes several scripts to modify images/thumbnails, see Scripts > Images.

Cool! That’s exactly what I’m after! The script Scale to 1024 pixels I can customise easily to my needs - and it does the convenient in-place conversion.