Version: 1.0
Build 1.0
The DictoImage framework aims to be an alternative to standard image formats
by creating images in a List-Dictionary format.
Dictoimage works by converting (or not) your image to a format that is like that
example_canvas = [
{
"HexValue": "#ffffff",
"Alpha": 255,
"Position": (0, 0)
},
...
]To get started with DictoImage, here is a step-by-step guide:
- Import
dictoimage, - You can then define two variables, I'll call them
canvasandpixel, - Define the values of those variables to be respectively:
dictoimage.Pixelspecial note: Pixel requires a RGBA tuple colour, and a position tuple when initialized.dictoimage.PixelCanvasspecial note: PixelCanvas requires a size (height, width) tuple when initialized.
- Print the value of your
Pixelusing theGetPixel()function. - Repeat the process with identical or different values for Pixels.
- When you judge there is enough pixels, initialize your
PixelCanvaswith a size that can only be a power of 2 (ideally). - Then add your pixels to the
Canvasusing theAddPixel()function. This function requires as argument thePixelyou want to add. - Once this is done, print your
Canvasusing theGetCanvas()function.
However, if you want to create a Canvas from a PNG for example, then you can use the files provided below:
png_to_dictimage- If you want to turn a PNG into a dictoimage.⚠️ Large images will take a while to process.
This will generate a canvas.dim file (which is the dictoimage file) and a canvas.dim.hdr file (which is the header that contains the size, required for conversion to PNG)dictoimage_to_png- If you want to turn a dictoimage file into a PNG. It will generate the PNG file asoutput.png.
Q: A canvas is too large, how can I reduce the size?
A: There are actually two ways of doing that:
- Reducing the resolution of the input (if you converted from PNG).
- Using the
pack_image()function from thepacker.pyfile.
Q: How to unpack a packed canvas (in the format of a .cdim)?
A: The process is pretty straightforward: instead of using the pack_image() function from the packer.py file,
use the unpack_image() function with the path of your compressed canvas.
It will give you the Canvas file (marked by a .dim extension) and the respective header (marked by
a .dim.hdr extension).
Q: It doesn't work!
A: Please check your python version first using python --version (or python3 on linux), the version may be incorrect.
The code works only under Python 3.10, 3.11 and 3.12. Upgrade to those if you use a lower version.
If it does nothing, then open an issue with the error message.
Q: The code says that x module is missing.
A: Before opening an issue for a ModuleNotFoundError, please check the requirements.txt file first.
And install the missing dependencies using pip install -r requirements.txt (or pip3 on linux.)
