1

i have gimp 2.10.22 on Kubuntu.

I want a one pixel png image with r=102 g=127 b=128 a=128

I know about "add alpha channel". I have played with "add layer mask", setting opacity on various tools, tried the range tool and other tools with add layer mask. I know about edit layer mask / show layer mask / apply layer mask

I just can NOT get a pixel with alpha of 128.

Everything I try gives me a weird alpha value. Sometimes too low, sometimes too high, or 0 or 255 but can't get 128 to save my life.

It looks ok, but when I apply the layer, or look at the tool result with the color picker tool, the alpha is not what I tried to get.

Is gimp just this hard to use (so many settings with bad defaults) or am i dumb (a veryyyy real possibility)

thanks for any help you can throw my way.

EDIT - given that the gradient tool DOES have alpha values you can pick in the from and to point, I figured it should work.

I put in my exact r,g,b,a values into both the from and the to point and picked linear gradient. Then had to click on one of the points and THEN hit ENTER to apply it (I'm def blaming the devs on unusability here)

Nope - alpha turned into 64. Then I noticed opacity was at 50% for the gradient tool.

Set it to 100%, set r,g,b,a in both from and to points, reclicked a point, hit ENTER to apply

Nope - alpha turned into 160.

Anybody know how to file a bug. That's gotta be a bug??

At least I can keep adjusting until I figure out the magic opacity to not change my dang alpha.

Is there something I don't get here. Cuz there sure seems like it.

7
  • 1
    I can't recreate the problem. RGB 102,127,128 = #667F80. If I set the pencil tool with that colour to 50% opacity in the tool options, the result is a pixel with RGBa,102,127,128,128. see screenshot
    – Billy Kerr
    Commented Aug 19, 2021 at 8:35
  • 1
    Same with colour picker (while holding down shift). See Screenshot
    – Billy Kerr
    Commented Aug 19, 2021 at 8:57
  • ok. you must have started with a pixel that was fully transparent. I see that the opacity value of 0-100 does make alpha=128 =iif= the original alpha of the pixel is 0 (or 1 or super low). That does get me what I need. But what if I wanted an alpha=127... Even starting from an alpha=0 pixel, getting an alpha=127 from opacity=0-100 is gonna be a lotta guesswork :( I guess gimp just won't be a good icon editor :( Commented Aug 19, 2021 at 16:04
  • 1
    yes I began with a fully transparent layer. You can add a pixel at half opacity (in the Pencil tool options), or set half opacity (50%) in the layer opacity. Either gets the same result. For more accuracy you can use fractions in the percentage opacity. So for example 49.8% will give you an Alpha of 127. See example
    – Billy Kerr
    Commented Aug 19, 2021 at 16:14
  • Ok so the key is starting with a fully transparent alpha (add layer mask and pick black i guess?) Then use opacity's fractional amount to translate standard alpha of 0-255 into gimp's 0.0-100.0 (and leave layer mask at 100% or whatever) This is still pretty annoying. But at least it gets me what I need. Thank you ! If ya can make an answer, I'll repick the answer to your's. Although the actual alpha calc is very nice to have. I haven't tested alphas in the final .png yet... Commented Aug 19, 2021 at 16:27

3 Answers 3

3

First of all, alpha usually ranges from 0 to 100 in GIMP. So when you say 128 opacity, I'm assuming you mean half opacity.

I created a 8-bit precision linear light 72 DPI 1-pixel image. Then I changed the foreground color to 102,127,128. Then, I selected the Pencil tool and set its opacity to 50%. After setting "Aspect Ratio" and "Angle" to zero, and "Force" to 100%, and unchecking all the checkboxes, I clicked the image. And the "Pointer Information" tool told me that the pixel was 102,127,128,128. Isn't that exactly what you want?

I'm using the exact same version of GIMP as you - 2.10.22. My OS, though, is Windows 10. Maybe try doing exactly what I did?

1
  • I tried what you did and it did work! But when I clicked again, the alpha changed higher than 128. So what's happening is that the fiinal alpha of the pixel DEPENDS on the opacity=0-100 you pick AND the original alpha of the pixel :( That's kinda ok for setting alpha=128. But what if I needed, say 127... Getting there is gonna be a pain. My conclusion is that gimp is just gonna be terrible as an iicon editor (what i need) Alpha should be directly settable SOMEhow between 0-255 on each pixel... Commented Aug 19, 2021 at 16:11
2

Quick answer: best solution is to create a 1-pixel layer, set its opacity to 50% using the slider at the top of the Layers list, and export.

Now, about your problem: since Gimp 2.10, the layer mask is gamma-corrected(*). In other words, the true alpha is mask^2.2. So if you want a half-transparent pixel the mask value is (^ is the power/exponent operation):

0.5 ^ (1/2.2) = 0.5 ^ 0.454545 = 0 .73

(or 186 in the 0..255 notation). And you can check that despite this value in the mask, if you export to PNG, the PNG will indeed have Alpha=.5.

If you don't want to compute this, you can obtain it this way:

  • create a plain layer
  • use the opacity slider to set it to the require opacity
  • Edit > Copy visible, File > Create > From clipboard
  • Layer > Mask > Add layer mask and Transfer alpha channel
  • Use the Pointer dialog (with deselected Sample merged) to check the mask value.

(*) this stems from the big change in Gimp 2.10 where computations are done on "linear light" values. In previous versions, Gimp worked directly on the gamma-corrected values (because JPG/PNG are natively gamma-corrected) but this creates nasty problems (for instances, color gradients will get dark in the middle). Some of the old behavior can be restored using the "Standard/Legacy" layer mode selector (small selector at the end of the Layer mode selector) but not how the mask is handled.

2
  • Hmm, well that'll work for a 1 pixel image (my question). In general, I'm trying to edit clip art for my application. It looks like gimp is just not able to "directly" set alpha of a pixel to what I want. It has all this opacity=0-100 instead of setting the dang alpha to 0-255 as stored in a png. I wonder which app is used on linux for icon editing sigh. Thanks for your explanation ! Commented Aug 19, 2021 at 16:17
  • 1
    @StephenHaze. It is possible to set the alpha exactly in GIMP. See my latest comment under your question.
    – Billy Kerr
    Commented Aug 19, 2021 at 16:19
1
  1. Create a new image, and make sure the background is set to transparent. Here's an example, I made a new 3px x 3px, transparent document.

enter image description here

If you forgot to do this and started with a solid white background layer, no worries, you can just delete the background layer in the layers panel, and add a new transparent layer instead. You can add as many transparent layers as you like. GIMP is layer based. Everything happens on layers.

If you can't see the Layers panel, hit Ctrl+L to bring it up, here's what you want to see, a layer thumbnail with the checkered pattern, this indicates transparency.

enter image description here

enter image description here

  1. Now to get to your specific problem. Set the foreground colour to RGB 102,127,128 = #667F80

enter image description here

  1. Select the Pencil Tool in the toolbox, select the 1px Brush

  2. In the Tool Options, set the opacity to what you want. For example 50% alpha = 128, or 49.8% = 127

enter image description here

  1. Now, back in the image paint a pixel

  2. Select the colour picker tool, and Shift+Click on the pixel, and check it.

enter image description here

2
  • thankyou! it's that 49.8=127 bit and the tool being affected by the EXISTING r,g,b,a values that I didn't get. Commented Aug 19, 2021 at 16:52
  • 1
    Yeah it's not nearly as complicated as you thought. I guessed right. Great! Glad you got it now.
    – Billy Kerr
    Commented Aug 19, 2021 at 16:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.