UI: SVG Thumbnails #109567
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#109567
Loading…
Reference in New Issue
No description provided.
Delete Branch "Harley/blender:SvgThumbs"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Allow SVG files to have previews in the File Browser. Adds
nanosvgrast.h to extern\nanosvg, which is an SVG rasterizer that is
an optional part of the nanosvg source.
This no longer adds the ability to load an SVG files into the Image Editor, it only allows thumbnailing of this file type.
Related RCS suggestion: https://blender.community/c/rightclickselect/2WBW/
Tested with 201 samples from w3.org; worked well and fast. Some examples of the preview samples created from them (the resulting PNG files).
WIP: SVG Thumbnailsto UI: SVG ThumbnailsThis should be evaluated as a design task before going though review.
I'm concerned that this introduces support for something which users will find incomplete, and request fixes - either pushing development focus into a new area - or leaving SVG support "incomplete/broken" from a user perspective.
Once supported users may reasonably request:
There is some potential that users start to use SVG for projects in a way that means updates to nanoSVG (even improvements) could make users files render differently.
With this change it's not clear what users expectations should be. If we add support for a format with a lot of limitations, which users run into and view as bugs... we might be better off not supporting it, so users convert the SVG's to images outside of Blender which is what they might have to do anyway.
We have two official release add-ons importing SVG (the one importing as curves, and the one importing as greasepencil). As such, I think having preview of SVG in the file browser makes sense.
But I would not expose it as a loadable image format indeed, unless it is decided to fully support our own SVG rasterizer, with all the necessary features.
In any case, this should indeed be a design task first.
Removing all code to do with loading SVG images, leaving only the code needed for thumbnailing.
Removing Reviewer and setting WIP to take this out of the review queue.
UI: SVG Thumbnailsto WIP: UI: SVG ThumbnailsI'd rather leave
@ -199,6 +199,18 @@ const ImFileType IMB_FILE_TYPES[] = {
/*default_save_role*/ COLOR_ROLE_DEFAULT_BYTE,
},
#endif
{
There should be a code-comment explaining why only the thumbnail callback is set as it's not obvious.
@ -0,0 +15,4 @@
extern "C" {
ImBuf *imb_load_filepath_thumbnail_svg(const char *filepath,
Also note here, that only thumbnails are supported and why.
@ -46,3 +46,3 @@
const char *imb_ext_image[] = {
".png", ".tga", ".bmp", ".jpg", ".jpeg", ".sgi", ".rgb", ".rgba", ".tif", ".tiff", ".tx",
".png",
With this change SVG are shown when opening an image, which is misleading as they're not supported.
Ideally, add-ons that support SVG can request SVG files are shown and in this case - the thumbnails will be shown.
I removed SVG from that
imb_ext_image
list and left it where it is now, which is a file treated as FILE_TYPE_OBJECT_IO. This means that opening an image in Image Editor you no longer see SVG files in the filtered list.But then I added a new thumbnail source type to match - THB_SOURCE_OBJECT_IO. And for files of this type I only thumbnail those that end in ".svg". This seems interesting to me as it opens a path for thumbnailing other non-image file types.
Note that when using the SVG import scripts we do see SVG files and thumbnails because those are currently set to filter on FILE_TYPE_OBJECT_IO.
WIP: UI: SVG Thumbnailsto UI: SVG ThumbnailsMinor requests.
@ -0,0 +13,4 @@
#include "../../../extern/nanosvg/nanosvgrast.h"
extern "C" {
Could the C-only function call a static local function? (to avoid
extern "C"
the whole file).@ -0,0 +15,4 @@
extern "C" {
/* Currently only creating thumbnails for this format to support specialized importers. General
It's not so obvious where this kind of info should be included, I'd prefer the file header, as this comment isn't a doc-string for the function, e.g.
@ -47,2 +47,3 @@
const char *imb_ext_image[] = {
".png", ".tga", ".bmp", ".jpg", ".jpeg", ".sgi", ".rgb", ".rgba", ".tif", ".tiff", ".tx",
".png",
".tga",
This should be reverted entirely.
Sorry, wasn't really sure what you wanted with this...
When making this "format_svg.cc" file I copied the pattern of the seven other "format_(type).cc" files for consistency. All of them do the whole file extern "C" thing. But this is made a bit weirder in that most of their functions are defined in
IMB_filetype.h
, inside an extern "C" block.So I removed the extern "C" block from this file since it isn't really needed anyway.
@blender-bot build
Harley:
This would require more work to merge. Only a single file can have NANOSVG_IMPLEMENTATION while including nanosvg.h. This is now done in some GP code so this would give duplicate symbols. Will have to think of a nice way to proceed.
Note that changes to build files are done in consolation with @LazyDodo
@blender-bot build
please provide provenance of the
nanosvgrast.h
file. There's really only two options here1 - This from the same revision as noted in
extern/nanosvg/README.blender
in this case the patch description of this diff should explicitly mention that2- This is from a different commit and this should be explained in the patch description why it is this way , and the
README.blender
needs to be updated to note the hash that was used.Unrelated sidenote: and i'm not gonna reject this diff for it, I'm "not thrilled" blenlib macro's (
ELEM
) are being used inextern/nanosvg/nanosvg.h
@antoniov can you please clean this up in a separate patch? local patch or not/extern
files shouldn't be depending on headers from/source
@LazyDodo I have created the fix of
nanosvg.h
: #109959lgtm