laurent32 Posted November 13, 2023 Posted November 13, 2023 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 : Here is the file I get with my routine : There is a problem, I lose my transparency (see green px)… Thanks for your help. Quote 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
walt.farrell Posted November 13, 2023 Posted November 13, 2023 If you Open your PNG in Affinity Photo 2, what color format is shown in the Context Toolbar? Quote -- Walt Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases PC: Desktop: Windows 11 Pro 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 Laptop: Windows 11 Pro 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU. Laptop 2: Windows 11 Pro 24H2, 16GB memory, Snapdragon(R) X Elite - X1E80100 - Qualcomm(R) Oryon(TM) 12 Core CPU 4.01 GHz, Qualcomm(R) Adreno(TM) X1-85 GPU iPad: iPad Pro M1, 12.9": iPadOS 18.3.1, Apple Pencil 2, Magic Keyboard Mac: 2023 M2 MacBook Air 15", 16GB memory, macOS Sequoia 15.0.1
laurent32 Posted November 13, 2023 Author Posted November 13, 2023 Hi Walt, Here is what I've got with my original affinity file : Here is what I get when I export to a png file with affinity : And here is what I get if I open back in affinity photo 2 the file I get after using a python routine : Is that the information you wanted ? Quote 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
walt.farrell Posted November 13, 2023 Posted November 13, 2023 Yes, thanks. But I have no idea what's going on. Sorry. Quote -- Walt Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases PC: Desktop: Windows 11 Pro 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 Laptop: Windows 11 Pro 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU. Laptop 2: Windows 11 Pro 24H2, 16GB memory, Snapdragon(R) X Elite - X1E80100 - Qualcomm(R) Oryon(TM) 12 Core CPU 4.01 GHz, Qualcomm(R) Adreno(TM) X1-85 GPU iPad: iPad Pro M1, 12.9": iPadOS 18.3.1, Apple Pencil 2, Magic Keyboard Mac: 2023 M2 MacBook Air 15", 16GB memory, macOS Sequoia 15.0.1
GarryP Posted November 13, 2023 Posted November 13, 2023 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. Quote
laurent32 Posted November 13, 2023 Author Posted November 13, 2023 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. Quote 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
laurent32 Posted November 13, 2023 Author Posted November 13, 2023 This png file gives the problem : While this one doesn't : 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 ? Quote 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
NotMyFault Posted November 13, 2023 Posted November 13, 2023 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. walt.farrell 1 Quote Mac mini M1 A2348 | MBP M3 Windows 11 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080 LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5 | Dell 27“ 4K 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. I use iPad screenshots and videos even in the Desktop section of the forum when I expect no relevant difference.
laurent32 Posted November 14, 2023 Author Posted November 14, 2023 Thanks for the idea @NotMyFault. The problem is that I did not use the palletized option, I export with the standard png profile : BUT your answer made me remember that i do use ImageOptim to get more compact files. Here are my ImageOptim prefs : 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. Quote 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
NotMyFault Posted November 14, 2023 Posted November 14, 2023 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? Quote Mac mini M1 A2348 | MBP M3 Windows 11 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080 LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5 | Dell 27“ 4K 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. I use iPad screenshots and videos even in the Desktop section of the forum when I expect no relevant difference.
NotMyFault Posted November 14, 2023 Posted November 14, 2023 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. Quote Mac mini M1 A2348 | MBP M3 Windows 11 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080 LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5 | Dell 27“ 4K 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. I use iPad screenshots and videos even in the Desktop section of the forum when I expect no relevant difference.
NotMyFault Posted November 14, 2023 Posted November 14, 2023 It could simply be a outdated python release. Search the web for the error message https://github.com/EmilStenstrom/mybgg/issues/34 Quote Mac mini M1 A2348 | MBP M3 Windows 11 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080 LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5 | Dell 27“ 4K 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. I use iPad screenshots and videos even in the Desktop section of the forum when I expect no relevant difference.
laurent32 Posted November 14, 2023 Author Posted November 14, 2023 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). Quote 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
laurent32 Posted November 14, 2023 Author Posted November 14, 2023 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) : Can you turn that jpg file into a png with transparency ? Maybe I'm doing something wrong ? Maybe your png will work ok ? Quote 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
NotMyFault Posted November 14, 2023 Posted November 14, 2023 2 hours ago, laurent32 said: Can you turn that jpg file into a png with transparency Open jpeg in Affinity Photo ensure „transparent canvas“ is active, to be able to see transparency in canvas check image is of type pixel layer. If not, or in doubt, rasterize layer. Use flood selection tool, activate detect edges, click on white background Normally hitting delete key removes the white background 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. check with channels panel, activate alpha, to see if process is complete. export as PNG laurent32 1 Quote Mac mini M1 A2348 | MBP M3 Windows 11 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080 LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5 | Dell 27“ 4K 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. I use iPad screenshots and videos even in the Desktop section of the forum when I expect no relevant difference.
laurent32 Posted November 14, 2023 Author Posted November 14, 2023 1 hour ago, NotMyFault said: Open jpeg in Affinity Photo ensure „transparent canvas“ is active, to be able to see transparency in canvas check image is of type pixel layer. If not, or in doubt, rasterize layer. Use flood selection tool, activate detect edges, click on white background Normally hitting delete key removes the white background 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. check with channels panel, activate alpha, to see if process is complete. 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. Quote 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
R C-R Posted November 14, 2023 Posted November 14, 2023 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. What does you Python & Pillow stuff say about it? laurent32 1 Quote All 3 1.10.8, & all 3 V2.6 Mac apps; 2020 iMac 27"; 3.8GHz i7, Radeon Pro 5700, 32GB RAM; macOS 10.15.7 All 3 V2 apps for iPad; 6th Generation iPad 32 GB; Apple Pencil; iPadOS 15.7
laurent32 Posted November 15, 2023 Author Posted November 15, 2023 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. 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. Quote 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
Recommended Posts
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.