posted on 2023-06-03 20:24 read(719) comment(0) like(0) collect(1)
Hello everyone, I am Kongkong star, and I will share this article with you
《通过Python的fitz库提取pdf中的图片》
.
The Fitz library is a Python image processing library mainly used to open, edit and save images in PDF, TIFF and JPEG formats. It helps users read and write PDF files, extract PDF pages, and mark and annotate pages. In addition, the Fitz library also provides some image processing functions, such as rotation, cropping, scaling, adjusting brightness, contrast and color balance, etc. These features make the Fitz library a very useful tool for image processing.
pip install fitz
pip show fitz
Name: fitz
Version: 0.0.1.dev2
Summary: Fitz: Workflow Mangement for neuroimaging data.
Home-page: http://github.com/kastman/fitz
Author: Erik Kastman
Author-email: erik.kastman@gmail.com
License: BSD (3-clause)
Requires: configobj, configparser, httplib2, nibabel, nipype, numpy, pandas, pyxnat, scipy
Required-by:
To use fitz, you need to install the pymupdf library.
PyMuPDF is a Python-based open source PDF processing library that provides a series of PDF document processing functions, such as reading, editing, creating, converting, etc. It is a Python binding for MuPDF, a lightweight open source PDF document rendering engine that supports multiple platforms and multiple file formats.
PyMuPDF is fast, efficient, and easy to use, and can be used for automated processing and batch processing of PDF documents, such as extracting text, extracting images, adding or modifying bookmarks, adding or modifying comments, merging PDF files, cutting PDF files, extracting PDF pages, etc. At the same time, it also supports PDF rendering into pictures, which is convenient for quick preview and thumbnail generation.
In short, PyMuPDF is a very practical Python PDF processing library, suitable for a variety of scenarios, such as data processing, document processing, automated office, etc.
pip install pymupdf
pip show pymupdf
Name: PyMuPDF
Version: 1.22.3
Summary: Python bindings for the PDF toolkit and renderer MuPDF
Home-page: https://github.com/pymupdf/PyMuPDF
Author: Artifex
Author-email: support@artifex.com
License: GNU AFFERO GPL 3.0
Requires:
Required-by:
fitz is a module of the Pymupdf library, it is one of the main modules of Pymupdf and the most commonly used module. The fitz module provides basic operations on PDF documents, such as opening, reading, editing, saving, etc.
import fitz
local = '/Users/kkstar/Downloads/'
pdf_doc = fitz.open(local+'demo_pic.pdf')
for pg in range(pdf_doc.page_count):
page = pdf_doc[pg]
image_list = page.get_images()
for img in image_list:
xref = img[0]
pix = fitz.Pixmap(pdf_doc, xref)
if str(fitz.csRGB) == str(pix.colorspace):
img_path = local + f'image{pg+1}_{xref}.png'
pix.save(img_path)
Author:Poison
link:http://www.pythonblackhole.com/blog/article/78483/84dc8871de8c7df2c92e/
source:python black hole net
Please indicate the source for any form of reprinting. If any infringement is discovered, it will be held legally responsible.
name:
Comment content: (supports up to 255 characters)
Copyright © 2018-2021 python black hole network All Rights Reserved All rights reserved, and all rights reserved.京ICP备18063182号-7
For complaints and reports, and advertising cooperation, please contact vgs_info@163.com or QQ3083709327
Disclaimer: All articles on the website are uploaded by users and are only for readers' learning and communication use, and commercial use is prohibited. If the article involves pornography, reactionary, infringement and other illegal information, please report it to us and we will delete it immediately after verification!