Turn ANY image into pixel art (literally any image)

(edit: it just creates the image u upload into roblox, just millions of pixels!)

I was looking around for a “image to pixel art” in roblox cause i was bored.

I found one but it was horrible to be honest, so I made my own.

Examples

When using scale of 35:


Little note, the bigger the more trouble you’re going to have to paste the data into roblox:

When using scale 15:

I wanted to go and use 100% scale, but it would probably just crash roblox

This uses python to actually spit the image data out!

How to use it:

Download and put this into ServerScriptService
loader.rbxm (1.8 KB)

Then make sure u have python installed and then just copy and paste this code:

CODE
from PIL import Image

def imgmaker(image_path, scale_percentage):
    image = Image.open(image_path)
    width, height = image.size

    new_width = max(1, int(width * scale_percentage / 100))
    new_height = max(1, int(height * scale_percentage / 100))

    resized_image = image.resize((new_width, new_height))
    pixels = resized_image.load()

    data = []

    for y in range(new_height):
        for x in range(new_width):
            r, g, b = pixels[x, y][:3]
            position = [x * 2, 0, y * 2]
            data.append([r, g, b] + position)

    lua_table = f"local data = {str(data).replace('[', '{').replace(']', '}')}"
    return lua_table

image_path = input('image path: ')
scale_percentage = int(input('scale (1-100, lower means worse quality): '))
lua_table = imgmaker(image_path, scale_percentage)

with open('output.lua', 'w') as file:
    file.write(lua_table)

After all of that, just run the python and go on from there.

tutorial if u dont know how to use the code


And literally just copy and paste the output into the ModuleScript

I guess any image is pixel art, just with millions of pixels.

4 Likes

You could also use this: Pixel It - Create pixel art from an image.

All you need to do is upload an image and then it’s automatically pixelized.

I know it’s not through Roblox, but it works just as good- if not, better.

1 Like

additionally, here are some pixel programs that i use:

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)
1 Like

This is actual “pixel art”. (Or a sprite, sprites count as pixel art)
spr_cutscene_14_spamton