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

BUG: Inverse color in CMYK images #1947

Merged
merged 5 commits into from
Jul 8, 2023
Merged

BUG: Inverse color in CMYK images #1947

merged 5 commits into from
Jul 8, 2023

Conversation

pubpub-zz
Copy link
Collaborator

closes #1895

CMYK image without decode requires reverting scale (cf p243,2§ last sentence in PDF 1.7 spec)

closes py-pdf#1895

CMYK image without decode requires reverting scale
(cf p243,2§ last sentence in PDF 1.7 spec)
@MartinThoma
Copy link
Member

pypdf/_page.py:2446: in __getitem__
    len_self = len(self)
pypdf/_page.py:2427: in __len__
    return self.length_function()
pypdf/_reader.py:453: in _get_num_pages
    return self.trailer[TK.ROOT]["/Pages"]["/Count"]  # type: ignore
pypdf/generic/_data_structures.py:309: in __getitem__
    return dict.__getitem__(self, key).get_object()
pypdf/generic/_base.py:306: in get_object
    obj = self.pdf.get_object(self)
pypdf/_reader.py:1329: in get_object
    retval = self._get_object_from_stream(indirect_reference)  # type: ignore
pypdf/_reader.py:1252: in _get_object_from_stream
    obj_stm: EncodedStreamObject = IndirectObject(stmnum, 0, self).get_object()  # type: ignore
pypdf/generic/_base.py:306: in get_object
    obj = self.pdf.get_object(self)
pypdf/_reader.py:1393: in get_object
    retval = self._encryption.decrypt_object(
pypdf/_encryption.py:989: in decrypt_object
    return cf.decrypt_object(obj)
pypdf/_encryption.py:208: in decrypt_object
    obj._data = self.stmCrypt.decrypt(obj._data)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pypdf._encryption.CryptAES object at 0x7fcf1d3e81f0>
data = b'\xe6\x10$\xb7\xe0\xed\xe1x\r\x10.\x14\xd3+@\xa3\xab_\xa76Mc\xffc/\xc6\x87<\x95\x80\xeb2\xc1Lu8\xb1Q\x15|a\xda\x0c\xb...xdc\x8d\x19M\x95\xfd\xf5d\xde\xf4\x14\x1a3\xa8\xf9@\x8aa\x93\xff4\xf5\xef:M\xa8L\xe7b/\xc4\xe4\x83\x89\xfb\xc5 7d\xf12'

    def decrypt(self, data: bytes) -> bytes:
>       raise DependencyError("PyCryptodome is required for AES algorithm")
E       pypdf.errors.DependencyError: PyCryptodome is required for AES algorithm

pypdf/_encryption.py:150: DependencyError

oO ... did I mess something up with the AES support PR?

@pubpub-zz
Copy link
Collaborator Author

this is a new test file which is encrypted. I've added some code to bypass the test if cryptodome is missing

@codecov
Copy link

codecov bot commented Jul 8, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (c239073) 93.92% compared to head (bc1a495) 93.93%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1947   +/-   ##
=======================================
  Coverage   93.92%   93.93%           
=======================================
  Files          33       33           
  Lines        6983     6993   +10     
  Branches     1382     1386    +4     
=======================================
+ Hits         6559     6569   +10     
  Misses        273      273           
  Partials      151      151           
Impacted Files Coverage Δ
pypdf/filters.py 93.57% <100.00%> (+0.15%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@pubpub-zz
Copy link
Collaborator Author

@MartinThoma
all yours 🙂

@MartinThoma MartinThoma changed the title BUG : inverse color in CMYK images BUG: Inverse color in CMYK images Jul 8, 2023
@MartinThoma MartinThoma merged commit 8753663 into py-pdf:main Jul 8, 2023
@MartinThoma
Copy link
Member

Nice!

this is a new test file which is encrypted
I should have looked at the code 😅

MartinThoma added a commit that referenced this pull request Jul 9, 2023
Bug Fixes (BUG):
-  Prevent updating page contents after merging page (stamping/watermarking) (#1952)
-  % to be hex encoded in names (#1958)
-  Inverse color in CMYK images (#1947)
-  Dates conversion not working with Z00\'00\' (#1946)
-  Support UTF-16-LE Strings (#1884)

[Full Changelog](3.12.0...3.12.1)
MartinThoma added a commit that referenced this pull request Jul 9, 2023
Bug Fixes (BUG):
-  Prevent updating page contents after merging page (stamping/watermarking) (#1952)
-  % to be hex encoded in names (#1958)
-  Inverse color in CMYK images (#1947)
-  Dates conversion not working with Z00\'00\' (#1946)
-  Support UTF-16-LE Strings (#1884)

[Full Changelog](3.12.0...3.12.1)
@pubpub-zz pubpub-zz deleted the cmyk branch September 2, 2023 09:50
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.

BUG: Transparency is converted to black
2 participants