I’m new to programming, i won’t become a developer but I like to learn a few stuff, since i’m a creative artist. I’m trying to solve an exercise I came up with.
I’m looking for guidelines to create a 1 pixel image from code. I want to try to create the most basic form of a white image, and I thought that a lossless 1 pixel gif of white (#FFFFFF or RGB 255, 255, 255) could be the simplest form, generating the smallest code possible.
Where would I even start?
I created two 1 pixel white .gifs, one in Paint and another in Photoshop, using 8bit Grayscale color mode. Gave both of them the same name, and when I hash them, both hashes are different, so they are not exactly the same. I also tried exporting from photoshop twice, to different directories, and this time hashes are the same.
My intention is to create the simplest and purest form of that white pixel.
Tips?
2
Answers
In Python, you can use PIL to create an image. Here is the code for what you requested.
The purest, simplest form that is widely readable (GIMP, Photoshop, MS-Paint) is NetPBM IMHO.
Here is a single white pixel – no metadata, no copyright, no EXIF, no creation date, no palette, no checksum. You can create it with a text editor or code:
Save it as
white.pbm
If you want a simple, single, red pixel, save the following as
red.ppm
:The simplest Python to create a white single pixel GIF with PIL is probably:
The simplest Python to create a red single pixel GIF with PIL is probably: