Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Downloaded PNG in RGB mode fails to support transparency: erase uses secondary color and export PNG replaces transparent color with black #4370

Open
hsandt opened this issue Mar 15, 2024 · 2 comments · May be fixed by #4420

Comments

@hsandt
Copy link

hsandt commented Mar 15, 2024

I often have this issue on images downloaded directly from the Internet, typically on The Spriters Resource. This happens when opening the PNG directly in Aseprite (not creating a new file then copying image rectangles). Note that opening a PNG sets the Color mode to RGB by default, so this is not an issue related to using Indexed Color mode (and even then, behavior differs from real Indexed Color mode).

Since spritesheets are often distributed with a transparency index color, I must manually remove the background color (by either using the magic wand + delete, paint bucket with transparent color or, when some background pixels are inside the sprites, the eraser + right-click to replace background color to transparent color (added myself to the palette).

However, I noticed the following:

It seems that somewhat the PNG metadata cannot be changed even after saving the file as an .aseprite file.

Switching to Indexed Color mode and back to RGB doesn't help. Switching to Indexed Color mode and defining background color as the index color doesn't work either. All 3 color modes have the issue.

Repro steps

  1. Download a spritesheet from the net, such as https://www.spriters-resource.com/master_system/sonicthehedgehog/sheet/5859/
  2. Open in directly in Aseprite (Open with... or drag and drop)
  3. Verify that it is RGB mode
  4. Try the eraser or bucket fill with transparent color => fills with secondary color
  5. Select background color as primary color. Add transparent color to palette, select as secondary color. Use the eraser + right-click with big brush size to replace background with transparency => it works
  6. Export PNG => background is now black
  7. Try different Color modes and repeat

Workaround

Create a brand new file in Aseprite in RGB mode, and copy image content from the PNG into that file, instead of opening the PNG itself in Aseprite.

Here is an example with a standard export on the left, and creating a new RGB file and copying content then exporting on the right:

image

Aseprite and System version

  • Aseprite version: v1.3.2 (official)
  • System: Linux Ubuntu 22.04

Other related threads

https://community.aseprite.org/t/my-eraser-draws-black-color-instead-of-erasing/2556/4

@Gasparoken
Copy link
Member

Thanks for this report. Some comments:
Some PNG images were loaded with a Background layer (instead a regular transparent layer) according how the images were encoded.

When you have a Backgroud layer, all pixels on your canvas will be non transparent and the eraser tool will 'paint':

  • left click: the secondary color (bg color)
  • right click: only the primary color will be replaced with secondary color within applied eraser area.

To work with pixels with alpha values, convert the 'Background Layer' to 'Layer': right click on Layer name, Convert to... > Layer
Screenshot 2024-03-19 at 08 05 57

Just in case: to select all the color you need to remove, the best tool is 'Magic Wand' with 0 Tolerance and Continuos unchecked on the context bar ('continuos unchecked' will remove isolated areas of color too).

More info about Background Layer: https://aseprite.org/docs/layers#background-layer

@Gasparoken
Copy link
Member

Gasparoken commented Mar 19, 2024

Based on your Repro steps, I see the inconsistency: there may be transparent pixels on a Background Layer, which should be prohibited. Then, in the export process, the alpha content of the pixels is discarded since the layer is a background layer. That's why it turns out 6. Export PNG => background is now black

@Gasparoken Gasparoken added this to the v1.3.x milestone Mar 19, 2024
@dacap dacap modified the milestones: v1.3.x, v1.3.6 Mar 19, 2024
@dacap dacap modified the milestones: v1.3.6, v1.3.7 Apr 9, 2024
@Gasparoken Gasparoken self-assigned this Apr 16, 2024
Gasparoken added a commit to Gasparoken/aseprite that referenced this issue Apr 17, 2024
fix aseprite#4370)

Before this fix, when working with sprites that included a
background layer and using the Eraser tool, drawing transparent
pixels was allowed if the secondary color was transparent +
right click (i.e. eraser in replace mode "Primary color ->to->
Secondary").
Original issue aseprite#4370 description:
"Downloaded PNG in RGB mode fails to support transparency: erase
uses secondary color and export PNG replaces transparent color with
black"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
3 participants