Skip to content

Commit d206ef7

Browse files
committed
hotfixing #1266
1 parent b32abc7 commit d206ef7

File tree

11 files changed

+64
-29
lines changed

11 files changed

+64
-29
lines changed

PKG-INFO

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 1.1
22
Name: PyMuPDF
3-
Version: 1.18.18
3+
Version: 1.18.19
44
Author: Jorj McKie
55
Author-email: [email protected]
66
License: GNU AFFERO GPL 3.0
@@ -20,7 +20,7 @@ Description:
2020
Introduction
2121
============
2222

23-
PyMuPDF (current version 1.18.18) is a Python binding with support for `MuPDF <http://mupdf.com/>`_ (current version 1.18.*), a lightweight PDF, XPS, and E-book viewer, renderer and toolkit, which is maintained and developed by Artifex Software, Inc.
23+
PyMuPDF (current version 1.18.19) is a Python binding with support for `MuPDF <http://mupdf.com/>`_ (current version 1.18.*), a lightweight PDF, XPS, and E-book viewer, renderer and toolkit, which is maintained and developed by Artifex Software, Inc.
2424

2525
MuPDF can access files in PDF, XPS, OpenXPS, CBZ, EPUB and FB2 (e-books) formats, and it is known for its top performance and high rendering quality.
2626

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# PyMuPDF 1.18.18
1+
# PyMuPDF 1.18.19
22

33
![logo](https://github.com/pymupdf/PyMuPDF/blob/master/demo/pymupdf.jpg)
44

@@ -11,7 +11,7 @@ On **[PyPI](https://pypi.org/project/PyMuPDF)** since August 2016: [![Downloads]
1111

1212
# Introduction
1313

14-
PyMuPDF (current version 1.18.18) is a Python binding with support for [MuPDF](https://mupdf.com/) (current version 1.18.*), a lightweight PDF, XPS, and E-book viewer, renderer, and toolkit, which is maintained and developed by Artifex Software, Inc.
14+
PyMuPDF (current version 1.18.19) is a Python binding with support for [MuPDF](https://mupdf.com/) (current version 1.18.*), a lightweight PDF, XPS, and E-book viewer, renderer, and toolkit, which is maintained and developed by Artifex Software, Inc.
1515

1616
MuPDF can access files in PDF, XPS, OpenXPS, CBZ, EPUB and FB2 (e-books) formats, and it is known for its top performance and high rendering quality.
1717

docs/changes.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@ Change Logs
33

44
------
55

6+
**Changes in Version 1.18.18**
7+
8+
* **Fixed** issue `#1257 <https://github.com/pymupdf/PyMuPDF/issues/1257>`_. Removing the read-only flag from PDF fields is now possible.
9+
10+
* **Fixed** issue `#1252 <https://github.com/pymupdf/PyMuPDF/issues/1252>`_. Now correctly specifying the ``zoom`` value for PDF link annotations.
11+
12+
* **Fixed** issue `#1244 <https://github.com/pymupdf/PyMuPDF/issues/1244>`_. Now correctly computing the transform matrix in :meth:`Page.get_image__bbox`.
13+
14+
* **Fixed** issue `#1241 <https://github.com/pymupdf/PyMuPDF/issues/1241>`_. Prevent returning artifact characters in :meth:`Page.get_textbox`, which happened in certain constellations.
15+
16+
* **Fixed** issue `#1234 <https://github.com/pymupdf/PyMuPDF/issues/1234>`_. Avoid creating infinite rectangles in corner cases -- :meth:`Page.get_drawings`, :meth:`Page.get_cdrawings`.
17+
18+
* **Added** test data and test scripts to the source PyPI source distribution.
19+
20+
------
21+
622
**Changes in Version 1.18.17**
723

824
Focus of this version are major performance improvements of selected functions.

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
# built documents.
4444
#
4545
# The full version, including alpha/beta/rc tags.
46-
release = "1.18.17"
46+
release = "1.18.19"
4747

4848
# The short X.Y version
4949
version = release

docs/faq.rst

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,14 @@ and `extract-imgb.py <https://github.com/JorjMcKie/PyMuPDF-Utilities/blob/master
191191

192192
----------
193193

194-
How to Handle Stencil Masks
194+
How to Handle Image Masks
195195
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
196-
Some images in PDFs are accompanied by **stencil masks**. In their simplest form stencil masks represent alpha (transparency) bytes stored as separate images. In order to reconstruct the original of an image, which has a stencil mask, it must be "enriched" with transparency bytes taken from its stencil mask.
196+
Some images in PDFs are accompanied by **image masks**. In their simplest form, masks represent alpha (transparency) bytes stored as separate images. In order to reconstruct the original of an image, which has a mask, it must be "enriched" with transparency bytes taken from its mask.
197197

198-
Whether an image does have such a stencil mask can be recognized in one of two ways in PyMuPDF:
198+
Whether an image does have such a mask can be recognized in one of two ways in PyMuPDF:
199199

200-
1. An item of :meth:`Document.get_page_images` has the general format *[xref, smask, ...]*, where *xref* is the image's :data:`xref` and *smask*, if positive, is the :data:`xref` of a stencil mask.
201-
2. The (dictionary) results of :meth:`Document.extract_image` have a key *"smask"*, which also contains any stencil mask's :data:`xref` if positive.
200+
1. An item of :meth:`Document.get_page_images` has the general format ``(xref, smask, ...)``, where *xref* is the image's :data:`xref` and *smask*, if positive, is the :data:`xref` of a mask.
201+
2. The (dictionary) results of :meth:`Document.extract_image` have a key *"smask"*, which also contains any mask's :data:`xref` if positive.
202202

203203
If *smask == 0* then the image encountered via :data:`xref` can be processed as it is.
204204

@@ -207,12 +207,11 @@ To recover the original image using PyMuPDF, the procedure depicted as follows m
207207
.. image:: images/img-stencil.*
208208
:scale: 60
209209

210-
>>> pix1 = fitz.Pixmap(doc, xref) # (1) pixmap of image w/o alpha
211-
>>> pix2 = fitz.Pixmap(doc, smask) # (2) stencil pixmap
212-
>>> pix = fitz.Pixmap(pix1) # (3) copy of pix1, empty alpha channel added
213-
>>> pix.set_alpha(pix2.samples) # (4) fill alpha channel
210+
>>> pix1 = fitz.Pixmap(doc.extract_image(xref)["image"]) # (1) pixmap of image w/o alpha
211+
>>> mask = fitz.Pixmap(doc.extract_image(smask)["image"]) # (2) mask pixmap
212+
>>> pix = fitz.Pixmap(pix1, mask) # (3) copy of pix1, image mask added
214213

215-
Step (1) creates a pixmap of the "netto" image. Step (2) does the same with the stencil mask. Please note that the :attr:`Pixmap.samples` attribute of *pix2* contains the alpha bytes that must be stored in the final pixmap. This is what happens in step (3) and (4).
214+
Step (1) creates a pixmap of the basic image. Step (2) does the same with the image mask. Step (3) adds an alpha channel and fills it with transparency information.
216215

217216
The scripts `extract-imga.py <https://github.com/JorjMcKie/PyMuPDF-Utilities/blob/master/extract-imga.py>`_, and `extract-imgb.py <https://github.com/JorjMcKie/PyMuPDF-Utilities/blob/master/extract-imgb.py>`_ above also contain this logic.
218217

@@ -2108,10 +2107,10 @@ If it is *False* or if you want to be on the safe side, pick one of the followin
21082107

21092108
Missing or Unreadable Extracted Text
21102109
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2111-
This can be a number of different problems.
2110+
Fairly often, text extraction does not work text as you would expect: text may be missing at all, or may not appear in the reading sequence visible on your screen, or contain garbled characters (like a ? or a "TOFU" symbol), etc. This can be caused by a number of different problems.
21122111

2113-
Problem: no text
2114-
^^^^^^^^^^^^^^^^
2112+
Problem: no text is extracted
2113+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
21152114
Your PDF viewer does display text, but you cannot select it with your cursor, and text extraction delivers nothing.
21162115

21172116
Cause
@@ -2130,7 +2129,7 @@ Text extraction does not deliver the text in readable order, duplicates some tex
21302129
Cause
21312130
^^^^^^
21322131
1. The single characters are redable as such (no "<?>" symbols), but the sequence in which the text is **coded in the file** deviates from the reading order. The motivation behind may be technical or protection of data against unwanted copies.
2133-
2. Many "<?>" symbols occur indicating MuPDF could not interpret these characters. The PDF creator may haved used a font that displays readable text, but obfuscates the unicode character that leads to the readable symbol (glyph).
2132+
2. Many "<?>" symbols occur, indicating MuPDF could not interpret these characters. The font may indeed be unsupported by MuPDF, or the PDF creator may haved used a font that displays readable text, but on purpose obfuscates the originating corresponding unicode character.
21342133

21352134
Solution
21362135
^^^^^^^^

docs/pixmap.rst

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,18 @@ Have a look at the :ref:`FAQ` section to see some pixmap usage "at work".
8383
:arg source: the source pixmap.
8484
:type source: *Pixmap*
8585

86+
.. method:: __init__(self, source, mask)
87+
88+
* New in v1.18.18
89+
90+
**Copy and add image mask:** Copy *source* pixmap, add an alpha channel with transparency data from a mask pixmap.
91+
92+
:arg source: pixmap without alpha channel.
93+
:type source: :ref:`Pixmap`
94+
95+
:arg mask: a mask pixmap. Must be a graysale pixmap.
96+
:type mask: :ref:`Pixmap`
97+
8698
.. method:: __init__(self, source, width, height, [clip])
8799

88100
**Copy and scale:** Copy *source* pixmap, scaling new width and height values -- the image will appear stretched or shrunk accordingly. Supports partial copying. The source colorspace may be *None*.
@@ -96,7 +108,7 @@ Have a look at the :ref:`FAQ` section to see some pixmap usage "at work".
96108

97109
:arg irect_like clip: restrict the resulting pixmap to this region of the **scaled** pixmap.
98110

99-
.. note:: If width or height are not *de facto* integers (i.e. ``value.is_integer() != True``), then the resulting pixmap **will have an alpha channel**.
111+
.. note:: If width or height do not *represent* integers (i.e. ``value.is_integer() != True``), then the resulting pixmap **will have an alpha channel**.
100112

101113
.. method:: __init__(self, source, alpha=1)
102114

@@ -255,7 +267,7 @@ Have a look at the :ref:`FAQ` section to see some pixmap usage "at work".
255267

256268
:arg bytes,bytearray,BytesIO alphavalues: the new alpha values. If provided, its length must be at least *width * height*. If omitted (``None``), all alpha values are set to 255 (no transparency). *Changed in version 1.14.13:* *io.BytesIO* is now also accepted.
257269
:arg bool premultiply: *New in v1.18.13:* whether to premultiply color components with the alpha value.
258-
:arg list,tuple opaque: specify a color that should be fully transparent -- ignoring the alpha value of the parameter. A sequence of integers in ``range(256)`` with a length of :attr:`Pixmap.n`. Default is *None*. E.g. in the RGB case a typical choice would be ``opaque=(255, 255, 255)`` for white.
270+
:arg list,tuple opaque: ignore the alpha value and set this color to fully transparent. A sequence of integers in ``range(256)`` with a length of :attr:`Pixmap.n`. Default is *None*. For example, a typical choice for RGB would be ``opaque=(255, 255, 255)`` (white).
259271

260272

261273
.. method:: invert_irect([irect])

docs/version.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Covered Version
22
--------------------
33

4-
This documentation covers PyMuPDF v1.18.17 features as of **2021-08-23 00:00:01**.
4+
This documentation covers PyMuPDF v1.18.19 features as of **2021-09-16 16:45:29**.
55

66
.. note:: The major and minor versions of **PyMuPDF** and **MuPDF** will always be the same. Only the third qualifier (patch level) may deviate from that of MuPDF.

fitz/fitz.i

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9565,6 +9565,11 @@ CheckParent(self)
95659565
cspaces = {"gray": csGRAY, "rgb": csRGB, "cmyk": csCMYK}
95669566
if type(colorspace) is str:
95679567
colorspace = cspaces.get(colorspace.lower(), None)
9568+
%}
9569+
%pythonappend get_pixmap
9570+
%{
9571+
val.samples_mv = val._samples_mv()
9572+
val.samples_ptr = val._samples_ptr()
95689573
%}
95699574
struct Pixmap *
95709575
get_pixmap(PyObject *matrix = NULL, struct Colorspace *colorspace = NULL, int alpha = 0)
@@ -9883,7 +9888,12 @@ struct DisplayList {
98839888
// DisplayList.get_pixmap
98849889
//----------------------------------------------------------------
98859890
FITZEXCEPTION(get_pixmap, !result)
9886-
%pythonappend get_pixmap %{val.thisown = True%}
9891+
%pythonappend get_pixmap
9892+
%{
9893+
val.thisown = True
9894+
val.samples_mv = val._samples_mv()
9895+
val.samples_ptr = val._samples_ptr()
9896+
%}
98879897
struct Pixmap *get_pixmap(PyObject *matrix=NULL,
98889898
struct Colorspace *colorspace=NULL,
98899899
int alpha=0,

fitz/utils.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,8 +704,6 @@ def get_pixmap(page: Page, **kw) -> Pixmap:
704704
pix = dl.get_pixmap(matrix=matrix, colorspace=colorspace, alpha=alpha, clip=clip)
705705
dl = None
706706
return pix
707-
# doc = page.parent
708-
# return page._makePixmap(doc, matrix, colorspace, alpha, annots, clip)
709707

710708

711709
def get_page_pixmap(

fitz/version.i

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
%pythoncode %{
22
VersionFitz = "1.18.0"
3-
VersionBind = "1.18.18"
4-
VersionDate = "2021-09-16 00:00:01"
5-
version = (VersionBind, VersionFitz, "20210916000001")
3+
VersionBind = "1.18.19"
4+
VersionDate = "2021-09-16 16:45:29"
5+
version = (VersionBind, VersionFitz, "20210916164529")
66
%}

0 commit comments

Comments
 (0)