Is there a way in Linux to create an image and construct it pixel by pixel directly in command line?
I tried imagemagick, but its only possible to create a blank image without set pixels seperate.
Any Idea?
Ok, so we start with a red pixel:
convert xc:red image.png
I'll enlarge it - it is rather small.
Now we get a blue one and want to add it:
convert image.png xc:blue +append image.png
Then someone gives us an RGB pixel:
convert image.png xc:"rgb(255,255,0)" +append image.png
Now some trouble-maker comes along with an HSL pixel:
convert image.png xc:"hsl(120,100,100)" +append image.png
Be careful not to use JPEG though as it is lossy.
You can use shell scripting to build a ppm image.
echo "P2"
echo "# Column (width) Row (height)"
echo "$1 $1\n1"
t=`expr $1 / 8`
for i in `seq 1 4`; do
for i in `seq 1 $t`; do
for i in `seq 1 4`; do
for i in `seq 1 $t`; do echo -n "1 "; done
for i in `seq 1 $t`; do echo -n "0 "; done
done
echo
done
for i in `seq 1 $t`; do
for i in `seq 1 4`; do
for i in `seq 1 $t`; do echo -n "0 "; done
for i in `seq 1 $t`; do echo -n "1 "; done
done
echo
done
done
To run the above code do:
$ sh filename.sh 120 > im1.ppm ; eog im1.ppm
The result is: enter image description here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With