Jump to content

How to delete transparent pixels from an image?

Recommended Posts

I have an image, but it has both opaque, half-transparent (anywhere between a visibility of 1% to 99%) and transparent pixels. Can I convenietly delete any pixel with a transparency of 1% to 99% (not fully transparent and not fully opaque)?

Link to comment
Share on other sites

Here is a CodeLab script to do what you want:


// Name: Transparency Threshold
// Submenu: Adjustments
// Author: BoltBait
// Title: Transparency Threshold v1.0
// Version: 1.0
// URL: https://forums.getpaint.net/topic/119839-how-to-delete-transparent-pixels-from-an-image/
// Help: Copyright (C)2022 BoltBait
#region UICode
IntSliderControl Amount1 = 128; // [0,255] Threshold
CheckboxControl Amount2 = true; // Maximize alpha of remaining pixels

void Render(Surface dst, Surface src, Rectangle rect)
    ColorBgra currentPixel;
    for (int y = rect.Top; y < rect.Bottom; y++)
        if (IsCancelRequested) return;
        for (int x = rect.Left; x < rect.Right; x++)
            currentPixel = src[x,y];

            if (currentPixel.A <= Amount1)
                currentPixel.A = 0;
                if (Amount2)
                    currentPixel.A = 255;
            dst[x,y] = currentPixel;



If someone gave you a CodeLab script and just want to know what to do with it, read this: 



Enjoy. :beer: 


  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...