if you’re going to do image processing in python, you should use numpy
python is infamous for being slow with loops
import numpy
from PIL import Image
from time import time
def imgmaker(image_path, scale_percentage):
image = Image.open(image_path)
stopwatch = time() # benchmark starts here
image = image.convert("RGB") # remove alpha chanel
width, height = image.size
new_width = max(1, int(width * scale_percentage / 100))
new_height = max(1, int(height * scale_percentage / 100))
image = image.resize((new_width,new_height),resample=Image.Resampling.NEAREST) # resize using pillow
# numpy processing example
numpy_image = numpy.asarray(image,"uint16") # to numpy array, i chose uint16 to prevent overflow when multiplying
numpy_image = numpy_image * 1.5 # for example, we can tell numpy to brighten up the image by a scalar value with minimal overhead
numpy_image = numpy_image * [1.0,.4,1.0] # maybe i want to multiply the blue channel by .4
# convert back to pillow
numpy_image = numpy_image.clip(0,255).astype("uint8") # convert back to u8 becuase the array is a float since we multiplied by 1.5
result = Image.fromarray(numpy_image)
print(time() - stopwatch) # end benchmark here, with a 1024x1024 image with scale 100, it takes 0.05 seconds
result.save("output.png") # upload to roblox, ImageLabels have an option called "ResampleMode" which enables the pixel effect to be shown
image_path = input('image path: ')
scale_percentage = int(input('scale (1-100, lower means worse quality): '))
output = imgmaker(image_path, scale_percentage)