Fix #2691: keep image name suffixes like ".001" on export#2711
Open
Builder106 wants to merge 1 commit into
Open
Fix #2691: keep image name suffixes like ".001" on export#2711Builder106 wants to merge 1 commit into
Builder106 wants to merge 1 commit into
Conversation
When combining image names, __gather_name ran os.path.splitext on the
image datablock name. For datablock names such as "Image.001" or
"Image.Other.001" this stripped the ".001" / ".001" suffix as if it were
a file extension, so distinct images collapsed to the same glTF name
("Image", "Image") and became ambiguous on re-import.
Datablock names are not filenames, so only strip a genuine image
extension (.png/.jpg/.jpeg/.webp) here, matching the whitelist the
shared-filepath branch above already uses.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2691.
Problem
On export, image datablock names containing a
.(Blender's own duplicate suffix, e.g.Image.001,Image.Other.001) lose everything after the last dot. Distinct images then collapse to the same glTF imagename(Image,Image), which is ambiguous and, as reported, scrambles image names on re-import.Cause
In
exp/material/image.py,__gather_namerunsos.path.splitext(img.name)when combining names:img.nameis a datablock name, not a filename, sosplitextwrongly treats.001/.Other.001as a file extension. (The shared-filepath branch a few lines above is already correct — it only strips a whitelisted real image extension.)Fix
Apply that same whitelist guard to the datablock-name loop: only strip a genuine image extension (
.png/.jpg/.jpeg/.webp); otherwise keep the full name. This follows the guidance on the issue — "when possible, we need to do our best to export correctly the name, avoiding ambiguity."Verification
Three images named
Image,Image.001,Image.Other.001, each on its own plane, exported to GLB (Blender 5.x):images[].namein the GLB["Image", "Image", "Image.Other"](collision)["Image", "Image.001", "Image.Other.001"]Genuine file extensions are still stripped (
wood.png→wood), and dotted names that are not extensions are preserved (v1.5_diffusestays intact).