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?
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?
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
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.
-background none
and use -append
in place of +append
.... –
Ursulina convert image.png -fill blue -draw "point x,y" image.png
–
Ursulina awk
or Perl too... https://mcmap.net/q/1923200/-create-a-png-file-from-lat-long-value –
Ursulina 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
© 2022 - 2024 — McMap. All rights reserved.