### ImageMagick version

7.1.1-24

### Operating system

Windows

### Operating system, version and so on

7, 6.1.7601

### Description

I am using `-flatten` to composite a partially transparent image with the background color. I expect the image to contain no transparency anymore afterwards. Though there actually is no pixel left anymore which has any transparency, the operation still adds an alpha channel, which is even stored in a PNG afterwards. I am confused as this is a counter-intuitive behavior. I am also confused as I have indeed observed IM to optimize the colors when saving an image as a PNG, potentially removing the alpha channel if no transparency is used. Sometimes it doesn't seem to do that and I don't know why. So how exactly does the optimization work, when does it remove an alpha channel and when does it not? Also, I am wondering if `-flatten` adding an unused alpha channel is the intended behavior. If so, I would like to know why so and which option I could use to ask IM to remove an unused alpha channel. I know I could use `-alpha Remove` but this will always remove the alpha channel and I would rather like to ask IM _if_ it can be removed.

Another strange behavior I observed is that even when I use `-alpha Remove` after `-flatten`, I first have to set the background color to a solid color though `-flatten` just _used_ a solid background color. Yet another strange behavior I observed is that setting the background color just before `-alpha Remove` only works when I use a color name or rgb(...) but not if I use rgba(..., 1.0).

### Steps to Reproduce

```
magick convert Cross.png -flatten HasAlphaChannelButNoTransparency.png
magick convert Cross.png -flatten -alpha Remove StillHasAlphaChannelButNoTransparency.png
magick convert Cross.png -flatten -background rgba(0,0,0,1) -alpha Remove AndEvenStillHasAlphaChannelButNoTransparency.png
magick convert Cross.png -flatten -background black -alpha Remove FinallyNoAlphaChannel.png
```

### Images

![Cross](https://github.com/ImageMagick/ImageMagick/assets/77283395/d07a6889-dbb2-433d-91fd-7fecad4c1254)

Though no pixel has transparency after -flatten, an alpha channel is added and saved in PNG
This is a GitHub Issue
repo:ImageMagick
owner:ImageMagick
Title : Though no pixel has transparency after -flatten, an alpha channel is added and saved in PNG
Issue date:

--- start body ---
### ImageMagick version

7.1.1-24

### Operating system

Windows

### Operating system, version and so on

7, 6.1.7601

### Description

I am using `-flatten` to composite a partially transparent image with the background color. I expect the image to contain no transparency anymore afterwards. Though there actually is no pixel left anymore which has any transparency, the operation still adds an alpha channel, which is even stored in a PNG afterwards. I am confused as this is a counter-intuitive behavior. I am also confused as I have indeed observed IM to optimize the colors when saving an image as a PNG, potentially removing the alpha channel if no transparency is used. Sometimes it doesn't seem to do that and I don't know why. So how exactly does the optimization work, when does it remove an alpha channel and when does it not? Also, I am wondering if `-flatten` adding an unused alpha channel is the intended behavior. If so, I would like to know why so and which option I could use to ask IM to remove an unused alpha channel. I know I could use `-alpha Remove` but this will always remove the alpha channel and I would rather like to ask IM _if_ it can be removed.

Another strange behavior I observed is that even when I use `-alpha Remove` after `-flatten`, I first have to set the background color to a solid color though `-flatten` just _used_ a solid background color. Yet another strange behavior I observed is that setting the background color just before `-alpha Remove` only works when I use a color name or rgb(...) but not if I use rgba(..., 1.0).

### Steps to Reproduce

```
magick convert Cross.png -flatten HasAlphaChannelButNoTransparency.png
magick convert Cross.png -flatten -alpha Remove StillHasAlphaChannelButNoTransparency.png
magick convert Cross.png -flatten -background rgba(0,0,0,1) -alpha Remove AndEvenStillHasAlphaChannelButNoTransparency.png
magick convert Cross.png -flatten -background black -alpha Remove FinallyNoAlphaChannel.png
```

### Images

![Cross](https://github.com/ImageMagick/ImageMagick/assets/77283395/d07a6889-dbb2-433d-91fd-7fecad4c1254)

--- end body ---
