Image to MakeCode Arcade image converter...again

Introducing another image-to-MakeCode-Arcade image converter!

A simple Python script that can accept images and :sparkles: multi-frame GIFs :sparkles: (that’s what makes it special) and turn them into a MakeCode Arcade image / image array!

The code to actually turn an image into a 16-color palette was based on @kristianpedersen’s Convert-Image-to-MakeCode-Arcade-Sprite web tool.

Easy to install* (all requirements are in the requirements.txt file) and all contained in one (giant and ugly) script! Python and command-line knowledge is highly recommended to use this tool. Should be self-explanatory - run with -h to view the help.

When you convert a single image, you can copy and paste the entire image and paste it in the image editor. But for animations, you must go to text mode and paste in the array.

And here’s a simple program to display a soundless video with MakeCode Arcade - beware that it contains over 195k lines! It’s a 3-minute video that has over 2k frames at 10FPS - it took 10 minutes to render!

(If you find the actual video I used and play it along it stays in sync so you can jam along to the audio as well! :smiley: The play animation block will compensate for time lost!)

And here’s a smaller one that you can see in blocks: (unfortunately the animation block turned into an array block :frowning:)

Enjoy!


* If you have at least Python 3.9 installed.

4 Likes

Will try this, thanks !

1 Like

I’m sorry how do we use it tho? Do we install PYTHON and run it there, or is there a website like @kristianpedersen 's web tool?

1 Like

how exactly do you use this, everytime i click it it takes me to the github code and honestly i dont understand github stuff (and by the way your two gifs especially the first,are AMAZING)

1 Like

It is unfortunately not a website, you must install python 3.9 or newer and download and run the script. Before running you also need to install the requirements with pip.

Ah ok so do I install these on my laptop ?

And what is pip

Hi @UnsignedArduino, great tool for convert gif!

I got this error, when converting a gif

And adding last 2 lines of following it passed

                if isinstance(pixel, int):
                    pixel_color = index_to_color[pixel]
                elif len(pixel) > 3:
                    pixel_color = pixel[:-1]  # Skip alpha
                else:
                    pixel_color = pixel

1 Like

To install on your laptop, install Python 3.9 (or newer) to your computer. Then download the script to your computer. Then use pip (the program is usually installed when you install Python) to install the dependencies in requirements.txt with pip install -r requirements.txt. (Make sure you cd to the directory where you downloaded the files before running the above command) Then you can run the script with python main.py. You may want to run with -h (python main.py -h) to print the help.

Can I still do this on chromebook ?

You could do it on repl.it maybe…

Ah ok thanks I’ll try and see if that works

1 Like

@UnsignedArduino I keep running into this little error. Any solutions for this, I’m not very familiar with Python.
Screen Shot 2022-07-14 at 11.24.18 PM

Hmmm…wonder what I meant to type there lol. You should be able to just delete that line, it’s just for debugging.

2 Likes

I guess Python doesn’t like me today. This is a little confusing.

1 Like

That’s really confusing, as it’s defined several lines up before. Try recopying the contents of main.py from the repo into that file.

Okay, some progress. Any idea how this happened?

That’s very confusing! Can you send me the image/GIF you are trying to convert??? It might be faster to do it that way so I can debug it faster on my machine instead of telling you to do stuff.

2 Likes

0001-0050 (1)

2 Likes

Ah I’ve figured it out! It was something I’ve copied and pasted a long time ago and never fixed it, now it should work! (recopy the script from GitHub)

Note that, the only way that it would happen is that you didn’t specify an output file with -o, so it will spam it to the console. Maybe you should specify one, so the whole command would look like this:

py main.py -i "petpalace.gif" -o "petpalace.txt" -g
1 Like