godot-proposals icon indicating copy to clipboard operation
godot-proposals copied to clipboard

Improve SVG thumbnails

Open MewPurPur opened this issue 10 months ago • 6 comments

Describe the project you are working on

An SVG editor

Describe the problem or limitation you are having in your project

image

My icons folder looks like this, which is an eyesore.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Changing the SVG thumbnails creation method to not produce blurred outputs.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Currently it appears as though the SVG is just rendered and upscaled.

The best approach I can think of right now would be to make it so after the SVG is rendered onto an image, grab that image's width and height and discard it. Use them to calculate how much the image needs to be upscaled or downscaled to fit in the thumbnail precisely. Then use this scale as an argument when re-rendering the SVG, and use the re-rendered version.

The above could maybe be simplified if we have a way to grab the SVG's width and height without rendering the whole thing, or maybe there's even some way to render an SVG at a set size. I don't know. Also, if https://github.com/godotengine/godot/pull/86022 goes through, maybe SVGTexture could help too.

In any case, it shouldn't be a performance killer, because the re-rendered SVGs have a set size, and we'll never need to render something big.

If this enhancement will not be used often, can it be worked around with a few lines of script?

Will be used often.

Is there a reason why this should be core and not an add-on in the asset library?

Basic functionality of something already supported.

MewPurPur avatar Apr 20 '24 22:04 MewPurPur

Wouldn't it be misleading to show the graphics in a different resolution than the one the asset will actually be drawn in? The thumnails are blurry because the svgs are treated as 16⋅16 pixels (or whichever the svg size is) images iirc, which make sense to me.

mieldepoche avatar Apr 21 '24 13:04 mieldepoche

That's not how SVGs are represented in any mature apps, SVGs can be imported with many scales even if their base scale is 16x16.

MewPurPur avatar Apr 21 '24 14:04 MewPurPur

SVGs can be imported with many scales even if their base scale is 16x16

I thought the thumbnail respected the import scale, but testing it now shows it does not... I think they should.

mieldepoche avatar Apr 21 '24 14:04 mieldepoche

Are we ever representing anything in the file system based on its import settings? I thought it was just supposed to be a good representation of the file itself, not how it's currently imported. And for SVGs the base truth would be what I described in the post

MewPurPur avatar Apr 21 '24 19:04 MewPurPur

I thought it was just supposed to be a good representation of the file itself, not how it's currently imported

I thought it was the opposite, but turns out it's not apparently :sweat_smile: . In that case, this proposal actually makes more sense then. Although intuitively, I expected to be shown the import result, not the original files.

mieldepoche avatar Apr 22 '24 12:04 mieldepoche

Another argument for this would be the benefit of helping communicate that the SVG files are resolution independent vector graphics, to contrast with bitmap images that have a set pixel resolution. The current pixelated previews incorrectly seem to indicate the svg files have a set pixel resolution.

lostminds avatar May 02 '24 12:05 lostminds

I support this proposal, but it needs an implementation. Help wanted!

fire avatar May 03 '24 14:05 fire

If someone can guide me to the code for creating these previews is, I'll probably be able to implement it.

MewPurPur avatar May 03 '24 15:05 MewPurPur

Do a search for EditorTexturePreviewPlugin or EditorTexturePreview.

fire avatar May 04 '24 15:05 fire