Skip to content

Fix #2691: keep image name suffixes like ".001" on export#2711

Open
Builder106 wants to merge 1 commit into
KhronosGroup:mainfrom
Builder106:fix/2691-image-name-periods
Open

Fix #2691: keep image name suffixes like ".001" on export#2711
Builder106 wants to merge 1 commit into
KhronosGroup:mainfrom
Builder106:fix/2691-image-name-periods

Conversation

@Builder106

Copy link
Copy Markdown

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 image name (Image, Image), which is ambiguous and, as reported, scrambles image names on re-import.

Cause

In exp/material/image.py, __gather_name runs os.path.splitext(img.name) when combining names:

for img in imgs:
    name, extension = os.path.splitext(img.name)   # "Image.001" -> "Image"
    names.append(name)

img.name is a datablock name, not a filename, so splitext wrongly treats .001 / .Other.001 as 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[].name in the GLB
before ["Image", "Image", "Image.Other"] (collision)
after ["Image", "Image.001", "Image.Other.001"]

Genuine file extensions are still stripped (wood.pngwood), and dotted names that are not extensions are preserved (v1.5_diffuse stays intact).

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GLB Export - Image Names Can't Contain Periods "."

1 participant