Skip to content

Update blender_thumbnailer.py to read Blender 5.x files - #1481

Open
050011-code wants to merge 5 commits into
TagStudioDev:mainfrom
050011-code:blend-thumbnail
Open

Update blender_thumbnailer.py to read Blender 5.x files#1481
050011-code wants to merge 5 commits into
TagStudioDev:mainfrom
050011-code:blend-thumbnail

Conversation

@050011-code

Copy link
Copy Markdown
Contributor

Summary

Updates blender_thumbnailer.py to read Blender 5.x files.

Refactor blender_thumbnailer.py to improve readability and maintainability. (Declaring this bit as AI made)

Handle file operations more safely.

Tasks Completed

  • Platforms Tested:
    • Windows x86
    • Windows ARM
    • macOS x86
    • macOS ARM
    • Linux x86
    • Linux ARM
  • Tested For:
    • Basic functionality
    • PyInstaller executable

Updates blender_thumbnailer.py to read Blender 5.x files.
Also refactor blender_thumbnailer.py to improve readability and maintainability. (Declaring this bit as AI made)
Handle file operations more safely.
@050011-code

050011-code commented Aug 16, 2026

Copy link
Copy Markdown
Contributor Author

Thats on me for not remembering to fix the formating
Looks like I also massacred the attribution

@050011-code

050011-code commented Aug 16, 2026

Copy link
Copy Markdown
Contributor Author

I'm sorry I was trying to make this pull request on my own fork!

There are still errors as its current state was not meant to be for the original repo

@050011-code
050011-code marked this pull request as draft August 16, 2026 12:07
Refactor blender_thumbnailer.py to use type hints and improve readability.
Removed unnecessary logging statements to clean up code.
Updated image resizing method to use Image.Resampling.BICUBIC.
@050011-code
050011-code marked this pull request as ready for review August 17, 2026 02:08
@CyanVoxel CyanVoxel added Type: UI/UX User interface and/or user experience Priority: Low Doesn't require immediate attention Status: Review Needed A review of this is needed TagStudio: Thumbs/Previews File thumbnails or previews labels Aug 17, 2026
@CyanVoxel CyanVoxel added this to the Alpha v9.6.4 milestone Aug 17, 2026
@CyanVoxel CyanVoxel moved this to 🏓 Ready for Review in TagStudio Development Aug 17, 2026
@CyanVoxel

Copy link
Copy Markdown
Member

(Declaring this bit as AI made)

Thank you for your willingness to contribute and fix this issue. Before I start making review comments on this, I'd like to cite our CONTRIBUTING.md's "Unacceptable Code" section:

Unacceptable Code
The following types of code will NOT be accepted to the project:

  • [...]
  • Code that you do not understand and/or cannot explain (i.e. "vibe coding")

If you're not able to explain why you made specific changes in this (preferably with sources from Blender where applicable) then I'm afraid I won't review this as per our contributing policy. If you do know what you're doing with these changes and are open to me (heavily) scrutinizing the AI-assisted changes, then I'll go ahead with an in-depth review. I wouldn't pester you over exact undocumented byte ranges as long as they work, but every other change I'd want explanations for.

Also, I just pulled this to actually give it a quick test, and it's not working with my Blender 5.x test file:
[info ] [ThumbRenderer][BLENDER][INFO] blender_5.blend Doesn't have an embedded thumbnail.
image

Comment on lines +243 to +248
finally:
if blendfile is not None:
blendfile.close()

return image_buffer, x, y
if raw_file is not None and raw_file is not blendfile:
raw_file.close()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If all you're doing with the try finally block is to manage opening and closing files, you should instead use "with" context managers

Comment on lines +25 to +27
# --------------------------------------------------------------
# Open file.
# --------------------------------------------------------------

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary to add three lines of comments to a self-explaining line of code (this comment style is a pattern in this PR)

Suggested change
# --------------------------------------------------------------
# Open file.
# --------------------------------------------------------------

Comment on lines +34 to +36
# --------------------------------------------------------------
# GZIP-compressed blend file.
# --------------------------------------------------------------

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary to have fluff comments like these lines

Suggested change
# --------------------------------------------------------------
# GZIP-compressed blend file.
# --------------------------------------------------------------
# GZIP-compressed blend file.

Comment on lines +137 to +139
# --------------------------------------------------------------
# Walk the BHeads until we find TEST.
# --------------------------------------------------------------

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# --------------------------------------------------------------
# Walk the BHeads until we find TEST.
# --------------------------------------------------------------
# Walk the BHeads until we find TEST.

Comment on lines +180 to +183
# ----------------------------------------------------------
# REND contains render information before TEST.
# Skip its payload.
# ----------------------------------------------------------

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# ----------------------------------------------------------
# REND contains render information before TEST.
# Skip its payload.
# ----------------------------------------------------------
# REND contains render information before TEST, skip its payload.

if code == rend:
blendfile.seek(length, os.SEEK_CUR)
# ----------------------------------------------------------
# Blender 5+ BHead

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Make version numbers consistent with one another

Suggested change
# Blender 5+ BHead
# Blender 5.0+ BHead

code: bytes = bhead[:4]

# ----------------------------------------------------------
# Blender 5+

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Blender 5+
# Blender 5.0+

Comment on lines +158 to +162
length: int = struct.unpack_from(
"<Q",
bhead,
16,
)[0]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be one line

Suggested change
length: int = struct.unpack_from(
"<Q",
bhead,
16,
)[0]
length: int = struct.unpack_from("<Q", bhead, 16)[0]

Comment on lines +174 to +178
length = struct.unpack_from(
int_endian + "i",
bhead,
4,
)[0]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be one line

Suggested change
length = struct.unpack_from(
int_endian + "i",
bhead,
4,
)[0]
length = struct.unpack_from(int_endian + "i", bhead, 4)[0]

Comment on lines +215 to +218
x, y = struct.unpack(
int_endian_pair,
dimensions,
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
x, y = struct.unpack(
int_endian_pair,
dimensions,
)
x, y = struct.unpack(int_endian_pair, dimensions)

@CyanVoxel CyanVoxel removed the Status: Review Needed A review of this is needed label Aug 17, 2026
@CyanVoxel CyanVoxel moved this from 🏓 Ready for Review to 👀 In review in TagStudio Development Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: Low Doesn't require immediate attention TagStudio: Thumbs/Previews File thumbnails or previews Type: UI/UX User interface and/or user experience

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

2 participants