### Godot version

2a0aef5f09

### System information

Windows 11, Ryzen 9 5950X, RTX 3090 (531.79) Vulkan, 64GB RAM

### Issue description

The issue occurs due to two things.
When textures/images are imported, the `fix_alpha_edges` / `fix_alpha_borders` function in the importer will modify the color values but leaves the alpha values unchanged.

Later, when using the `_convert` function in the `image.cpp` file or `Image::convert` to convert from `Image::FORMAT_RGBA` to `Image::FORMAT_L8` the following image results (raw on top, conversion on bottom).
![Clipboard - May 22, 2023 8_13 PM](https://github.com/godotengine/godot/assets/5207577/52f4597e-17b6-48c5-8fb4-d6d37012d8f4)

I, originally, thought that the `fix_alpha_edges` / `fix_alpha_borders` code was at fault but it turns out to not necessarily be the case.  I modified the `_convert` function in `image.cpp` to calculate grayscale values correctly and to consider the alpha channel or not and now I'm getting the expected output as shown here:
![Clipboard - May 23, 2023 7_16 AM](https://github.com/godotengine/godot/assets/5207577/73babb20-22bb-4f23-808f-5d49dce55f2d)


### Steps to reproduce

Import `Image::FORMAT_RGBA` image into any project.

Convert image in code by calling the `convert` function to `Image::FORMAT_L8`.

Screen shot of MRP here:
![image](https://github.com/godotengine/godot/assets/5207577/9d7d0078-5e41-45d1-b5c5-fc291b839fa9)


### Minimal reproduction project

Attached now
[Issue_77393.zip](https://github.com/godotengine/godot/files/11545149/Issue_77393.zip)

if (data.size() == 0) {
		return;
	}
	static const uint8_t srgb2lin[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 22, 22, 23, 23, 24, 24, 25, 26, 26, 27, 27, 28, 29, 29, 30, 31, 31, 32, 33, 33, 34, 35, 36, 36, 37, 38, 38, 39, 40, 41, 42, 42, 43, 44, 45, 46, 47, 47, 48, 49, 50, 51, 52, 53, 54, 55, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 70, 71, 72, 73, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 85, 87, 88, 89, 90, 92, 93, 94, 95, 97, 98, 99, 101, 102, 103, 105, 106, 107, 109, 110, 112, 113, 114, 116, 117, 119, 120, 122, 123, 125, 126, 128, 129, 131, 132, 134, 135, 137, 139, 140, 142, 144, 145, 147, 148, 150, 152, 153, 155, 157, 159, 160, 162, 164, 166, 167, 169, 171, 173, 175, 176, 178, 180, 182, 184, 186, 188, 190, 192, 193, 195, 197, 199, 201, 203, 205, 207, 209, 211, 213, 215, 218, 220, 222, 224, 226, 228, 230, 232, 235, 237, 239, 241, 243, 245, 248, 250, 252, 255 };
	ERR_FAIL_COND(format != FORMAT_RGB8 && format != FORMAT_RGBA8);
	if (format == FORMAT_RGBA8) {
		int len = data.size() / 4;
		uint8_t *data_ptr = data.ptrw();
		for (int i = 0; i < len; i++) {
			data_ptr[(i << 2) + 0] = srgb2lin[data_ptr[(i << 2) + 0]];
			data_ptr[(i << 2) + 1] = srgb2lin[data_ptr[(i << 2) + 1]];
			data_ptr[(i << 2) + 2] = srgb2lin[data_ptr[(i << 2) + 2]];
		}
	} else if (format == FORMAT_RGB8) {
		int len = data.size() / 3;
		uint8_t *data_ptr = data.ptrw();
		for (int i = 0; i < len; i++) {
			data_ptr[(i * 3) + 0] = srgb2lin[data_ptr[(i * 3) + 0]];
			data_ptr[(i * 3) + 1] = srgb2lin[data_ptr[(i * 3) + 1]];
			data_ptr[(i * 3) + 2] = srgb2lin[data_ptr[(i * 3) + 2]];
		}
	}
}
void Image::premultiply_alpha() {