← Back to Community
How do I include image data in raw code. (Python)
Profile icon
CrispyYeeto

Although I am not using Replit python, I am curious on how to include image encoding into the code itself. For example, Willards MineKhan uses this method for his Minecraft textures. He stores it in the code in the form of a string:

""0g0g70ordrzz0u30g730wa4vzz0xnyl8f11lrk7315qj7jz1fh47pb6553365533033636350335403653650063306333633300635163503655353653535605335031350330553500033033366333433663663535336655335055335553353530355333033503300333336635353663650660554353355635155305303053556333333366353323553060365553063030663533555365534355335530"

How can I use this method for creating my own images built into code, but in Python?

And how would I translate this into an actual image to be used?
I want to be able to skew and manipulate the data in the most efficient way possible, without relying on external assets.

Voters
Profile icon
CrispyYeeto
Comments
hotnewtop
Profile icon
RYANTADIPARTHI

use the PIL package for image data.

Profile icon
robowolf

You can use PIL to convert numpy arrays to images. https://www.geeksforgeeks.org/convert-a-numpy-array-to-an-image/

Profile icon
Dimosin654

@robowolf Please can you explain it to me better?

Profile icon
robowolf

@Dimosin654

from PIL import Image im = Image.fromarray(*numpy array*)
Profile icon
Dimosin654

@robowolf Ok ,tank you