With technology evolving and the global situation changing, more and more important deals, transactions, classes, etc are moving online. We have to submit our aadhar card, pan card, drivers license, etc via online mediums on a regular basis for a variety of tasks. With the world moving online, there arises a need to police these highly confidential and important tasks.

Digital manipulation of images has become a serious issue. Sophisticated manipulation is undiscernable to the naked eye. We need to come up with methods that can detect this manipulation automatically. One of these methods is called Error Level Analysis.

Error Level Analysis (ELA) is a forensic method used to identify digital manipulation in images. JPEG (Joint Photographic Experts Group) developed an algorithm to compress (minimize the size) images using a grid of 8×8 squares that are compressed individually. Without manipulation, the squares compress without any errors. However, when manipulation has been introduced, the areas around the manipulation compress at a different rate than the surroundings.

ELA exploits this fact and identifies these areas of different compression. To do this, it resaves the picture at a different compression rate and checks the difference with the original. Using this the algorithm highlights the edited areas in the image.


The following code snippet has been taken from the following GitHub project:


Exdef convert_to_ela_image(path, quality):
    filename = path
    resaved_filename = filename.split('.')[0] + '.resaved.jpg'
    ELA_filename = filename.split('.')[0] + '.ela.png'
    im = Image.open(filename).convert('RGB')
    im.save(resaved_filename, 'JPEG', quality=quality)
    resaved_im = Image.open(resaved_filename)
    ela_im = ImageChops.difference(im, resaved_im)
    extrema = ela_im.getextrema()
    max_diff = max([ex[1] for ex in extrema])
    if max_diff == 0:
        max_diff = 1
    scale = 255.0 / max_diff
    ela_im = ImageEnhance.Brightness(ela_im).enhance(scale)
    return ela_im


Edited image:

ELA performed on image:

As we can see, a dancing bear has been edited into an image of Ronaldo taking a free kick. After performing ELA on the image, the outline of the dancing bear is clearly outlined since significant compression differences have been detected there. This shows the vast applications of ELA in forgery detection and security.

Visits: 736

Leave a Reply

Your email address will not be published. Required fields are marked *