• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Unexpected aliasing on shape layers when exporting with Save for Web

Explorer ,
Apr 21, 2024 Apr 21, 2024

Copy link to clipboard

Copied

This issue has been giving me issues for quite a long time and I've finally tracked down the issue. When exporting images in Photoshop using the legacy Save for Web interface, which is particularly useful for pixel art, if there are shape layers, when scaling the image down, unintended aliasing appears around the edges of the shapes, particularly in areas where the rectangular bounds seem to overlap. This produces noticable, visual artifacts that should never be there.

This is happening on Photoshop 25.6.0 on Windows 11.

 

Here are the steps to reproduce:

  1. Create a new document, fairly large at about 2000x2000.
  2. Draw a red triangle on one side of the canvas.
  3. Create a circle somewhere else on the canvas, away from the triangle.
  4. Go to the Save for Web dialog.
  5. Scale the image down. Even as little as 1 pixel makes a difference but it's more noticable if it's scaled down more, like down to 200x200
  6. The original image on the left or top will have a slight red ring around the white circle.

 

A possible workaround is if the layers are exported separately instead of at the same time. Another possible workaround is if the red triangle layer is above the white circle, but this isn't always possible depending on the art. Rasterizing the layers does not work, but it does change how the aliasing turns out.

Attached is an example of how the image comes out if I set it to an indexed PNG-8 image with transparency and matting disabled. There's a clear red ring around the white circle that shouldn't be there.

TOPICS
Windows

Views

941

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Apr 21, 2024 Apr 21, 2024

Copy link to clipboard

Copied

Use the Nearest Neighbor resampling algorithm. It's there for pixel art where you need to maintain crisp edges.

 

Pixel art should always be made at actual size so you don't have to resample at all.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 21, 2024 Apr 21, 2024

Copy link to clipboard

Copied

It depends on the use case. In my example, I have some art built at a higher resolution that I'm trying to scale down while retaining sharp edges and limited colors. Nearest Neighbor in that case may produce rather inaccurate shapes on the art due to the nature of the scaling algorithm. I'm not sure if this used to be the case before because I've had this workflow for several years now.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Apr 21, 2024 Apr 21, 2024

Copy link to clipboard

Copied

I tried to replicate this issue, but I can't. I experience no red anti-aliasing issues.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 21, 2024 Apr 21, 2024

Copy link to clipboard

Copied

It might depend on how the shape is drawn and possibly the scale size. I prepared a sample file similar to the example image in the first post. Trying to output this at about 200x200 should produce aliasing in Save for Web even on the original image.

https://www.dropbox.com/scl/fi/jiywmkoq7tpk6mxh0omry/save-for-web-aliasing-example.psd?rlkey=rfmmz5e...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 25, 2024 Apr 25, 2024

Copy link to clipboard

Copied

This aliasing issue may not be exclusive to Save for Web after all. In another graphic I worked on, I exported using the modern Export As and while the aliasing was not noticeable at first, when it gets processed or scaled by something else, the same aliasing present in Save for Web is noticeable. In this case, here is a closeup of the thumbnail produced by Discord. This is the same aliasing more easily noticed in Save for Web.

HugoM01_0-1714105364880.png 

HugoM01_1-1714107336754.png

 

Where did this come from? It was certainly not in my source PSD or in the PNG file I exported.

Curiously, even the example image, if I were to save as a PNG, would exhibit aliasing upon export, even though it would just be a PNG image free of shape layers at that point. Something is going on with the core rendering or exporting in Photoshop because this is producing messy images all over.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Apr 26, 2024 Apr 26, 2024

Copy link to clipboard

Copied

That looks more like the anti-aliased edges' transparency is premultiplied with white.

The PNG spec states it shouldn't premultiply, but many applications ignore this rule.

 

Here is an example of premultiplying the transparent edge pixels with respectively black or white for comparison:

 

sample.png

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 26, 2024 Apr 26, 2024

Copy link to clipboard

Copied

LATEST

The concept of premultiplied transparency can be complicated to understand, but from what I can gather from that rabbit hole, and inspecting the results and settings like in your screenshot above, this seems like a similar problem, but not exactly the same one. Especially in my second image with the letter border. How else could that aliasing outside the black stroke be explained? This looks like something that would happen if I had done an inner stroke, but this is just a plain black stroke being drawn outside the letter. The aliasing is even mirroring the gradient in certain spots.

Color Quantizer reports various sections of color with alpha set to 0 well outside the art. Why is that?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Apr 22, 2024 Apr 22, 2024

Copy link to clipboard

Copied

Ah, I see. Interesting. It seems that the legacy SFW will (for some reason) use red values to add anti-aliasing to the white circle when any other resampling method is used other than Nearest Neighbour.

 

But that only happens when the Quality setting isn't set to Nearest Neighbour, just as @D Fosse mentioned.

 

I tested this in other image editors and web image optimization tools, and only the legacy defunct Save for Web function in Photoshop behaves like this.

 

If I may ask: why are you scaling down shapes like this? I agree with @D Fosse that for pixel art you should be working at the native output resolution instead of downscaling shapes.

And why would you want to use the old SfW anyway? The new Export As function works better and doesn't introduce this buggy behaviour no matter the resampling method.

 

In any case: switch to Nearest Neighbour in SfW, and the problem goes away.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 22, 2024 Apr 22, 2024

Copy link to clipboard

Copied

Well, not just red but the surrounding color. It could alias with a gradient color, which is what was happening in my project.

As I mentioned, this export method is essential when it comes to downscaling and color-reducing art from a higher resolution to a target size for pixel art. Sometimes that art will contain shapes or other layers which produce these unwanted artifacts.

Here is another project I worked on prior where the issue was more prevalent. I have this logo I'm trying to downscale and color reduce, but with a very specific transparent cutout in the center done as a hard edge, and anti-aliased on white on the outside. I've disabled transparency to enhance the defect. The part I have circled is how all of the inside should have appeared after downscaling, but due to this bug, nearly all of it is aliased. Particularly around the lower yellow circle where the edges almost seems to emit aliasing due to proximity.

HugoM01_0-1713819942257.png

 

Nearest neighbor scaling is not what I'm looking for in this case because I need the art to be smooth, even though the issue is not present in this state.

HugoM01_1-1713820061854.png

 

I eventually ended up manually cleaning up the aliasing from the first one after exporting because it was close enough to what I needed.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Apr 22, 2024 Apr 22, 2024

Copy link to clipboard

Copied

So... Why not use the new export function? That also supports scaling down.

 

All that said, I feel your pain, because Photoshop isn't exactly a forerunner in optimizing low resolution pixel art or downscaling larger version for prep to low resolution export, nor for colour reduction or file size optimization.

 

Myself, I avoid Photoshop entirely and rely either on Color Quantizer (for exact colour reduction control) or Squoosh. (Also use PhotoLine, which has good export options for pixel art.) Both allow for what you need to do. Squoosh also runs as an off-line app, but requires a local LAMP web server to run it in. CQ is a desktop app for Windows, but is predominantly PNG optimization oriented, while Squoosh supports the latest AVIF, OxiPNG, and other file formats.

 

https://squoosh.app/

http://x128.ho.ua/color-quantizer.html

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Apr 22, 2024 Apr 22, 2024

Copy link to clipboard

Copied

PS Adobe will never EVER fix those bugs in the legacy Save for Web. It's deprecated and no longer supported or improved or bugfixed.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 22, 2024 Apr 22, 2024

Copy link to clipboard

Copied

The new Export function doesn't do color reduction and also scales Layer Styles when scaling up or down, affecting the appearance of the image. It's not made to do all the specific color handling the old tool can do because this is not something many people have to do anymore. I recall the last change they made to this was taking out the masking option several years ago. And this bug is surely a more recent regression or I would have encountered it years ago.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Apr 22, 2024 Apr 22, 2024

Copy link to clipboard

Copied

I wasn't aware of that particular layer style problem in the new export in PS.

And I know exactly what you mean in regard to that specific art prep workflow: I prepare pixel art game assets and use predefined colour palettes. 

 

That is why I mentioned Color Quantizer: it is the only all-in-one optimization utility that affords full control over the colour palette and features a colour masking/brush tool to indicate which parts of the image (colours) should be preserved over other areas. And much better downscale resampling algorithms than any other tool, with pre- and post sharpening while scaling down. Also full control over edge transparency and background matte down to preserving edges from dithering.

 

In my opinion, nothing beats CQ in efficiency and simplicity for this kind of work up till this day. Photoshop Save for Web pales in comparison. I found it to be a far superior replacement for any other SfW export dialog.

 

Anyway, might be worth a try now that Save for Web is no longer viable for you. Even loads psd files.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines