Runtime texture generation produces black border on edges

Godot Version

4.4dev3

Question

when using SubViewPort to get ImageTexture

	await RenderingServer.frame_post_draw
	for node in get_tree().get_nodes_in_group(&'subviewports'):
		var image:Image=node.get_texture().get_image()
		image.compress(Image.COMPRESS_BPTC)
		self[node.name]=ImageTexture.create_from_image(image)
		node.queue_free()

Produces artifacts like black border on edges of opaque pixels to transparent. As I know this is because of antialiasing but it disabled by default for viewport and polygons which I used to create textures. Seems ok when just using ViewportTexture but if it was converted to ImageTexture then there black border appears, even if no compression was applied
image

So, how to fix this black border effect?

seems it because of how texture filter works and could be a bug. To eliminate it I set texture filter in ProjectSettings (ctrl+F ‘filter’ /textures)
default_texture_filter=Nearest it fixes that black outline effect, but at cost of quality.
Digging more into rendering I tried to set transparent mode of SubViewport to opaque and then replace pixels to transparent:
image
and that line Color(1,1,1, 0) is an answer where problem is.

after it black outline replaced with white…
so Godot renders (if not Nearest filter enabled) ViewportTexture alpha channel with mixing 2 pixels data, even if set to sharp 1 to 0 alpha

I found a solution for it. As previous posts described, I managed to change color of outline effect. So the solution pretty easy and logically inspired… I just added checks of neighbor pixels, so when next pixel to current meant to be transparent, I just set next pixel data to current and set alpha channel to 0. This fixed image appearance.