zynexis Posted October 23, 2023 Posted October 23, 2023 Hi, I was trying to do a batch resize of a collection of transparent png sprites and noticed that even with Nearest neighbor enabled in the batch, it still causes anti aliasing This does not happen when using the regular Resize Document with nearest neighbor function When using Export function to save as png with Nearest Neighbor, we also get anti aliasing (I assume batch resize is using this, since they are both not equal to Resize Document) reproduce: 1. use batch resize on the attached original image, resize to 96x96, nearest neighbor 2. resize original image using resize document with nearest neighbor 3. observe the difference in the outputs 4. compare result to the correct output image Quote
NotMyFault Posted October 23, 2023 Posted October 23, 2023 Did you rasterize the image before changing the document size? otherwise you may resize a document containing an image layer. The image layer will always use „bilinear“ resampling for rendering while Photo is open (except you change this in settings/performance. when comparing transparent images (with blend mode difference), you need to compare every color channel individually while settings alpha to 100%. Quote Mac mini M1 A2348 | Windows 10 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080 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. My posts focus on technical aspects and leave out most of social grease like „maybe“, „in my opinion“, „I might be wrong“ etc. just add copy/paste all these softeners from this signature to make reading more comfortable for you. Otherwise I’m a fine person which respects you and everyone and wants to be respected.
zynexis Posted October 23, 2023 Author Posted October 23, 2023 the image is rasterized, and the issue is not with Resize Document (it does it correctly) the problem is with the png exporter and batch, it is using a different method to resize/resample, even if both are set to use nearest neighbor the difference is visible with the naked eye, the difference blend image is just to make it obvious, no need to compare each channel Quote
NotMyFault Posted October 23, 2023 Posted October 23, 2023 I tried to reproduce the issue, but for me the only cause of difference was the aforementioned image layer. in my tests, no difference between document resize and export to png. But I used iPad and Mac. Quote Mac mini M1 A2348 | Windows 10 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080 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. My posts focus on technical aspects and leave out most of social grease like „maybe“, „in my opinion“, „I might be wrong“ etc. just add copy/paste all these softeners from this signature to make reading more comfortable for you. Otherwise I’m a fine person which respects you and everyone and wants to be respected.
NotMyFault Posted October 23, 2023 Posted October 23, 2023 Another issue: the 500x500px image (as uploaded in the forum) is already blurry, and does not match the screenshot which looks sharper. You screenshot: the png with transparency: Quote Mac mini M1 A2348 | Windows 10 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080 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. My posts focus on technical aspects and leave out most of social grease like „maybe“, „in my opinion“, „I might be wrong“ etc. just add copy/paste all these softeners from this signature to make reading more comfortable for you. Otherwise I’m a fine person which respects you and everyone and wants to be respected.
zynexis Posted October 23, 2023 Author Posted October 23, 2023 i'm glad that you try to help, but the issue is pretty straight forward, i think you are confusing things a bit the source image is an output by an ai image model in 500x500 (with background removed) and is not pixel precise in any way - that's why it needs to rescaled down to 96x96, where it will become pixel exact you talk about image layers etc, i don't see any relevance at all, we are talking about rescaling an opened png image, it makes 0 difference if the background is rasterized or not in this case, it is a pixel layer, and Resize Document will make it exactly as expected with nearest neighbor resampling 1) open the 500 pixel original and do Export as PNG, set width/height to 96x96, set nearest neighbor 2) now go back to the 500 pixel original, resize document to 96x96 with nearest neighbor resampling, then export as PNG like normal 3) compare the 2 outputs, you can see the aliasing difference (on my windows 10 desktop version at least) you can compare by dragging the 2 96x96 into doc as layers Quote
NotMyFault Posted October 23, 2023 Posted October 23, 2023 7 minutes ago, zynexis said: you talk about image layers etc, i don't see any relevance at all, It totally depends how you create or open the file from the original png. If you get an image layer, this will make a big difference, as image layers will not get resample when resizing the document. Quote Mac mini M1 A2348 | Windows 10 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080 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. My posts focus on technical aspects and leave out most of social grease like „maybe“, „in my opinion“, „I might be wrong“ etc. just add copy/paste all these softeners from this signature to make reading more comfortable for you. Otherwise I’m a fine person which respects you and everyone and wants to be respected.
NotMyFault Posted October 23, 2023 Posted October 23, 2023 9 minutes ago, zynexis said: i think you are confusing things a bit This is not a nice sentence I want to read about my posts. Have a nice day, I’m out of this thread. Quote Mac mini M1 A2348 | Windows 10 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080 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. My posts focus on technical aspects and leave out most of social grease like „maybe“, „in my opinion“, „I might be wrong“ etc. just add copy/paste all these softeners from this signature to make reading more comfortable for you. Otherwise I’m a fine person which respects you and everyone and wants to be respected.
zynexis Posted October 23, 2023 Author Posted October 23, 2023 when you open a PNG in Affinity Photo, it opens as a pixel layer (rasterized) not as an image layer like when you drag in an image into a doc this is something you keep mentioning, even when i already explain that it is a pixel layer and that the problem is not with Resize Document That's why i' saying you are confusing things and not reading what i'm actually saying saying there is no difference for you, i have no way to verify unless you upload your results, clearly there is a difference as i have shown you then post about my screenshots, which were showing the scaled down versions, not the 500px original, further confusing things like i said, i appreciate the help, just please read and understand the actual issue first anyways, good bye then Quote
Staff Callum Posted October 25, 2023 Staff Posted October 25, 2023 Hi Zynexis, I'm struggling to replicate this issue here both images export without anti aliasing for me. Please could you provide a screen recording showing the exact steps you are taking just so I can be sure we aren't doing something different from each other? Quote Please tag me using @ in your reply so I can be sure to respond ASAP.
zynexis Posted October 26, 2023 Author Posted October 26, 2023 On 10/25/2023 at 1:50 PM, Callum said: Hi Zynexis, I'm struggling to replicate this issue here both images export without anti aliasing for me. Please could you provide a screen recording showing the exact steps you are taking just so I can be sure we aren't doing something different from each other? Hey Callum, Sure, i recorded a short video to show the issue the problem seems to be that batch processing uses the png exporter resizing, which in this case is different (on my pc at least) than the Affinity doc resize, making the batch resize invalid to use for these pixel sprites (i included the original image.png) I'm on Windows 10, Affinity Photo ver 2.2.0 Affinity Photo Neareset Neighbor Export vs Resize Doc.mp4 Quote
NotMyFault Posted October 26, 2023 Posted October 26, 2023 (edited) The issue is caused by placing an image into a larger canvas, with fully transparent edge pixels around the placed layer. it seems the export function starts with the actual position of the image layer at 5,52, and transforms the resample result to a fractional position. This can be rated as bug, specifically as results from export differ from in-document resize. This issue can be easily avoided: add a rectangle shape in canvas size, no fill, no stroke nest the png layer as child. now the results from export and resize are identical. i did not spot this as I missed to set resample to resample during first tests. Your video was extremely helpful to reproduce. Edited October 27, 2023 by NotMyFault Typo lepr 1 Quote Mac mini M1 A2348 | Windows 10 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080 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. My posts focus on technical aspects and leave out most of social grease like „maybe“, „in my opinion“, „I might be wrong“ etc. just add copy/paste all these softeners from this signature to make reading more comfortable for you. Otherwise I’m a fine person which respects you and everyone and wants to be respected.
zynexis Posted October 26, 2023 Author Posted October 26, 2023 8 minutes ago, NotMyFault said: The issue is caused by placing an image into a larger cannas, with fully transparent edge pixels. it seems the export function starts with the actual position of the image layer at 5,52, and transforms the resample result to a fractional position. This can be rated as bug, specifically as results from export differ from in-document resize. This issue can be easily avoided: add a rectangle shape in canvas size, no fill, no stroke nest the png layer as child. now the results from export and resize are identical. i can confirm this produces an identical result, so makes sense the transparency offset is having an impact Nice find the workaround is not that 'easy' when working with batch and got over 100 sprites that needs this weird workaround output from batch and resize doc to png should be the same optimally, or batch is kind of useless for the (quite common) tasks Quote
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.