Skip to content

@bimusiek #1467

@georgehandrew

Description

@georgehandrew

@bimusiek
I have added functionality to solve your problem - hopefully in a fairly elegant way:

  • Changed Page.getImageList() and Document.getPageImageList() to provide the xref of the soft-image mask /SMask parameter as the second item of each image entry (it was useless before anyway). If this number is positive, then the image itself should be specially treated for creating PNGs.
  • If [xref, smask,..., "Im2"] is an entry of getPageImageList() and smask is positive, then the following statements should create the original Im2 png:
pix1 = fitz.Pixmap(doc, xref)     # pixmap without alpha channel
pix2 = fitz.Pixmap(doc, smask)    # this contains the alpha values in its samples
pix3 = fitz.Pixmap(pix1)     # copy of pix1 with alpha channel added (new constructor)
pix3.setAlpha(pix2.samples)     # fill its alpha values with pix2 samples (new method)
pix3.writePNG("Im2.png")     # this should look right now!

Pixmap pix3 should now reflect the original image - and be what you were missing ... let me know your experiences.

Originally posted by @JorjMcKie in #98 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions