I am generating random data and trying to convert it to a PNG image using :head -c 1MB < /dev/urandom | hexdump -e '16/1 _x%02X' | sed 's/_/\\/g; s/\\x  //g; s/.*/    &/' | tr -d \ | display -depth 8 -size 1000x1000+0 rgb:-This command always shows a greyish image with some RGB pixels. What am I doing wrong ?My final goal is to generate at least one image with random data.
Random image generator
command line;display;images;random
Firstly, you need to feed display RGB:- raw bytes, not an encoded hex string like you're building with that hexdump | sed | tr pipeline.Secondly, you aren't giving it enough bytes: you need 3 bytes per pixel, one for each colour channel.This does what you want:mx=320;my=256;head -c $((3*mx*my)) /dev/urandom | display -depth 8 -size ${mx}x${my} RGB:-To save directly to PNG, you can do this:mx=320;my=256;head -c $((3*mx*my)) /dev/urandom | convert -depth 8 -size ${mx}x${my} RGB:- random.pngHere's a typical output image:If you'd like to make an animation, there's no need to create and save individual frames. You can feed a raw byte stream straight to ffmpeg / avconv, eg mx=320; my=256; nframes=100; dd if=/dev/urandom bs=$((mx*my*3)) count=$nframes | avconv -r 25 -s ${mx}x${my} -f rawvideo -pix_fmt rgb24 -i - random.mp4