I have a few private GitHub repositories of games I have made. I want to open source the codebases, but many of the images used are licensed so cannot be shared freely.

Since the image dimensions and filetype need to stay the same for the code to compile, a possible solution would be to replace all of the images with placeholders.


  • Be able to select a few hundred images at once.
  • Replace each image with a placeholder of the same name, size, and filetype.
  • Ideally each image would contain, as text, the filename for identification, or an ID.

Ideas so far

Using what I already know, recording a Photoshop macro of adding a "placeholder" layer onto an image and overwriting the original would complete half my task. It could easily work in bulk, but I don't see any way to get an ID or filename INTO the image itself.

Any ideas, or perhaps better solutions to the image replacement?


2 Answers 2


You can use imagemagick on linux for that task.

for file in foo.jpg bar.jpg *.png; do  magick -gravity center -background black -fill white -size "$(identify -format "%wx%h" $file)" caption:"$file" $file; done


  • runs a for loop over all specified files between inand ;. You can use shell expansion here, for example *.png

  • magick -gravity center -background black -fill white will create a new image with black background, containing the filename centered as white text.

  • -size "$(identify -format "%wx%h" $file) will get the specified files resolution and use the result for the new file. identify is part of imagemagick

  • caption:"$file" contains the text contained in the image, in this case the filename/path we got from our for loop.


While imagemagick exists for windows, I honestly have no idea how to get this scenario to work on windows.

  • 1
    I've got Windows & Mac OS available, so will give it a go on both! Looks like this will work, maybe with some platform bugs. Will report back, thanks.
    – Jake Lee
    Mar 8, 2022 at 9:55

Whilst the other answer presumably works well on Linux, I wanted a more GUI-driven approach that would work on Windows, and I felt more in control of.

I ended up using IrfanView's batch conversion functionality, with the following "Advanced settings":

irfanview batch conversion

So, to summarise a confusing screen:

  • Set the image's brightness to -255 (full black).
  • Add the filename ($F) to the centre of the image.
  • Using a custom processing order, ensure the text is added after the image is made black.
  • Save over the original.
Before After
sample input sample output

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .