Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Way to easy specify NCLX output color profile #171

Merged
merged 3 commits into from
Nov 14, 2023
Merged

Way to easy specify NCLX output color profile #171

merged 3 commits into from
Nov 14, 2023

Conversation

bigcat88
Copy link
Owner

This PR provides a way to easy specify NCLX output color profile.

Changes proposed in this pull request:

  • Image write tests were disabled if libheif has lower version then 1.17.3 (libheif has some bug in 1.16.x versions, that crashes the process in some cases when NCLX writing is enabled)
  • SAVE_NCLX_PROFILE changed to be True by default.
  • color_primaries, transfer_characteristics, matrix_coefficients, full_range_flag - can be specified as a parameters for save operation.

This approach allow easy to encode in lossless mode:

    buf = BytesIO()
    im_rgb.save(buf, format=save_format, quality=-1, chroma=444, matrix_coefficients=0)
    helpers.assert_image_equal(im_rgb, Image.open(buf))

Also it allows like before just change nclx values in info dictionary:

    buf = BytesIO()
    im.info["nclx_profile"]["matrix_coefficients"] = 0
    im.info["nclx_profile"]["color_primaries"] = 1
    im.save(buf, format="HEIF")

The documentation has been updated with this information, in theory that's it, the problem with NCLX color profiles is solved and closed.

strukturag/libheif#995

Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
Copy link

codecov bot commented Nov 14, 2023

Codecov Report

Merging #171 (10ae2c4) into master (365d230) will not change coverage.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #171   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        10           
  Lines          907       906    -1     
=========================================
- Hits           907       906    -1     
Files Coverage Δ
pillow_heif/heif.py 100.00% <ø> (ø)
pillow_heif/misc.py 100.00% <100.00%> (ø)
pillow_heif/options.py 100.00% <100.00%> (ø)

@bigcat88 bigcat88 merged commit 9218ac1 into master Nov 14, 2023
26 checks passed
@bigcat88 bigcat88 deleted the NCLX-rework branch November 14, 2023 14:59
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.

None yet

1 participant