soiz1 commited on
Commit
7e0c692
·
verified ·
1 Parent(s): f675396

Update forensics/ela.py

Browse files
Files changed (1) hide show
  1. forensics/ela.py +3 -1
forensics/ela.py CHANGED
@@ -40,6 +40,8 @@ def ELA(img, quality=75, scale=50, contrast=20, linear=False, grayscale=False):
40
  Processed ELA image
41
  """
42
  # Convert image to float32 and normalize
 
 
43
  original = img.astype(np.float32) / 255
44
 
45
  # Compress image
@@ -61,4 +63,4 @@ def ELA(img, quality=75, scale=50, contrast=20, linear=False, grayscale=False):
61
  if grayscale:
62
  ela = desaturate(ela)
63
 
64
- return Image.fromarray(ela)
 
40
  Processed ELA image
41
  """
42
  # Convert image to float32 and normalize
43
+ if isinstance(img, Image.Image):
44
+ img = np.asarray(img.convert("RGB"))[:, :, ::-1] # PIL→BGR
45
  original = img.astype(np.float32) / 255
46
 
47
  # Compress image
 
63
  if grayscale:
64
  ela = desaturate(ela)
65
 
66
+ return Image.fromarray(ela)