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
Extract some transparent PNG images, discoloration occurs #670
Comments
The logic to recover the alpha channel is known to be incomplete. def recoveImage(xref, smake):
def getimage(pix):
if pix.colorspace.n != 4:
return pix
tpix = fitz.Pixmap(fitz.csRGB, pix)
return tpix
pix1 = fitz.Pixmap(self.mu_Document, xref)
pix2 = fitz.Pixmap(self.mu_Document, smake)
pix = fitz.Pixmap(pix1, 1) # add alpha channel
ba = bytearray(pix2.samples)
for i in range(len(ba)):
if ba[i] > 0:
ba[i] = 255
pix.setAlpha(ba)
pix1 = pix2 = None
return getimage(pix) |
I will temporarily use PIL to restore transparency, looking forward to improvement |
Ah, ok. |
|
Great, thanks. |
OK |
I have changed the example scripts extract-imga.py and extract-imgb.py to make use of PIL/Pillow in case of transparent images. |
The original image:
Extracted image:
The text was updated successfully, but these errors were encountered: