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

Batch resize vs Resize Document discrepancy (and Export png resize)


zynexis

Recommended Posts

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

 

batch resize transparent nearest neighbor.png

batch resize with nearest neighbor.png

resize document normally with nearest neighbor.png

difference.png

original image to be resized to 96x96 (2).png

correct output (resize document).png

Link to comment
Share on other sites

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

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.

 

Link to comment
Share on other sites

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
 

Link to comment
Share on other sites

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.

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.

 

Link to comment
Share on other sites

Another issue: the 500x500px image (as uploaded in the forum) is already blurry, and does not match the screenshot which looks sharper.

You screenshot:

IMG_0835.thumb.png.52e655ac0aa18b833f3e66d208ef34a1.png

the png with transparency:

IMG_0834.thumb.png.de02d05fb5dd8db4b0fe4fd5732c2696.png

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.

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

 

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.

 

Link to comment
Share on other sites

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.

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.

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • Staff

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?

Please tag me using @ in your reply so I can be sure to respond ASAP.

Link to comment
Share on other sites

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

original image.png

Link to comment
Share on other sites

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:

  1. add a rectangle shape in canvas size, no fill, no stroke
  2. 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.

 

IMG_0846.png

Edited by NotMyFault
Typo

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.

 

Link to comment
Share on other sites

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:

  1. add a rectangle shape in canvas size, no fill, no stroke
  2. 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

 

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.