Image.save() more heavy than original when using bpy #102421

Closed
opened 2022-11-11 09:01:22 +01:00 by Julien Duroure · 14 comments
Member

System Information
Operating system: Linux Mint
Graphics card: Nvidia

Blender Version
Broken: after 29a3f43da5
Worked: Before 29a3f43da5

Short description of error
When copying an image with bpy, the newly created is much more heavy than the original

Exact steps for others to reproduce the error

  • Open the blend file
  • The original packed image file is around 513 ko
  • Run script
  • The created image is around 3.1 Mo

Some notes:

image_size_issue.blend

**System Information** Operating system: Linux Mint Graphics card: Nvidia **Blender Version** Broken: after 29a3f43da5d3 Worked: Before 29a3f43da5d3 **Short description of error** When copying an image with bpy, the newly created is much more heavy than the original **Exact steps for others to reproduce the error** - Open the blend file - The original packed image file is around 513 ko - Run script - The created image is around 3.1 Mo Some notes: - This bug was first discovered using the glTF exporter (see https://github.com/KhronosGroup/glTF-Blender-IO/issues/1787) - I git bisect the commit that cause the issue, but I also needed to cherry-pick the regression fix 4b3315fc98a9 to get my bisect works in some iteration. [image_size_issue.blend](https://archive.blender.org/developer/F13890368/image_size_issue.blend)
Author
Member

Added subscriber: @JulienDuroure

Added subscriber: @JulienDuroure
Member

Added subscribers: @brecht, @OmarEmaraDev

Added subscribers: @brecht, @OmarEmaraDev
Member

Changed status from 'Needs Triage' to: 'Needs Developer To Reproduce'

Changed status from 'Needs Triage' to: 'Needs Developer To Reproduce'
Member

I can reproduce, though tagging the module for more information before confirming.

I can reproduce, though tagging the module for more information before confirming.

Changed status from 'Needs Developer To Reproduce' to: 'Confirmed'

Changed status from 'Needs Developer To Reproduce' to: 'Confirmed'

Previously the image save operator would default to JPEG quality 90, and the Python API would use 75. Now that we made them consistent, it's quality 90 for both, leading to bigger file sizes.

That in itself I would not consider a bug, but the issue is that there is currently no API to control the quality.

Previously the image save operator would default to JPEG quality 90, and the Python API would use 75. Now that we made them consistent, it's quality 90 for both, leading to bigger file sizes. That in itself I would not consider a bug, but the issue is that there is currently no API to control the quality.

I see the glTF add-on already has some code to copy and scale the image datablock, which I think preserves file format settings like quality. But I guess for this case it's packing multiple images into channels of one image, so there is not a single image to copy the file format settings from?

I see the glTF add-on already has some code to copy and scale the image datablock, which I think preserves file format settings like quality. But I guess for this case it's packing multiple images into channels of one image, so there is not a single image to copy the file format settings from?
Author
Member

Exactly.
I made a simple script for this bug report, but for glTF cases, we sometimes need to create images from scratch, packing channels from multiple image source to a single image.

Exactly. I made a simple script for this bug report, but for glTF cases, we sometimes need to create images from scratch, packing channels from multiple image source to a single image.

This issue was referenced by 377da3f949

This issue was referenced by 377da3f94934a372c4d57c38595a6224a18d8c5e

This issue was referenced by 981245fc6f

This issue was referenced by 981245fc6fc29538e625edf429f926f7a182ddb7

This issue was referenced by 5f4afecbf3

This issue was referenced by 5f4afecbf3559a7ddcc2621d1e863a5425859404

Actually turns out the main problem is that it's saving as PNG despite being set to JPEG. I will fix that, and also add an optional quality parameter to the Image.save() for more control over that.

Actually turns out the main problem is that it's saving as PNG despite being set to JPEG. I will fix that, and also add an optional `quality` parameter to the `Image.save()` for more control over that.

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Brecht Van Lommel self-assigned this 2022-11-14 17:17:14 +01:00
Author
Member

Thanks Brecht!

Thanks Brecht!
Bastien Montagne added this to the Core project 2023-02-09 15:43:10 +01:00
Bastien Montagne removed this from the Core project 2023-02-09 18:19:07 +01:00
Sign in to join this conversation.
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
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#102421
No description provided.