Jump to content

Programmatically import image as PNG with ALPHA channel


Recommended Posts

Hello,

Is there a way to programmatically import an image as png with alpha channel, without showing up the import dialog as in:

def vs.ImportImageFileN(filePath, importPt, mode):
    return HANDLE

I am aware of:

def vs.ImportImageFile(filePath, importPt):
    return HANDLE

but I am wondering if there is a way to force the default import preferences (JPEG) as PNG with ALPHA channel.

 

This is needed in my perspective rectifier plugin, where a new image (PNG with ALPHA) is created and imported on the fly.

 

Link to comment

Thank you JBenghiat, it works!

Even importing a PNG (with alpha) as JPEG, it maintains its transparency. It appears filled with white, but IT CAN BE set to fill none!

I was (for years) convinced that JPEGs couldn't have alpha channels, but I was wrong 🤔

 

Link to comment

If all white pixels become transparent, well, this is not so good.

In the PNG with alpha there could be white pixels that must remain opaque!

 

I have to test it…

I fear, in the end, I have to show up the import dialog to the user, instructing him to choose PNG with ALPHA option…

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...