Using Python to generate unique images.

Farzy Vafa
2 min readOct 2, 2021

Sometimes service providers can easily link different profiles together if the metadata and/or images have the same filesize and data.

For example, if you are trying to make 5 different Instagram profiles, you should probably try to upload different profile pictures each time.

But what if you want the same image, without being detected?

Make sure to first install Pillow:

pip install Pillow

Here is the code I ended up going with, to create 19 unique images from my first image; 1.jpg:

import shutil
from PIL import Image
import PIL
import os
import glob
from random import randrange
original = r'YOURIMAGEPATHHERE.jpg'
for x in range(2, 21):
newimgpath = ("YOURIMAGEPATH\" + str(x) + ".jpg")
print(newimgpath)
shutil.copyfile(original, newimgpath)
picture = Image.open(newimgpath)
randnum = randrange(50, 99)
picture.save(newimgpath,optimize=True,quality=randnum)

It worked great, each copy would get a compressed randomly from 50–99 so that it won’t look too terrible.

Voila, we got some unique images!

You can take it a step further, by trying these methods:

  • Adding slight and random amounts of gaussian blur
  • Removing or changing certain ranges of colours
  • Removing random lines of pixels, for example on the x and or y axis

Coding is fun! I could have just copy and pasted the image 19 times, and opened each one in paint and made small modification, but what is the fun in that?

I hope the code above helps you with slight image modifications in Python.

--

--

Farzy Vafa

☕, 👨‍💻, 📈, 🏠 and 💪. Enjoy my articles on all of these topics.