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

Thumbnail with icc-profile #100

Closed
kyamagu opened this issue Mar 20, 2019 · 7 comments
Closed

Thumbnail with icc-profile #100

kyamagu opened this issue Mar 20, 2019 · 7 comments
Assignees
Milestone

Comments

@kyamagu
Copy link
Contributor

kyamagu commented Mar 20, 2019

From https://github.com/kyamagu/psd-tools/issues/99

@kyamagu kyamagu self-assigned this Mar 20, 2019
@kyamagu
Copy link
Contributor Author

kyamagu commented Mar 20, 2019

This is likely due to the difference between Pillow's handling of ICC profiles for PSD files. Current psd-tools approach is to convert to sRGB space for RGB documents, and do nothing for other colors.

@andrey-hider
Copy link

Thank you for answer.
Is there any chance to update as_PIL() function to be able to create image thumbnails from psd-tools as from Pillow? Right now I see that this conversion happens in function _apply_icc(), what are the negative sides to exclude this conversion to sRGB?

@kyamagu
Copy link
Contributor Author

kyamagu commented Mar 22, 2019

@andrey-hider Sure, it is reasonable to control the behavior perhaps with argument options. Will consider in the next release.

The current behavior is to reflect the display color of the document in Photoshop UI. Without sRGB conversion, color looks different from Photoshop UI.

@kyamagu kyamagu added this to the 1.8.12 milestone Mar 22, 2019
@kyamagu kyamagu mentioned this issue Mar 25, 2019
@kyamagu
Copy link
Contributor Author

kyamagu commented Mar 25, 2019

@andrey-hider ver 1.8.12 supports the following:

icc_profile = psd.image_resources.get_data('ICC_PROFILE')
image = psd.compose(apply_icc=False)
image.save('output.png', icc_profile=icc_profile)

@andrey-hider
Copy link

@kyamagu Thank you for update.

I'm trying to execute new version and got next error:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/chalice/app.py", line 670, in _get_view_function_response
    response = view_function(**function_args)
  File "<path>/app.py", line 156, in test_psd_icc_profile
    from psd_tools.api.psd_image import PSDImage
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/psd_tools/__init__.py", line 2, in <module>
    from .api.psd_image import PSDImage
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/psd_tools/api/psd_image.py", line 10, in <module>
    from psd_tools.psd import PSD, FileHeader, ImageData, ImageResources
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/psd_tools/psd/__init__.py", line 10, in <module>
    from .base import BaseElement
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/psd_tools/psd/base.py", line 207, in <module>
    class NumericElement(ValueElement):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/psd_tools/psd/base.py", line 211, in NumericElement
    value = attr.ib(default=0.0, type=float, converter=float)
TypeError: attr() got an unexpected keyword argument 'type'

Code that I used:

def test_psd_icc_profile():
    from psd_tools.api.psd_image import PSDImage

    psd = PSDImage.open('<path_to_file>/TEST_merged.psd')
    no_icc = psd.compose(apply_icc=False)
    with_icc = psd.compose(apply_icc=True)

    print(no_icc.getextrema())
    print(with_icc.getextrema())

Do you have ideas why I have this error?
Versions of required extensions are:
Python 3.6.4
psd-tools == 1.8.12
numpy == 1.16.1
scipy == 1.2.1

Thank you!

@kyamagu
Copy link
Contributor Author

kyamagu commented Mar 25, 2019 via email

@andrey-hider
Copy link

@kyamagu Thank you, it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants