The Meaning of Life, the Universe, and Everything.
So I recently came across a video (and the livestream) by PhoenixSC, which showcased an interesting idea - flipbooks in Minecraft. As I saw a lot of people liking the idea of flipbooks and wanting to try it out themselves, I thought it would be really cool if there was a script which automatically converts a GIF in to a flipbook. So, I decided to create it myself.
In order to run the script, you will need to have Python 3.6+ installed on your computer (I decided to keep it in this format, so people wouldn't be suspicious of it, as they can just check the source code). You also need a terminal - the default command line (cmd.exe).
After you install Python, you need to run one important command. Open up the command line (or any other terminal) and type:
pip install Pillow
This will install a package called 'Pillow', which is used to get information about the GIFs.
To use the script - after you install it - place it in a folder. After you place it there, click on the folder path at the top, and type 'cmd' (without the quotation marks, in fact, everywhere where I put the quotation marks, they shouldn't be included), it will automatically open up the command line with the current working directory being the folder (which is what you want). After you open up the command line, type: [path to Python] gif2flipbook.py [name of a GIF in the same folder].gif [mode]
[path to Python] - system path to Python (you can usually just type 'py' or 'python' there, which are the default paths to Python)
[GIF in the same folder] - the name of the GIF file you want to convert in to a flipbook (it has to be in the same folder as your 'gif2flipbook.py' file)
[mode] - the mode in which the GIF should be converted to a filpbook, use '-ascii' if you want it to be converted in to ASCII characters, or use '-colors' if you want to use it with colored squares (which look like pixels)
py gif2flipbook.py example_gif_file.gif -colors
Let's talk about what you can adjust with the script (the actual code): # You can change these to anything you want
author = ""
title = ""
target = "@p"
Here you can change anything you want, author is a variable in which you can type anything acceptable by Minecraft, and it'll be shown as the author of the book. title is a variable in which you can type anything acceptable by Minecraft and it'll be shown as the title or the name of a book. Lastly, we have target, which is the player to which the book will be given. It is allowed to use selectors or player names. To change the variable, click in between the double quotes and type anything you want in between them - don't worry, the double quotes won't be shown to the user.
The output will be written in a text file called 'gif2flipbook output' (you don't need to create it before hand, the script will automatically create it if it doesn't already exist), which will be placed in the same location as the 'gif2flipbook.py' file. The contents in this file will resemble those of a mcfunction, it is recommended that you copy and paste the output into a mcfunction, as there is no command length limit there (genius idea by nickftw - one of the viewers of the video I mentioned earlier) and it may also contain multiple give commands if the GIF has more than 100 frames (as Minecraft books can store up to 100 pages). You just need to run the mcfunction (which you have to put in to the world's data pack folder) and you'll get the book(s)!
Some GIFs may take longer to process (in almost every case, it should take less than a minute), even though the actual limit on how large a GIF file can be is over 6500000 frames.
A video by PhoenixSC showcasing some stuff you can create using the '-colors' mode:
That's it, you've mastered how to use the script! If you have any problems, just leave a comment down below, and I will try to help.
P.S. Thanks for everyone who has shared many useful tips about Minecraft and how it handles stuff - main credits go to: PhoenixSC (realized the original idea, and pointed out some bugs - also creator of the video) & nickftw (gave me some tips about command limit length, which helped me improve the program by a lot)!