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

Improve SVG thumbnails #9567

Open
MewPurPur opened this issue Apr 20, 2024 · 9 comments
Open

Improve SVG thumbnails #9567

MewPurPur opened this issue Apr 20, 2024 · 9 comments

Comments

@MewPurPur
Copy link

MewPurPur commented Apr 20, 2024

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 godotengine/godot#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.

@mieldepoche
Copy link

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.

@MewPurPur
Copy link
Author

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.

@mieldepoche
Copy link

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.

@MewPurPur
Copy link
Author

MewPurPur commented Apr 21, 2024

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

@mieldepoche
Copy link

mieldepoche commented Apr 22, 2024

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 😅 . In that case, this proposal actually makes more sense then.
Although intuitively, I expected to be shown the import result, not the original files.

@lostminds
Copy link

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.

@fire
Copy link
Member

fire commented May 3, 2024

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

@MewPurPur
Copy link
Author

MewPurPur commented May 3, 2024

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

@fire
Copy link
Member

fire commented May 4, 2024

Do a search for EditorTexturePreviewPlugin or EditorTexturePreview.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants