using pixel color value to set parameters.

hello hello. this is what im trying to do.
gmic ima.jpg -resize2dx 400 -colormap 2,1,2 -resize2dy 2,1
this gives me a 2x1 pixel image.
i would like to generate a bigger picture (like 1024x1024) using the brighter pixel color of the two and print text on top using the color of the other one.
so far i didnt succeed and tbh im a bit lost.
thanks in advance. lulu

For me, this gives a 4x2 RGB image (because of the resize2dy 2,1 applied on a 2x1 image).

Otherwise, I suggest (added double quote to avoid bash substitution, may differ depending on the shell you use):

$ gmic sp colorful r2dx 400 colormap 2,1,2 s x r[0] 1024,1024 t[0] \"Hello my friends\",0.5~,0.5~,100,1,"{I(#1)}" rm. o output.png

which renders this:

I like the font. (The kerning of ello is a little off.) Did you upgrade it at some point? I forget.

thanks. splitting on x is nice. but could you explain this : β€œ{I(#1)}” . this is the tough part.

The bracket means to evaluate via the math parser. β€˜I’ means color array at point x,y,z. If it was i instead, it mean value at point x,y,z,c. # means the image index. As there is no argument next to it indice, it takes the color array at point 0,0,0. The math parser takes the array as a set of argument just as if you were doing it by hand.

oh ok thanks. i have to learn all that precisely.

1 Like

You can do sp cat,lena echo {I(#indice)}. Then zoom in at top left and hover your mouse at the image corner. Replace indice with 0 or 1 or -2 or -1. It’ll be easier to understand doing this.