-
Notifications
You must be signed in to change notification settings - Fork 588
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(jpeg): Support encoding/decoding arbitrary metadata as comments
This is needed to port Blender's current JPEG IO code to using OIIO, but is also a useful feature to have in general. For reading, the code tries to parse comments as colon-separated key-value pairs and sets metadata accordingly. For writing, this needs to be explicitly enabled by setting jpeg:com_attributes to 1 in order to avoid accidentally bloating files for existing applications. Signed-off-by: Lukas Stockner <[email protected]>
- Loading branch information
1 parent
c658c8f
commit 3521e6c
Showing
7 changed files
with
151 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
Reading src/blender-render.jpg | ||
src/blender-render.jpg : 640 x 480, 3 channel, uint8 jpeg | ||
SHA-1: A60D05FC42FDEE2FC8907531E3641C17D7C1E3AB | ||
channel list: R, G, B | ||
ImageDescription: "Blender:File:<untitled>" | ||
Blender:Camera: "Camera" | ||
Blender:Date: "2024/09/17 15:50:17" | ||
Blender:File: "<untitled>" | ||
Blender:Frame: "001" | ||
Blender:RenderTime: "00:03.49" | ||
Blender:Scene: "Scene" | ||
Blender:Time: "00:00:00:01" | ||
jpeg:subsampling: "4:2:0" | ||
oiio:ColorSpace: "sRGB" | ||
Comparing "src/blender-render.jpg" and "no-attribs.jpg" | ||
PASS | ||
Reading no-attribs.jpg | ||
no-attribs.jpg : 640 x 480, 3 channel, uint8 jpeg | ||
SHA-1: 329B449C07E6649023504E2C8E5130B41985CF7F | ||
channel list: R, G, B | ||
ImageDescription: "Blender:File:<untitled>" | ||
Blender:File: "<untitled>" | ||
Exif:ColorSpace: 1 | ||
Exif:ExifVersion: "0230" | ||
Exif:FlashPixVersion: "0100" | ||
IPTC:Caption: "Blender:File:<untitled>" | ||
jpeg:subsampling: "4:2:0" | ||
oiio:ColorSpace: "sRGB" | ||
Reading src/blender-render.jpg | ||
src/blender-render.jpg : 640 x 480, 3 channel, uint8 jpeg | ||
SHA-1: A60D05FC42FDEE2FC8907531E3641C17D7C1E3AB | ||
channel list: R, G, B | ||
ImageDescription: "Blender:File:<untitled>" | ||
Blender:Camera: "Camera" | ||
Blender:Date: "2024/09/17 15:50:17" | ||
Blender:File: "<untitled>" | ||
Blender:Frame: "001" | ||
Blender:RenderTime: "00:03.49" | ||
Blender:Scene: "Scene" | ||
Blender:Time: "00:00:00:01" | ||
jpeg:subsampling: "4:2:0" | ||
oiio:ColorSpace: "sRGB" | ||
Comparing "src/blender-render.jpg" and "with-attribs.jpg" | ||
PASS | ||
Reading with-attribs.jpg | ||
with-attribs.jpg : 640 x 480, 3 channel, uint8 jpeg | ||
SHA-1: 329B449C07E6649023504E2C8E5130B41985CF7F | ||
channel list: R, G, B | ||
ImageDescription: "Blender:File:<untitled>" | ||
Blender:Camera: "Camera" | ||
Blender:Date: "2024/09/17 15:50:17" | ||
Blender:File: "<untitled>" | ||
Blender:Frame: "001" | ||
Blender:RenderTime: "00:03.49" | ||
Blender:Scene: "Scene" | ||
Blender:Time: "00:00:00:01" | ||
Exif:ColorSpace: 1 | ||
Exif:ExifVersion: "0230" | ||
Exif:FlashPixVersion: "0100" | ||
IPTC:Caption: "Blender:File:<untitled>" | ||
jpeg:subsampling: "4:2:0" | ||
oiio:ColorSpace: "sRGB" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env python | ||
|
||
# Copyright Contributors to the OpenImageIO project. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# https://github.com/AcademySoftwareFoundation/OpenImageIO | ||
|
||
|
||
redirect = ' >> out.txt 2>&1 ' | ||
|
||
# This file was rendered and saved in Blender, and therefore contains metadata | ||
# in the form of comments. | ||
|
||
# Check if the comments are correctly decoded as attributes, and that writing | ||
# to a new JPEG does not include them by default. | ||
command += rw_command ("src", "blender-render.jpg", use_oiiotool=1, | ||
output_filename="no-attribs.jpg") | ||
command += info_command ("no-attribs.jpg", safematch=True) | ||
|
||
# Check that, when jpeg:com_attributes is set, the attributes are preserved. | ||
command += rw_command ("src", "blender-render.jpg", use_oiiotool=1, | ||
output_filename="with-attribs.jpg", | ||
extraargs="--attrib:type=int jpeg:com_attributes 1") | ||
command += info_command ("with-attribs.jpg", safematch=True) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.