Script to make 1-color images
Posted: 2011-09-04T21:07:55-07:00
Hi,
Just for fun (and thinking about a pixel-test program in the long run) I wanted to generate a series of 1920x1080 images that are each one color, 16 million + images, the colors ranging from #000000 to #FFFFFF. So of course I'm not going to do this by hand, it's a perfect job for a script. I'm starting with an image called base.jpg that is 1920x1080 and a uniform background of #000000. Here's the script (doing just #000000 to #00000F for testing purposes):
#!/bin/bash
for((i=0;i<16;i++))
do
f=$(printf "#%.6X" $i)
g=$(printf "%.6X" $i)
convert base.jpg -background $f -compose Dst -flatten $g.jpg
done
When I run this, I get the images 000000.jpg - 00000F.jpg, but the don't have the correct background values.
000000.jpg and 000001.jpg both have pure black backgrounds (#000000)
000002.jpg and 000003.jpg both have backgrounds of #000002
000004.jpg has background #000004
000005.jpg has background #010005
000006.jpg has background #010006
000007.jpg has background #000106
000008.jpg and 000009.jpg have background #000008
00000A.jpg and 00000B.jpg have background #00000A
00000C.jpg and 00000D.jpg have background #00000C
00000E.jpg and 00000F.jpg have background #01000E
Based on what I was reading on the Usage pages (http://www.imagemagick.org/Usage/canvas/#specific), I also tried using the convert line
convert base.jpg -fill $f -draw 'color 0,0 reset' $g.jpg
but the results were the same (exactly the same).
Since the file names are correct, the value being put into -background should be correct (and the same as the file name just with the # in front of it).
Does anyone have an idea why this isn't working the way I expect it to?
$ convert -version
Version: ImageMagick 6.4.0 01/19/10 Q16 http://www.imagemagick.org
Thank you so much,
J.F.H.
Just for fun (and thinking about a pixel-test program in the long run) I wanted to generate a series of 1920x1080 images that are each one color, 16 million + images, the colors ranging from #000000 to #FFFFFF. So of course I'm not going to do this by hand, it's a perfect job for a script. I'm starting with an image called base.jpg that is 1920x1080 and a uniform background of #000000. Here's the script (doing just #000000 to #00000F for testing purposes):
#!/bin/bash
for((i=0;i<16;i++))
do
f=$(printf "#%.6X" $i)
g=$(printf "%.6X" $i)
convert base.jpg -background $f -compose Dst -flatten $g.jpg
done
When I run this, I get the images 000000.jpg - 00000F.jpg, but the don't have the correct background values.
000000.jpg and 000001.jpg both have pure black backgrounds (#000000)
000002.jpg and 000003.jpg both have backgrounds of #000002
000004.jpg has background #000004
000005.jpg has background #010005
000006.jpg has background #010006
000007.jpg has background #000106
000008.jpg and 000009.jpg have background #000008
00000A.jpg and 00000B.jpg have background #00000A
00000C.jpg and 00000D.jpg have background #00000C
00000E.jpg and 00000F.jpg have background #01000E
Based on what I was reading on the Usage pages (http://www.imagemagick.org/Usage/canvas/#specific), I also tried using the convert line
convert base.jpg -fill $f -draw 'color 0,0 reset' $g.jpg
but the results were the same (exactly the same).
Since the file names are correct, the value being put into -background should be correct (and the same as the file name just with the # in front of it).
Does anyone have an idea why this isn't working the way I expect it to?
$ convert -version
Version: ImageMagick 6.4.0 01/19/10 Q16 http://www.imagemagick.org
Thank you so much,
J.F.H.