Replit changes RGB pixel values

Bug description:
When you change a pixel in an image and save it as a file in replit, it can change that pixel so it isn’t the same when you read the pixel again.

Expected vs Current Behavior:
It should return the same pixel

Steps to reproduce:
Open an image
Change the first pixel to (2,1,0)
Save the image
Open the image again
The first pixel is not equal to the (2.1,0)

Bug appears at this link:

Screenshot(s)/Screen Recording:

Browser/OS/Device: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36 Edg/

Replit Profile:

Might be an issue with the Python library or your code, have you tried the code on your on machine?

Alright, the issue is that you don’t change the filename variable.

import Image # PIL.Image
filename = "dillon.png" #filename of an image
  img = the file
  raise IndexError("File does not exist")#If the filename isn't found, return an error
img_size = img.size# Get the image file size
arr = list(img.getdata()) # Get the rgba pixels of the image
arr[0] = (2,1,0,255)#Setting the first pixel in the image to a random color
im2 ="RGBA", size=img_size)
im2.putdata(arr)"new.png")#Making new image called "new.png"
#you never rename the filename, still dillon.png
#so add:
filename = "new.png"
img = new.png
arr = list(img.getdata())#Getting list of pixels
print(arr[0])#printing first pixel
1 Like

Thank you so much. This was actually for another program, but I realized I messed up 3 lines in that program and it was not replit.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.