0

I want to generate all possible RGB colors as images and save them to my drive. For testing purposes I only want to generate the first 1000 or so.

It should start by HEX #000000 and go up to #FFFFFF. The images should be 1x1 pixels.

My question now is how would you realize it? What would be the best method for this?

lespucci
  • 29
  • 5
  • Maybe take a step back, consider the impracticalities of what you are going to do with 16 million images, and say what problem you are really trying to solve. You might be better off with a 64x64 image and 3 RGB sliders that each vary between 0..255. – Mark Setchell Jun 14 '20 at 17:32
  • Just trying to create a bot that generates 1x1 images and uploads them to for example Instagram. – lespucci Jun 15 '20 at 06:23
  • There are many ways to achieve this. Here is a curated list of code repositories that do just that: https://github.com/allrgb. – ACJ Nov 09 '20 at 13:35

1 Answers1

1

Required only bash and convert from package ImageMagick

#!/bin/bash                                               
LIST=(0 1 2 3 4 5 6 7 8 9 A B C D E F)

for x in ${LIST[*]} 
do
    for y in ${LIST[*]}
    do
        COLOR+=($x$y)
    done
done

for i in ${COLOR[*]}
do
    for j in ${COLOR[*]}
    do
        for k in ${COLOR[*]}
        do
            convert -size 1x1 xc:"#$i$j$k" "color-"$i$j$k.png
        done
    done
done 

effect: complete palette (256x256x256) 16777216 one pixel png images

example:

$ file color-FF0000.png
color-FF0000.png: PNG image data, 1 x 1, 1-bit colormap,non-interlaced

It is necessary to make sure that ImageMagick installation is correct and that the graphics libraries required by it exist.

Slawomir Dziuba
  • 1,265
  • 1
  • 6
  • 13
  • Not quite sure why but I get this error when I run it: https://i.imgur.com/3JItbzz.png – lespucci Jun 14 '20 at 15:55
  • @lespucci maybe here is the solution imagemagick.org/discourse-server/viewtopic.php?t=35098 You can replace .png with .jpg or .gif if you don't have PNG libraries or properly install ImageMagick with all dependencies. – Slawomir Dziuba Jun 14 '20 at 17:02
  • Thanks for now! It works with .gif, I probably need to install the PNG libraries. – lespucci Jun 15 '20 at 06:20
  • @lespucci Thanks are very kind. However, in StackOverflow, it is usual to approve correct solutions instead of thanking. Thanks. – Slawomir Dziuba Jun 15 '20 at 07:10
  • I understand, I will edit my post later and add some code for further assistance/help. I still got some questions. – lespucci Jun 15 '20 at 09:17
  • @lespucci if the questions relate to the current code, it is better to ask them in the comment, I will gladly answer. However, if the meaning of a question is to be changed, it is better to ask a new question, because otherwise it is misleading to those who do not know the course of events, such changes of the question after the answer are not well received on SO. – Slawomir Dziuba Jun 15 '20 at 10:23