22 Jun '22
Redacting craiyon prompts with imagemagick
I’ve been messing around with craiyon (formerly DALL-E mini), because who hasn’t been doing that recently.
As part of a workshop I’m running soon at the School of Cybernetics I need to provide “redacted” versions of the classic 3x3 craiyon output image—and I need to do it for quite a few outputs.
Because it’s tedious to do that by hand, here’s what I came up with:
input a prompt and generate the craiyon output as normal
use the 📷 Screenshot button to get a nice, clean screenshot
run this imagemagick command (in my case the downloaded screenshot name was
craiyon_2022-6-22_17-21-5.png, yours will be similar but with a different timestamp at the end)
convert craiyon_2022-6-22_17-21-5.png -fill red -draw 'rectangle 30, 240, 1320, 320' -fill white -pointsize 50 -gravity north -annotate +0+250 'REDACTED' craiyon_2022-6-22_17-21-5-redacted.png
(bonus round) if you want to loop over a bunch of files and do it in batch, I did that in Emacs with:
(--each (f-entries "." (lambda (s) (s-ends-with? "png" s))) (shell-command (format "convert %s -fill red -draw 'rectangle 30, 240, 1320, 320' -fill white -pointsize 50 -gravity north -annotate +0+250 'REDACTED' redacted-%s.jpg" it (f-base it))))
Here’s an example screenshot:
and the same output, after the redaction command has been run:
If you need to do the same, then hopefully I’ve saved you a bit of time ☺