[Python] Extract all Images from PDF with Python, and retain their transparency

Discussão em 'Python' iniciado por Stack, Janeiro 30, 2025.

  1. Stack

    Stack Membro Participativo

    I see a number of solutions on the web and here for extracting images from a PDF with PyMuPDF, PyPDF2, and others, but none them successfully retain transparency information, are using deprecated code that no longer works, or the questions have gone unanswered. The examples I try show a black background where the transparency should be. If I open the PDF in photoshop and pull out the image it is transparent backgrounded as I would expect. So I know the information is in there somewhere. Does anyone have an example that does this with Python?

    Here is an example of a post with solutions that do extract images, but they all convert to the wrong file format, or save as png but missing transparent aspects.

    Extract images from PDF without resampling, in python?

    Continue reading...

Compartilhe esta Página