Jump to content
You must now use your email address to sign in [click for more info] ×

Recommended Posts

Hi all,

I've got a python warning telling me :

"UserWarning: Palette images with Transparency expressed in bytes should be converted to RGBA images"

when I use a png image with transparency in my routine.

How can I convert (export ?) my png file in order to bypass that warning message ?

Here is my source file :

image.png.4cacd831041344a8a3984a098a896a4b.png

Here is the file I get with my routine :

image.png.a1b46da36c75c558b10692039adecb38.png

There is a problem, I lose my transparency (see green px)…

Thanks for your help.

MacBook Pro 16 pouces (3456 × 2234), 2021 / Apple M1 Pro / 16 Go / macOS Ventura Version 13.4.1 (22F82)
+ 31,5 pouces (2560 × 1440) + 27 pouces (1080 × 1920) + iPad (8th generation) / iPadOS 17.2 + Apple Pencil + 

Macmini6,2 Quad-Core Intel Core i7 16 Go / macOS Catalina version 10.15.7 (19H2026)
MacBookAir6,2 Intel Core i5 double cœur 4 Go / macOS Big Sur version 11.7.7 (20G1345)

Licence Universelle Affinity V2 updated to 2.3.0

Link to comment
Share on other sites

If you Open your PNG in Affinity Photo 2, what color format is shown in the Context Toolbar?

-- Walt
Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases
PC:
    Desktop:  Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 

    Laptop:  Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU.
iPad:  iPad Pro M1, 12.9": iPadOS 17.3, Apple Pencil 2, Magic Keyboard 
Mac:  2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.3

Link to comment
Share on other sites

Hi Walt,

 Here is what I've got with my original affinity file :

image.thumb.png.622766002b5e646d2d9451fb361589ba.png

Here is what I get when I export to a png file with affinity :

image.thumb.png.234b72880ea05a8a12b924aaf8709ce1.png

And here is what I get if I open back in affinity photo 2 the file I get after using a python routine :

image.thumb.png.9c23ce435c71d09c5cb09fc4c4efd7ad.png

Is that the information you wanted ?

MacBook Pro 16 pouces (3456 × 2234), 2021 / Apple M1 Pro / 16 Go / macOS Ventura Version 13.4.1 (22F82)
+ 31,5 pouces (2560 × 1440) + 27 pouces (1080 × 1920) + iPad (8th generation) / iPadOS 17.2 + Apple Pencil + 

Macmini6,2 Quad-Core Intel Core i7 16 Go / macOS Catalina version 10.15.7 (19H2026)
MacBookAir6,2 Intel Core i5 double cœur 4 Go / macOS Big Sur version 11.7.7 (20G1345)

Licence Universelle Affinity V2 updated to 2.3.0

Link to comment
Share on other sites

Yes, thanks. But I have no idea what's going on. Sorry.

-- Walt
Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases
PC:
    Desktop:  Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 

    Laptop:  Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU.
iPad:  iPad Pro M1, 12.9": iPadOS 17.3, Apple Pencil 2, Magic Keyboard 
Mac:  2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.3

Link to comment
Share on other sites

28 minutes ago, laurent32 said:

And here is what I get if I open back in affinity photo 2 the file I get after using a python routine :

I think the important step here is “after using a python routine”.

We don’t know what the python routine needs, or what it is doing, or what it’s supposed to do, so we can’t know what it needs, or should change, or has changed.

If you can upload the python routine then a python expert may see it and give further advice, but without it we’re pretty much in the dark.

Link to comment
Share on other sites

Yes @GarryP, the problem might come from one of the packages I use in my .py routine (PIL)…

First I wanted to check if I was missing something evident in Affinity photo 2.

I'll send part of my routine in an upcoming post.

MacBook Pro 16 pouces (3456 × 2234), 2021 / Apple M1 Pro / 16 Go / macOS Ventura Version 13.4.1 (22F82)
+ 31,5 pouces (2560 × 1440) + 27 pouces (1080 × 1920) + iPad (8th generation) / iPadOS 17.2 + Apple Pencil + 

Macmini6,2 Quad-Core Intel Core i7 16 Go / macOS Catalina version 10.15.7 (19H2026)
MacBookAir6,2 Intel Core i5 double cœur 4 Go / macOS Big Sur version 11.7.7 (20G1345)

Licence Universelle Affinity V2 updated to 2.3.0

Link to comment
Share on other sites

This png file gives the problem :

image.png.a5bce2911ecd678590a6c40519c4019e.png

While this one doesn't :

image.png.c8ee4fc99c4e643c8b765bf29942a7cb.png

They both are png files with transparencies.

I really wonder why they are not treated the same way by my Python routine using the Pillow package for a simple resize ?

Can anyone tell me if there is a difference in the way those 2 files are built ? 

MacBook Pro 16 pouces (3456 × 2234), 2021 / Apple M1 Pro / 16 Go / macOS Ventura Version 13.4.1 (22F82)
+ 31,5 pouces (2560 × 1440) + 27 pouces (1080 × 1920) + iPad (8th generation) / iPadOS 17.2 + Apple Pencil + 

Macmini6,2 Quad-Core Intel Core i7 16 Go / macOS Catalina version 10.15.7 (19H2026)
MacBookAir6,2 Intel Core i5 double cœur 4 Go / macOS Big Sur version 11.7.7 (20G1345)

Licence Universelle Affinity V2 updated to 2.3.0

Link to comment
Share on other sites

The message says you have a palletized PNG file, and alpha channel. It seems that combination causes issues.
To correct, export from APh, but deselected palettierend in export settings. This will then create a regular RGBA image.

Mac mini M1 A2348

LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5

iPad Air Gen 5 (2022) A2589

Special interest into procedural texture filter, edit alpha channel, RGB/16 and RGB/32 color formats, stacking, finding root causes for misbehaving files, finding creative solutions for unsolvable tasks, finding bugs in Apps.

 

Link to comment
Share on other sites

Thanks for the idea @NotMyFault.

The problem is that I did not use the palletized option, I export with the standard png profile :

image.png.6efb5981c6ad6b80c80c73e7078eb58c.png

image.png.0f0470409a17ea04301834a537f2ae38.png

BUT your answer made me remember that i do use ImageOptim to get more compact files.

Here are my ImageOptim prefs :

image.png.659ac10e90dff696408babdaf8fbf289.png

image.png.569df88c6ab030262bbd968218e2bbb2.png

image.png.3c7f21f6dc5a35f0558c44b9b345c5b4.png

ImageOptim could cause the problem then… ?

So… how could I work on the files that have the problem to revert back to a "normal" png file ?

Exporting a new png file, with "palettisé" untick does not correct the problem.

Thanks again for your help.

MacBook Pro 16 pouces (3456 × 2234), 2021 / Apple M1 Pro / 16 Go / macOS Ventura Version 13.4.1 (22F82)
+ 31,5 pouces (2560 × 1440) + 27 pouces (1080 × 1920) + iPad (8th generation) / iPadOS 17.2 + Apple Pencil + 

Macmini6,2 Quad-Core Intel Core i7 16 Go / macOS Catalina version 10.15.7 (19H2026)
MacBookAir6,2 Intel Core i5 double cœur 4 Go / macOS Big Sur version 11.7.7 (20G1345)

Licence Universelle Affinity V2 updated to 2.3.0

Link to comment
Share on other sites

The files from your first post in this thread differ.

the problematic blue one has a feathered edge on alpha channel, meaning alpha values with a gradient from 0.0 to 1.0

the ok green one has a hard edge with hard transition from 0 to 1.

I adjusted the blue one to have hard edge  too.

can you try if this solves the isse?

 

Logo hard alpha.png

Mac mini M1 A2348

LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5

iPad Air Gen 5 (2022) A2589

Special interest into procedural texture filter, edit alpha channel, RGB/16 and RGB/32 color formats, stacking, finding root causes for misbehaving files, finding creative solutions for unsolvable tasks, finding bugs in Apps.

 

Link to comment
Share on other sites

1 hour ago, laurent32 said:

BUT your answer made me remember that i do use ImageOptim to get more compact files.

 

Well, in future try to go without this tool, or at least keep the original files and check both if they work to identify which app causes the issue.

Mac mini M1 A2348

LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5

iPad Air Gen 5 (2022) A2589

Special interest into procedural texture filter, edit alpha channel, RGB/16 and RGB/32 color formats, stacking, finding root causes for misbehaving files, finding creative solutions for unsolvable tasks, finding bugs in Apps.

 

Link to comment
Share on other sites

It could simply be a outdated python release. Search the web for the error message

 

https://github.com/EmilStenstrom/mybgg/issues/34

Mac mini M1 A2348

LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5

iPad Air Gen 5 (2022) A2589

Special interest into procedural texture filter, edit alpha channel, RGB/16 and RGB/32 color formats, stacking, finding root causes for misbehaving files, finding creative solutions for unsolvable tasks, finding bugs in Apps.

 

Link to comment
Share on other sites

44 minutes ago, NotMyFault said:

I adjusted the blue one to have hard edge  too.

can you try if this solves the isse?

Nice idea @NotMyFault, but…

I tried twice, the routine is still ok with the green one and NOT OK with the blue one…

There must be something different in that blue file… or in that green file ???

I mean other than what you just found (which is nice).

MacBook Pro 16 pouces (3456 × 2234), 2021 / Apple M1 Pro / 16 Go / macOS Ventura Version 13.4.1 (22F82)
+ 31,5 pouces (2560 × 1440) + 27 pouces (1080 × 1920) + iPad (8th generation) / iPadOS 17.2 + Apple Pencil + 

Macmini6,2 Quad-Core Intel Core i7 16 Go / macOS Catalina version 10.15.7 (19H2026)
MacBookAir6,2 Intel Core i5 double cœur 4 Go / macOS Big Sur version 11.7.7 (20G1345)

Licence Universelle Affinity V2 updated to 2.3.0

Link to comment
Share on other sites

I'm not sure, and I don't know if it could have an incidence…

But I think…

— I initially selected pixels and erased them to build my transparency for the problematic blue file.

— I initially used vector tool to build my transparency for the green working file.

I searched my disks and found my original blue file (jpg that I turned into a png with transparency) :

image.jpeg.d8a6c627cc7e1ad4e4f93e9c201f79f1.jpeg

Can you turn that jpg file into a png with transparency ?

Maybe I'm doing something wrong ?

Maybe your png will work ok ?

MacBook Pro 16 pouces (3456 × 2234), 2021 / Apple M1 Pro / 16 Go / macOS Ventura Version 13.4.1 (22F82)
+ 31,5 pouces (2560 × 1440) + 27 pouces (1080 × 1920) + iPad (8th generation) / iPadOS 17.2 + Apple Pencil + 

Macmini6,2 Quad-Core Intel Core i7 16 Go / macOS Catalina version 10.15.7 (19H2026)
MacBookAir6,2 Intel Core i5 double cœur 4 Go / macOS Big Sur version 11.7.7 (20G1345)

Licence Universelle Affinity V2 updated to 2.3.0

Link to comment
Share on other sites

2 hours ago, laurent32 said:

Can you turn that jpg file into a png with transparency

  1. Open jpeg in Affinity Photo
  2. ensure „transparent canvas“ is active, to be able to  see transparency in canvas 
  3. check image is of type pixel layer. If not, or in doubt, rasterize layer.
  4. Use flood selection tool, activate detect edges, click on white background
  5. Normally hitting delete key removes the white background
  6. if this does not work, use erase brush, make it large and hard and 100% opacity, and swipe generously over image until all white is removed.
  7. check with channels panel, activate alpha, to see if process is complete.
  8. export as PNG

 

 

Mac mini M1 A2348

LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5

iPad Air Gen 5 (2022) A2589

Special interest into procedural texture filter, edit alpha channel, RGB/16 and RGB/32 color formats, stacking, finding root causes for misbehaving files, finding creative solutions for unsolvable tasks, finding bugs in Apps.

 

Link to comment
Share on other sites

1 hour ago, NotMyFault said:
  1. Open jpeg in Affinity Photo
  2. ensure „transparent canvas“ is active, to be able to  see transparency in canvas 
  3. check image is of type pixel layer. If not, or in doubt, rasterize layer.
  4. Use flood selection tool, activate detect edges, click on white background
  5. Normally hitting delete key removes the white background
  6. if this does not work, use erase brush, make it large and hard and 100% opacity, and swipe generously over image until all white is removed.
  7. check with channels panel, activate alpha, to see if process is complete.
  8. export as PNG

That's what I do, tried again, still have the problem so I guess I have to have a closer look at Python3 and Pillow…

Both of them have been updated not long ago…

Pillow might not be great in png manipulation ?

But then why is it good with my green file… a mystery…

If I find an answer I'll post it here…

Thanks @NotMyFault and all.

MacBook Pro 16 pouces (3456 × 2234), 2021 / Apple M1 Pro / 16 Go / macOS Ventura Version 13.4.1 (22F82)
+ 31,5 pouces (2560 × 1440) + 27 pouces (1080 × 1920) + iPad (8th generation) / iPadOS 17.2 + Apple Pencil + 

Macmini6,2 Quad-Core Intel Core i7 16 Go / macOS Catalina version 10.15.7 (19H2026)
MacBookAir6,2 Intel Core i5 double cœur 4 Go / macOS Big Sur version 11.7.7 (20G1345)

Licence Universelle Affinity V2 updated to 2.3.0

Link to comment
Share on other sites

11 hours ago, laurent32 said:

ImageOptim could cause the problem then… ?

I don't think so but maybe try it without lossy 'minification' enabled & see what happens. 

FWIW, I use ImageOptim without that enabled & this what I get for your image.jpeg.d8a6c627cc7e1ad4e4f93e9c201f79f1.jpeg file is this ~160 KB file.image.png.5c56af5fdb9a0875c49c5bb62291080c.png

What does you Python & Pillow stuff say about it?

All 3 1.10.8, & all 3 V23.0 Mac apps; 2020 iMac 27"; 3.8GHz i7, Radeon Pro 5700, 32GB RAM; macOS 10.15.7
Affinity Photo 
1.10.8; Affinity Designer 1.108; & all 3 V2 apps for iPad; 6th Generation iPad 32 GB; Apple Pencil; iPadOS 15.7

Link to comment
Share on other sites

13 hours ago, R C-R said:

I don't think so but maybe try it without lossy 'minification' enabled & see what happens. 

FWIW, I use ImageOptim without that enabled & this what I get for your image.jpeg.d8a6c627cc7e1ad4e4f93e9c201f79f1.jpeg file is this ~160 KB file.image.png.5c56af5fdb9a0875c49c5bb62291080c.png

What does you Python & Pillow stuff say about it?

Great job @R C-R !! You identified the problem with my blue file !

And also I did some tuning on my Python3 code and everything seems to be back in order now !

Thanks all for your knowledge.

MacBook Pro 16 pouces (3456 × 2234), 2021 / Apple M1 Pro / 16 Go / macOS Ventura Version 13.4.1 (22F82)
+ 31,5 pouces (2560 × 1440) + 27 pouces (1080 × 1920) + iPad (8th generation) / iPadOS 17.2 + Apple Pencil + 

Macmini6,2 Quad-Core Intel Core i7 16 Go / macOS Catalina version 10.15.7 (19H2026)
MacBookAir6,2 Intel Core i5 double cœur 4 Go / macOS Big Sur version 11.7.7 (20G1345)

Licence Universelle Affinity V2 updated to 2.3.0

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.
Note: Your post will require moderator approval before it will be visible.

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

Loading...
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.