mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Merge branch 'master' into patch-2
This commit is contained in:
commit
0b7fcbbc93
2
.github/workflows/test-windows.yml
vendored
2
.github/workflows/test-windows.yml
vendored
|
@ -8,7 +8,7 @@ jobs:
|
|||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10-dev"]
|
||||
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
|
||||
architecture: ["x86", "x64"]
|
||||
include:
|
||||
# PyPy3.6 only ships 32-bit binaries for Windows
|
||||
|
|
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
|
@ -15,7 +15,7 @@ jobs:
|
|||
python-version: [
|
||||
"pypy-3.7",
|
||||
"pypy-3.6",
|
||||
"3.10-dev",
|
||||
"3.10",
|
||||
"3.9",
|
||||
"3.8",
|
||||
"3.7",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
repos:
|
||||
- repo: https://github.com/psf/black
|
||||
rev: e3000ace2fd1fcb1c181bb7a8285f1f976bcbdc7 # frozen: 21.7b0
|
||||
rev: 911470a610e47d9da5ea938b0887c3df62819b85 # frozen: 21.9b0
|
||||
hooks:
|
||||
- id: black
|
||||
args: ["--target-version", "py36"]
|
||||
|
@ -24,7 +24,7 @@ repos:
|
|||
- id: remove-tabs
|
||||
exclude: (Makefile$|\.bat$|\.cmake$|\.eps$|\.fits$|\.opt$)
|
||||
|
||||
- repo: https://gitlab.com/pycqa/flake8
|
||||
- repo: https://github.com/PyCQA/flake8
|
||||
rev: dcd740bc0ebaf2b3d43e59a0060d157c97de13f3 # frozen: 3.9.2
|
||||
hooks:
|
||||
- id: flake8
|
||||
|
|
|
@ -5,6 +5,9 @@ Changelog (Pillow)
|
|||
8.4.0 (unreleased)
|
||||
------------------
|
||||
|
||||
- Prefer global transparency in GIF when replacing with background color #5756
|
||||
[radarhere]
|
||||
|
||||
- Added "exif" keyword argument to TIFF saving #5575
|
||||
[radarhere]
|
||||
|
||||
|
|
BIN
Tests/images/dispose_bgnd_transparency.gif
Normal file
BIN
Tests/images/dispose_bgnd_transparency.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.5 KiB |
|
@ -337,6 +337,13 @@ def test_dispose_background():
|
|||
pass
|
||||
|
||||
|
||||
def test_dispose_background_transparency():
|
||||
with Image.open("Tests/images/dispose_bgnd_transparency.gif") as img:
|
||||
img.seek(2)
|
||||
px = img.convert("RGBA").load()
|
||||
assert px[35, 30][3] == 0
|
||||
|
||||
|
||||
def test_transparent_dispose():
|
||||
expected_colors = [(2, 1, 2), (0, 1, 0), (2, 1, 2)]
|
||||
with Image.open("Tests/images/transparent_dispose.gif") as img:
|
||||
|
|
|
@ -999,3 +999,10 @@ class TestFileLibTiff(LibTiffTestCase):
|
|||
assert len(im.tag_v2[STRIPOFFSETS]) == 1
|
||||
finally:
|
||||
TiffImagePlugin.STRIP_SIZE = 65536
|
||||
|
||||
@pytest.mark.parametrize("compression", ("tiff_adobe_deflate", None))
|
||||
def test_save_zero(self, compression, tmp_path):
|
||||
im = Image.new("RGB", (0, 0))
|
||||
out = str(tmp_path / "temp.tif")
|
||||
with pytest.raises(SystemError):
|
||||
im.save(out, compression=compression)
|
||||
|
|
|
@ -271,11 +271,9 @@ class GifImageFile(ImageFile.ImageFile):
|
|||
Image._decompression_bomb_check(dispose_size)
|
||||
|
||||
# by convention, attempt to use transparency first
|
||||
color = (
|
||||
frame_transparency
|
||||
if frame_transparency is not None
|
||||
else self.info.get("background", 0)
|
||||
)
|
||||
color = self.info.get("transparency", frame_transparency)
|
||||
if color is None:
|
||||
color = self.info.get("background", 0)
|
||||
self.dispose = Image.core.fill("P", dispose_size, color)
|
||||
else:
|
||||
# replace with previous contents
|
||||
|
|
|
@ -133,7 +133,7 @@ if sys.platform == "win32":
|
|||
|
||||
|
||||
class MacViewer(Viewer):
|
||||
"""The default viewer on MacOS using ``Preview.app``."""
|
||||
"""The default viewer on macOS using ``Preview.app``."""
|
||||
|
||||
format = "PNG"
|
||||
options = {"compress_level": 1}
|
||||
|
|
|
@ -1620,13 +1620,15 @@ def _save(im, fp, filename):
|
|||
stride = len(bits) * ((im.size[0] * bits[0] + 7) // 8)
|
||||
# aim for given strip size (64 KB by default) when using libtiff writer
|
||||
if libtiff:
|
||||
rows_per_strip = min(STRIP_SIZE // stride, im.size[1])
|
||||
rows_per_strip = 1 if stride == 0 else min(STRIP_SIZE // stride, im.size[1])
|
||||
# JPEG encoder expects multiple of 8 rows
|
||||
if compression == "jpeg":
|
||||
rows_per_strip = min(((rows_per_strip + 7) // 8) * 8, im.size[1])
|
||||
else:
|
||||
rows_per_strip = im.size[1]
|
||||
strip_byte_counts = stride * rows_per_strip
|
||||
if rows_per_strip == 0:
|
||||
rows_per_strip = 1
|
||||
strip_byte_counts = 1 if stride == 0 else stride * rows_per_strip
|
||||
strips_per_image = (im.size[1] + rows_per_strip - 1) // rows_per_strip
|
||||
ifd[ROWSPERSTRIP] = rows_per_strip
|
||||
if strip_byte_counts >= 2 ** 16:
|
||||
|
|
14
src/thirdparty/raqm/NEWS
vendored
14
src/thirdparty/raqm/NEWS
vendored
|
@ -1,3 +1,17 @@
|
|||
Overview of changes leading to 0.7.1
|
||||
Monday, September 27, 2021
|
||||
====================================
|
||||
|
||||
Fix test failure with newer HarfBuzz versions.
|
||||
|
||||
Apply FT_Face transformation matrix when built against FreeType 2.11 or later.
|
||||
|
||||
Add meson build system. Autotools build system will be dropped in next release.
|
||||
|
||||
Improve MSVC support.
|
||||
|
||||
Build and documentation fixes.
|
||||
|
||||
Overview of changes leading to 0.7.1
|
||||
Sunday, November 22, 2020
|
||||
====================================
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
Raqm
|
||||
====
|
||||
|
||||
[![Linux & macOS build](https://travis-ci.org/HOST-Oman/libraqm.svg?branch=master)](https://travis-ci.org/HOST-Oman/libraqm)
|
||||
[![Windows build](https://img.shields.io/appveyor/ci/HOSTOman/libraqm/master.svg)](https://ci.appveyor.com/project/HOSTOman/libraqm)
|
||||
[![Build](https://github.com/HOST-Oman/libraqm/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/HOST-Oman/libraqm/actions)
|
||||
|
||||
Raqm is a small library that encapsulates the logic for complex text layout and
|
||||
provides a convenient API.
|
||||
|
@ -15,7 +14,7 @@ The documentation can be accessed on the web at:
|
|||
> http://host-oman.github.io/libraqm/
|
||||
|
||||
Raqm (Arabic: رَقْم) is writing, also number or digit and the Arabic word for
|
||||
digital (رَقَمِيّ) shares the same root, so it is a play on “digital writing”.
|
||||
digital (رَقَمِيّ) shares the same root, so it is a play on “digital writing”.
|
||||
|
||||
Building
|
||||
--------
|
||||
|
@ -30,31 +29,30 @@ To build the documentation you will also need:
|
|||
|
||||
To install dependencies on Fedora:
|
||||
|
||||
sudo dnf install freetype-devel harfbuzz-devel fribidi-devel gtk-doc
|
||||
sudo dnf install freetype-devel harfbuzz-devel fribidi-devel meson gtk-doc
|
||||
|
||||
To install dependencies on Ubuntu:
|
||||
|
||||
sudo apt-get install libfreetype6-dev libharfbuzz-dev libfribidi-dev \
|
||||
gtk-doc-tools
|
||||
sudo apt-get install libfreetype6-dev libharfbuzz-dev libfribidi-dev meson gtk-doc-tools
|
||||
|
||||
On Mac OS X you can use Homebrew:
|
||||
|
||||
brew install freetype harfbuzz fribidi gtk-doc
|
||||
brew install freetype harfbuzz fribidi meson gtk-doc
|
||||
export XML_CATALOG_FILES="/usr/local/etc/xml/catalog" # for the docs
|
||||
|
||||
Once you have the source code and the dependencies, you can proceed to build.
|
||||
To do that, run the customary sequence of commands in the source code
|
||||
directory:
|
||||
|
||||
$ ./configure
|
||||
$ make
|
||||
$ make install
|
||||
$ meson build
|
||||
$ ninja -C build
|
||||
$ ninja -C build install
|
||||
|
||||
To build the documentation, pass `--enable-gtk-doc` to the `configure` script.
|
||||
To build the documentation, pass `-Ddocs=enable` to the `meson`.
|
||||
|
||||
To run the tests:
|
||||
|
||||
$ make check
|
||||
$ ninja -C test
|
||||
|
||||
Contributing
|
||||
------------
|
4
src/thirdparty/raqm/raqm-version.h
vendored
4
src/thirdparty/raqm/raqm-version.h
vendored
|
@ -33,9 +33,9 @@
|
|||
|
||||
#define RAQM_VERSION_MAJOR 0
|
||||
#define RAQM_VERSION_MINOR 7
|
||||
#define RAQM_VERSION_MICRO 1
|
||||
#define RAQM_VERSION_MICRO 2
|
||||
|
||||
#define RAQM_VERSION_STRING "0.7.1"
|
||||
#define RAQM_VERSION_STRING "0.7.2"
|
||||
|
||||
#define RAQM_VERSION_ATLEAST(major,minor,micro) \
|
||||
((major)*10000+(minor)*100+(micro) <= \
|
||||
|
|
48
src/thirdparty/raqm/raqm.c
vendored
48
src/thirdparty/raqm/raqm.c
vendored
|
@ -39,6 +39,21 @@
|
|||
#include <hb.h>
|
||||
#include <hb-ft.h>
|
||||
|
||||
#if FREETYPE_MAJOR > 2 || \
|
||||
FREETYPE_MAJOR == 2 && FREETYPE_MINOR >= 11
|
||||
#define HAVE_FT_GET_TRANSFORM
|
||||
#endif
|
||||
|
||||
#if HB_VERSION_ATLEAST(2, 0, 0)
|
||||
#define HAVE_HB_BUFFER_SET_INVISIBLE_GLYPH
|
||||
#endif
|
||||
|
||||
#if HB_VERSION_ATLEAST(1, 8, 0)
|
||||
#define HAVE_DECL_HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES 1
|
||||
#else
|
||||
#define HAVE_DECL_HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES 0
|
||||
#endif
|
||||
|
||||
#include "raqm.h"
|
||||
|
||||
#if FRIBIDI_MAJOR_VERSION >= 1
|
||||
|
@ -455,8 +470,6 @@ raqm_set_text_utf8 (raqm_t *rq,
|
|||
return true;
|
||||
}
|
||||
|
||||
RAQM_TEST ("Text is: %s\n", text);
|
||||
|
||||
rq->flags |= RAQM_FLAG_UTF8;
|
||||
|
||||
rq->text_utf8 = malloc (sizeof (char) * len);
|
||||
|
@ -1556,6 +1569,21 @@ _raqm_resolve_scripts (raqm_t *rq)
|
|||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
_raqm_ft_transform (int *x,
|
||||
int *y,
|
||||
FT_Matrix matrix)
|
||||
{
|
||||
FT_Vector vector;
|
||||
vector.x = *x;
|
||||
vector.y = *y;
|
||||
|
||||
FT_Vector_Transform (&vector, &matrix);
|
||||
|
||||
*x = vector.x;
|
||||
*y = vector.y;
|
||||
}
|
||||
|
||||
static bool
|
||||
_raqm_shape (raqm_t *rq)
|
||||
{
|
||||
|
@ -1585,6 +1613,22 @@ _raqm_shape (raqm_t *rq)
|
|||
|
||||
hb_shape_full (run->font, run->buffer, rq->features, rq->features_len,
|
||||
NULL);
|
||||
|
||||
#ifdef HAVE_FT_GET_TRANSFORM
|
||||
{
|
||||
FT_Matrix matrix;
|
||||
hb_glyph_position_t *pos;
|
||||
unsigned int len;
|
||||
|
||||
FT_Get_Transform (hb_ft_font_get_face (run->font), &matrix, NULL);
|
||||
pos = hb_buffer_get_glyph_positions (run->buffer, &len);
|
||||
for (unsigned int i = 0; i < len; i++)
|
||||
{
|
||||
_raqm_ft_transform (&pos[i].x_advance, &pos[i].y_advance, matrix);
|
||||
_raqm_ft_transform (&pos[i].x_offset, &pos[i].y_offset, matrix);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
42
src/thirdparty/raqm/raqm.h
vendored
42
src/thirdparty/raqm/raqm.h
vendored
|
@ -30,6 +30,10 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifndef RAQM_API
|
||||
#define RAQM_API
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <ft2build.h>
|
||||
|
@ -93,86 +97,86 @@ typedef struct raqm_glyph_t {
|
|||
FT_Face ftface;
|
||||
} raqm_glyph_t;
|
||||
|
||||
raqm_t *
|
||||
RAQM_API raqm_t *
|
||||
raqm_create (void);
|
||||
|
||||
raqm_t *
|
||||
RAQM_API raqm_t *
|
||||
raqm_reference (raqm_t *rq);
|
||||
|
||||
void
|
||||
RAQM_API void
|
||||
raqm_destroy (raqm_t *rq);
|
||||
|
||||
bool
|
||||
RAQM_API bool
|
||||
raqm_set_text (raqm_t *rq,
|
||||
const uint32_t *text,
|
||||
size_t len);
|
||||
|
||||
bool
|
||||
RAQM_API bool
|
||||
raqm_set_text_utf8 (raqm_t *rq,
|
||||
const char *text,
|
||||
size_t len);
|
||||
|
||||
bool
|
||||
RAQM_API bool
|
||||
raqm_set_par_direction (raqm_t *rq,
|
||||
raqm_direction_t dir);
|
||||
|
||||
bool
|
||||
RAQM_API bool
|
||||
raqm_set_language (raqm_t *rq,
|
||||
const char *lang,
|
||||
size_t start,
|
||||
size_t len);
|
||||
|
||||
bool
|
||||
RAQM_API bool
|
||||
raqm_add_font_feature (raqm_t *rq,
|
||||
const char *feature,
|
||||
int len);
|
||||
|
||||
bool
|
||||
RAQM_API bool
|
||||
raqm_set_freetype_face (raqm_t *rq,
|
||||
FT_Face face);
|
||||
|
||||
bool
|
||||
RAQM_API bool
|
||||
raqm_set_freetype_face_range (raqm_t *rq,
|
||||
FT_Face face,
|
||||
size_t start,
|
||||
size_t len);
|
||||
|
||||
bool
|
||||
RAQM_API bool
|
||||
raqm_set_freetype_load_flags (raqm_t *rq,
|
||||
int flags);
|
||||
|
||||
bool
|
||||
RAQM_API bool
|
||||
raqm_set_invisible_glyph (raqm_t *rq,
|
||||
int gid);
|
||||
|
||||
bool
|
||||
RAQM_API bool
|
||||
raqm_layout (raqm_t *rq);
|
||||
|
||||
raqm_glyph_t *
|
||||
RAQM_API raqm_glyph_t *
|
||||
raqm_get_glyphs (raqm_t *rq,
|
||||
size_t *length);
|
||||
|
||||
bool
|
||||
RAQM_API bool
|
||||
raqm_index_to_position (raqm_t *rq,
|
||||
size_t *index,
|
||||
int *x,
|
||||
int *y);
|
||||
|
||||
bool
|
||||
RAQM_API bool
|
||||
raqm_position_to_index (raqm_t *rq,
|
||||
int x,
|
||||
int y,
|
||||
size_t *index);
|
||||
|
||||
void
|
||||
RAQM_API void
|
||||
raqm_version (unsigned int *major,
|
||||
unsigned int *minor,
|
||||
unsigned int *micro);
|
||||
|
||||
const char *
|
||||
RAQM_API const char *
|
||||
raqm_version_string (void);
|
||||
|
||||
bool
|
||||
RAQM_API bool
|
||||
raqm_version_atleast (unsigned int major,
|
||||
unsigned int minor,
|
||||
unsigned int micro);
|
||||
|
|
Loading…
Reference in New Issue
Block a user