repo
string
pull_number
int64
instance_id
string
issue_numbers
list
base_commit
string
patch
string
test_patch
string
problem_statement
string
hints_text
string
created_at
timestamp[ns, tz=UTC]
version
float64
python-pillow/Pillow
7,870
python-pillow__Pillow-7870
[ "7511" ]
8afedb7ba441933a5c1948b649585cff0921ec20
diff --git a/src/PIL/Jpeg2KImagePlugin.py b/src/PIL/Jpeg2KImagePlugin.py --- a/src/PIL/Jpeg2KImagePlugin.py +++ b/src/PIL/Jpeg2KImagePlugin.py @@ -19,7 +19,7 @@ import os import struct -from . import Image, ImageFile, _binary +from . import Image, ImageFile, ImagePalette, _binary class BoxReader: @@ -162,6 +16...
diff --git a/Tests/test_file_jpeg2k.py b/Tests/test_file_jpeg2k.py --- a/Tests/test_file_jpeg2k.py +++ b/Tests/test_file_jpeg2k.py @@ -364,6 +364,16 @@ def test_subsampling_decode(name: str) -> None: assert_image_similar(im, expected, epsilon) +@pytest.mark.skipif( + not os.path.exists(EXTRA_DIR), reaso...
JPEG2000 image read incorrectly When doing ```python from PIL import Image Image.open('test.jp2').show() ``` on the file [test.jp2.zip](https://github.com/python-pillow/Pillow/files/13223024/test.jp2.zip) an apparently incorrect result is displayed. I have checked this with both the latest Pillow-10.1.0 as we...
Am I correct in saying that you created this image <img src="https://github.com/python-pillow/Pillow/assets/3112309/71af2f2b-79e6-4dcf-869e-421a1433e4af" width="400" /> but were expecting this? <img src="https://github.com/python-pillow/Pillow/assets/3112309/963488af-1728-4f6a-b588-4e76ef846107" width="400" ...
2024-03-12T00:48:03Z
10.2
python-pillow/Pillow
7,823
python-pillow__Pillow-7823
[ "7817" ]
bebf038e49b10500a36161c1bac24b76cf70bcd4
diff --git a/src/PIL/PngImagePlugin.py b/src/PIL/PngImagePlugin.py --- a/src/PIL/PngImagePlugin.py +++ b/src/PIL/PngImagePlugin.py @@ -392,8 +392,8 @@ def chunk_iCCP(self, pos, length): # Compressed profile n bytes (zlib with deflate compression) i = s.find(b"\0") logger.debug("iCCP profil...
diff --git a/Tests/images/unknown_compression_method.png b/Tests/images/unknown_compression_method.png new file mode 100644 Binary files /dev/null and b/Tests/images/unknown_compression_method.png differ diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py --- a/Tests/test_file_png.py +++ b/Tests/test_file_png....
PNG iCCP chunk profile compression type verification seems wrong ### What did you do? Hello, I've been looking around at some PNG decoders and I think I've found a small bug in your iCCP chunk handling. ### What did you expect to happen? I would expect the library to read the iCCP chunk compression version byte c...
2024-02-22T08:58:17Z
10.2
python-pillow/Pillow
7,883
python-pillow__Pillow-7883
[ "7876" ]
794a7d691fcc70ffd3f6dad58737cc1ad2b8da26
diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -1166,6 +1166,9 @@ def _seek(self, frame): self.__next, self.fp.tell(), ) + if self.__next >= 2**63: + msg = ...
diff --git a/Tests/images/seek_too_large.tif b/Tests/images/seek_too_large.tif new file mode 100644 Binary files /dev/null and b/Tests/images/seek_too_large.tif differ diff --git a/Tests/test_file_tiff.py b/Tests/test_file_tiff.py --- a/Tests/test_file_tiff.py +++ b/Tests/test_file_tiff.py @@ -113,6 +113,10 @@ def test...
Uncaught Exception(s) in Pillow Library ### What did you do? We (@DogukanK, @esraercann) discovered a 3 crashes in Python Pillow library because of 'Uncaught Exception' via specially crafted input. ### What did you expect to happen? Exceptions should be handled properly in Pillow. ### What actually happene...
Looking at your second situation, I see it is hitting https://github.com/python-pillow/Pillow/blob/9e3d1a7b05b5c961eb1daaae4e5ed62feb6d5507/src/decode.c#L194-L198 You are trying to create an image that is 134,217,792px wide, greater than the limit in that logic of 67,108,856px wide. So that's not an unexpected e...
2024-03-16T02:44:11Z
10.2
python-pillow/Pillow
7,496
python-pillow__Pillow-7496
[ "7495" ]
d05ff5059f2bb9a46c512f8d303e8e3f8cc6939e
diff --git a/src/PIL/JpegImagePlugin.py b/src/PIL/JpegImagePlugin.py --- a/src/PIL/JpegImagePlugin.py +++ b/src/PIL/JpegImagePlugin.py @@ -85,10 +85,12 @@ def APP(self, marker): self.info["dpi"] = jfif_density self.info["jfif_unit"] = jfif_unit self.info["jfif_density"] = jfif...
diff --git a/Tests/images/multiple_exif.jpg b/Tests/images/multiple_exif.jpg new file mode 100644 Binary files /dev/null and b/Tests/images/multiple_exif.jpg differ diff --git a/Tests/test_file_jpeg.py b/Tests/test_file_jpeg.py --- a/Tests/test_file_jpeg.py +++ b/Tests/test_file_jpeg.py @@ -822,6 +822,10 @@ def test_if...
Multi-segment Exif fails to read ### What did you do? Writing code to read ai generated images and tried to get User Comment field from EXIF data contained in an image opened with Image.open. The jpeg image is as far as I can tell not corrupt. ExifTool reads it OK and shows me the comment with a minor warning that "Fi...
2023-10-26T10:52:20Z
10.1
python-pillow/Pillow
7,481
python-pillow__Pillow-7481
[ "7479" ]
a10dec01b5a3f63c43f7095dbc7aec5658aad251
diff --git a/src/PIL/BmpImagePlugin.py b/src/PIL/BmpImagePlugin.py --- a/src/PIL/BmpImagePlugin.py +++ b/src/PIL/BmpImagePlugin.py @@ -230,21 +230,21 @@ def _bitmap(self, header=0, offset=0): else: padding = file_info["palette_padding"] palette = read(padding * file_info["...
diff --git a/Tests/images/apng/mode_greyscale.png b/Tests/images/apng/mode_grayscale.png similarity index 100% rename from Tests/images/apng/mode_greyscale.png rename to Tests/images/apng/mode_grayscale.png diff --git a/Tests/images/apng/mode_greyscale_alpha.png b/Tests/images/apng/mode_grayscale_alpha.png similarity i...
Mix use of grayscale/greyscale in document and code <!-- Thank you for reporting an issue. Follow these guidelines to ensure your issue is handled properly. If you have a ... 1. General question: consider asking the question on Stack Overflow with the python-imaging-library tag: * https://stackov...
2023-10-19T08:19:08Z
10.1
python-pillow/Pillow
7,383
python-pillow__Pillow-7383
[ "7381" ]
52c6d686135e13df23f05cfe34d393b9d6e981f6
diff --git a/src/PIL/ImageOps.py b/src/PIL/ImageOps.py --- a/src/PIL/ImageOps.py +++ b/src/PIL/ImageOps.py @@ -588,6 +588,7 @@ def exif_transpose(image, *, in_place=False): with the transposition applied. If there is no transposition, a copy of the image will be returned. """ + image.load() ...
diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py --- a/Tests/test_file_libtiff.py +++ b/Tests/test_file_libtiff.py @@ -8,7 +8,7 @@ import pytest -from PIL import Image, ImageFilter, TiffImagePlugin, TiffTags, features +from PIL import Image, ImageFilter, ImageOps, TiffImagePlugin, TiffTags, fea...
ImageOps.exif_transpose not expected behaviour for TIFF images ### What did you do? I have a simple tiff image 150x100px rotated 90 degrees according to exif tag: [sample-out.zip](https://github.com/python-pillow/Pillow/files/12549680/sample-out.zip) ```bash exiftool -n sample-out.tif ... Image Width ...
I've created PR #7383 to resolve this.
2023-09-07T22:49:54Z
10
python-pillow/Pillow
7,420
python-pillow__Pillow-7420
[ "7384" ]
b723e9e62e4706a85f7e44cb42b3d838dae5e546
diff --git a/src/PIL/Image.py b/src/PIL/Image.py --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -915,7 +915,7 @@ def convert( self.load() - has_transparency = self.info.get("transparency") is not None + has_transparency = "transparency" in self.info if not mode and self.mode == "P"...
diff --git a/Tests/test_file_webp.py b/Tests/test_file_webp.py --- a/Tests/test_file_webp.py +++ b/Tests/test_file_webp.py @@ -234,3 +234,13 @@ def test_duration(self, tmp_path): with Image.open(out_webp) as reloaded: assert reloaded.info["duration"] == 1000 + + def test_roundtrip_rgba_palett...
Method to test if image has transparency/alpha [**2023/09/11 edit**] adding a tl;dr: 1. Online sources do not agree on a single method to check for either transparency (actual transparent pixels) or the presence of an alpha channel (whether or not it is opaque), and for all the examples I've found, it's easy to craft ...
A side comment that I'm not sure how to phrase - you mention two StackOverflow posts, a 2016 StackOverflow post referencing a StackOverflow post from 2009. If the problem is that old, I have to imagine the awkward solutions are also well-ingrained in the behaviour of users by now, and that whatever happens here, posts ...
2023-09-25T10:36:10Z
10
python-pillow/Pillow
7,412
python-pillow__Pillow-7412
[ "7411" ]
4ecf1df4ea63457040f63adaeea35996913b6ac1
diff --git a/src/PIL/ImageOps.py b/src/PIL/ImageOps.py --- a/src/PIL/ImageOps.py +++ b/src/PIL/ImageOps.py @@ -242,7 +242,7 @@ def contain(image, size, method=Image.Resampling.BICUBIC): Returns a resized version of the image, set to the maximum width and height within the requested size, while maintaining the...
diff --git a/Tests/test_imageops.py b/Tests/test_imageops.py --- a/Tests/test_imageops.py +++ b/Tests/test_imageops.py @@ -39,6 +39,9 @@ def test_sanity(): ImageOps.contain(hopper("L"), (128, 128)) ImageOps.contain(hopper("RGB"), (128, 128)) + ImageOps.cover(hopper("L"), (128, 128)) + ImageOps.cover(h...
Function to downscale to minimum size <!-- Thank you for reporting an issue. Follow these guidelines to ensure your issue is handled properly. If you have a ... 1. General question: consider asking the question on Stack Overflow with the python-imaging-library tag: * https://stackoverflow.com/que...
I think that `ImageOps` is a better home for this than `Image`, since we have similar methods there already. I've created PR #7412 to add the new function.
2023-09-21T01:48:54Z
10
python-pillow/Pillow
7,302
python-pillow__Pillow-7302
[ "7301" ]
3c5324b07c2ed98bc0ec94bd5c6a30f9c66e42fb
diff --git a/src/PIL/PngImagePlugin.py b/src/PIL/PngImagePlugin.py --- a/src/PIL/PngImagePlugin.py +++ b/src/PIL/PngImagePlugin.py @@ -1042,6 +1042,7 @@ def getxmp(self): "LA": ("LA", b"\x08\x04"), "I": ("I;16B", b"\x10\x00"), "I;16": ("I;16B", b"\x10\x00"), + "I;16B": ("I;16B", b"\x10\x00"), "P;...
diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -92,11 +92,11 @@ def test_sanity(self, tmp_path): assert im.format == "PNG" assert im.get_format_mimetype() == "image/png" - for mode in ["1", "L", "P", "RGB", "I"...
Enable writing I;16B images as PNG While investigating an ImageIO issue concerning behavior on big-endian architectures I've noticed that pillow's PNG plugin currently doesn't allow writing 16-bit big-endian images to PNG. `I;16` is already supported, so I was wondering if it would be possible to add `I;16B` as well. ...
2023-07-24T07:22:13Z
10
python-pillow/Pillow
7,274
python-pillow__Pillow-7274
[ "7324" ]
7b17f9bbb4ac7e79c855efcc2d57dd89e8d8ced8
diff --git a/src/PIL/Image.py b/src/PIL/Image.py --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -1385,7 +1385,7 @@ def getextrema(self): def _getxmp(self, xmp_tags): def get_name(tag): - return tag.split("}")[1] + return re.sub("^{[^}]+}", "", tag) def get_value(elemen...
diff --git a/Tests/images/xmp_no_prefix.jpg b/Tests/images/xmp_no_prefix.jpg new file mode 100644 Binary files /dev/null and b/Tests/images/xmp_no_prefix.jpg differ diff --git a/Tests/images/xmp_padded.jpg b/Tests/images/xmp_padded.jpg new file mode 100644 Binary files /dev/null and b/Tests/images/xmp_padded.jpg differ...
Inconsistent XMP data retrieval: Failure with specific JPEG files ### What did you do? I'm loading a .jpg image using Pillow in an attempt to extract the XMP metadata: ```python from PIL import Image image = Image.open("lib/filename_example_1.jpg") raw_xmp_info = image.getxmp() ``` ### What did you expect t...
2023-07-10T12:16:36Z
10
python-pillow/Pillow
7,151
python-pillow__Pillow-7151
[ "7149" ]
2a274a476088c610451370b9b78e7c63b7b31da3
diff --git a/src/PIL/ImageDraw.py b/src/PIL/ImageDraw.py --- a/src/PIL/ImageDraw.py +++ b/src/PIL/ImageDraw.py @@ -314,11 +314,11 @@ def rounded_rectangle( full_x, full_y = False, False if all(corners): - full_x = d >= x1 - x0 + full_x = d >= x1 - x0 - 1 if full_x:...
diff --git a/Tests/images/imagedraw_rounded_rectangle_x_odd.png b/Tests/images/imagedraw_rounded_rectangle_x_odd.png new file mode 100644 Binary files /dev/null and b/Tests/images/imagedraw_rounded_rectangle_x_odd.png differ diff --git a/Tests/images/imagedraw_rounded_rectangle_y_odd.png b/Tests/images/imagedraw_rounde...
rounded_rectangle raises an "y1 should be > y0" even when coordinates are correctly ordered ### What did you do? I recently updated one of my programs from 9.4 to 9.5 and got this new ValueError when drawing rounded rectangles on an image. After some trials and error, I think the bug only happens when the rectang...
2023-05-10T03:43:29Z
9.5
python-pillow/Pillow
7,078
python-pillow__Pillow-7078
[ "7077" ]
b0c76535022b795f2c31d725131c54e8e10d1ff7
diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -1892,6 +1892,10 @@ class AppendingTiffWriter: 8, # srational 4, # float 8, # double + 4, # ifd + 2, # unicode + 4, # complex + ...
diff --git a/Tests/test_file_tiff.py b/Tests/test_file_tiff.py --- a/Tests/test_file_tiff.py +++ b/Tests/test_file_tiff.py @@ -96,10 +96,17 @@ def test_mac_tiff(self): assert_image_similar_tofile(im, "Tests/images/pil136.png", 1) - def test_bigtiff(self): + def test_bigtiff(self, tmp_path): ...
Saving TIFF stack does not support tags with type long8 Title pretty much says it all. I believe the problem is that this list doesn't contain long8: [here](https://github.com/python-pillow/Pillow/blob/4ffbbe194c5a1b8840f809574017ab5f1333695f/src/PIL/TiffImagePlugin.py#L1881) to reproduce ```python import nump...
2023-04-09T23:23:36Z
9.5
python-pillow/Pillow
7,111
python-pillow__Pillow-7111
[ "811" ]
9636a2aaf1c31e46ab6faaef778ca7ed0db0870d
diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -170,6 +170,8 @@ (MM, 0, (1,), 2, (8,), ()): ("L", "L;IR"), (II, 1, (1,), 1, (8,), ()): ("L", "L"), (MM, 1, (1,), 1, (8,), ()): ("L", "L"), + (II, 1, (2,), 1, (8,),...
diff --git a/Tests/images/8bit.s.tif b/Tests/images/8bit.s.tif new file mode 100644 Binary files /dev/null and b/Tests/images/8bit.s.tif differ diff --git a/Tests/test_file_tiff.py b/Tests/test_file_tiff.py --- a/Tests/test_file_tiff.py +++ b/Tests/test_file_tiff.py @@ -198,6 +198,12 @@ def test_save_unsupported_mode(s...
Fails to open OME-TIFF example data files [OME-TIFF](https://www.openmicroscopy.org/site/support/ome-model/ome-tiff/index.html) is a TIFF format that embeds some microscopy-specific metadata as an XML comment embedded in the TIFF header. Sample data is available at https://www.openmicroscopy.org/site/support/ome-model...
I'm not at a computer to test, but just to confirm: does this happen with Pillow (the PIL fork)? Which version of Pillow do you have? Yes, this is with Pillow 2.5.0, Python 3.4. I actually haven't tested this with PIL. The actual problem with that file is that it is specified as a bigendian 8-bit signed integer form...
2023-04-24T04:02:32Z
9.5
python-pillow/Pillow
6,954
python-pillow__Pillow-6954
[ "6953" ]
d48dca3dc46947867e5f28d42ed2eb93f5b2e6ae
diff --git a/src/PIL/ImageDraw.py b/src/PIL/ImageDraw.py --- a/src/PIL/ImageDraw.py +++ b/src/PIL/ImageDraw.py @@ -295,29 +295,37 @@ def rectangle(self, xy, fill=None, outline=None, width=1): if ink is not None and ink != fill and width != 0: self.draw.draw_rectangle(xy, ink, 0, width) - def ...
diff --git a/Tests/images/imagedraw_rounded_rectangle_corners_nnnn.png b/Tests/images/imagedraw_rounded_rectangle_corners_nnnn.png new file mode 100644 Binary files /dev/null and b/Tests/images/imagedraw_rounded_rectangle_corners_nnnn.png differ diff --git a/Tests/images/imagedraw_rounded_rectangle_corners_nnny.png b/T...
Add a corners parameter for `ImageDraw.rounded_rectangle`? ### What's your feature request? To add an optional bool tuple parameter (`corners=(True, True, True, True)`), or 4 optional bool parameters (`top_left=True, top_right=True, ...`) describing which corners of a rectangle should be rounded for `ImageDraw.rounde...
2023-02-16T09:00:58Z
9.4
python-pillow/Pillow
6,890
python-pillow__Pillow-6890
[ "6882" ]
145b80be56e23b9bb464ea8d1b2dd28b71f5bd81
diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -722,6 +722,8 @@ def load_byte(self, data, legacy_api=True): @_register_writer(1) # Basic type, except for the legacy API. def write_byte(self, data): + if isinst...
diff --git a/Tests/test_file_tiff_metadata.py b/Tests/test_file_tiff_metadata.py --- a/Tests/test_file_tiff_metadata.py +++ b/Tests/test_file_tiff_metadata.py @@ -202,14 +202,15 @@ def test_writing_other_types_to_ascii(value, expected, tmp_path): assert reloaded.tag_v2[271] == expected -def test_writing_in...
Bug: TypeError exif_transpose() / exif.tobytes() Doing `PIL.ImageOps.exif_transpose(im)` for a .jpg I get this error: ```pytb File "C:\Python38\lib\site-packages\PIL\ImageOps.py", line 602, in exif_transpose transposed_image.info["exif"] = transposed_exif.tobytes() File "C:\Python38\lib\site-packages\PIL...
So you've found an image where the [GPSAltitudeRef](https://www.awaresystems.be/imaging/tiff/tifftags/privateifd/gps/gpsaltituderef.html), which should either be a BYTE of 0 (meaning "above sea level") or 1 (meaning "below sea level"), is instead 2.2. Thanks for trying to be helpful in the absence of an image. Do yo...
2023-01-13T10:05:10Z
9.4
python-pillow/Pillow
6,852
python-pillow__Pillow-6852
[ "6844" ]
28b8b6088e1a9ab87b96d5d7edd7fcbc08a43ea7
diff --git a/src/PIL/QoiImagePlugin.py b/src/PIL/QoiImagePlugin.py new file mode 100644 --- /dev/null +++ b/src/PIL/QoiImagePlugin.py @@ -0,0 +1,105 @@ +# +# The Python Imaging Library. +# +# QOI support for PIL +# +# See the README file for information on usage and redistribution. +# + +import os + +from . import Imag...
diff --git a/Tests/images/hopper.qoi b/Tests/images/hopper.qoi new file mode 100644 Binary files /dev/null and b/Tests/images/hopper.qoi differ diff --git a/Tests/images/pil123rgba.qoi b/Tests/images/pil123rgba.qoi new file mode 100644 Binary files /dev/null and b/Tests/images/pil123rgba.qoi differ diff --git a/Tests/t...
QOI support ### What did you do? Tried to open a QOI image ( https://qoiformat.org/ ) with Pillow (`Image.open("picture.qoi")`) The picture is in this zip file (a 2-seconds stick-man) : [picture.zip](https://github.com/python-pillow/Pillow/files/10327604/picture.zip) ### What did you expect to happen? I wou...
I would be happy to contribute to Pillow by implementing QOI support btw (if in scope of pillow) Thanks for the test image, that was a helpful reference point. I've created PR #6852 to add support for reading QOI images. Oh thanks, just had a look and this seems like a very clean implementation
2023-01-02T08:23:32Z
9.4
python-pillow/Pillow
6,830
python-pillow__Pillow-6830
[ "6537" ]
907d59753bdd66460f0bc73e6022352f5ff14591
diff --git a/src/PIL/Image.py b/src/PIL/Image.py --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -65,21 +65,16 @@ def __getattr__(name): if name in categories: deprecate("Image categories", 10, "is_animated", plural=True) return categories[name] - elif name in ("NEAREST", "NONE"): - de...
diff --git a/Tests/test_image.py b/Tests/test_image.py --- a/Tests/test_image.py +++ b/Tests/test_image.py @@ -921,12 +921,7 @@ def test_categories_deprecation(self): with pytest.warns(DeprecationWarning): assert Image.CONTAINER == 2 - def test_constants_deprecation(self): - with pytes...
API changes for Resampling modes With Pillow 9.2.0, I get the following deprecation notice: ``` DeprecationWarning: BILINEAR is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.BILINEAR instead. ``` Is it really necessary to introduce this breaking API change? Can the old names not be ke...
To provide context, the deprecations being discussed were added in #5954. The intention was not to make an arbitrary change, but to make use of a newish Python language feature, enums. https://github.com/python-pillow/Pillow/pull/5954#issuecomment-1009970094 > Do we keep the old constants "forever"? > > Or do we ...
2022-12-27T22:45:31Z
9.3
python-pillow/Pillow
6,819
python-pillow__Pillow-6819
[ "6804" ]
edcfe09f12d6113aaca3a4b3f9bad343c0ddbdb9
diff --git a/src/PIL/PngImagePlugin.py b/src/PIL/PngImagePlugin.py --- a/src/PIL/PngImagePlugin.py +++ b/src/PIL/PngImagePlugin.py @@ -1383,7 +1383,7 @@ def _save(im, fp, filename, chunk=putchunk, save_all=False): chunks.remove(cid) chunk(fp, cid, data) - exif = im.encoderinfo.get...
diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -706,10 +706,18 @@ def test_exif(self): assert exif[274] == 3 def test_exif_save(self, tmp_path): + # Test exif is not saved from info + test_file = str(tmp_path / "tem...
Exif information not saved in JPEG Plugin unless explicitly added in save call <!-- Thank you for reporting an issue. Follow these guidelines to ensure your issue is handled properly. If you have a ... 1. General question: consider asking the question on Stack Overflow with the python-imaging-library ta...
2022-12-23T01:16:13Z
9.3
python-pillow/Pillow
6,783
python-pillow__Pillow-6783
[ "6751" ]
f0b494ede583d9080548cc6d589bb376053ca93b
diff --git a/src/PIL/ImageGrab.py b/src/PIL/ImageGrab.py --- a/src/PIL/ImageGrab.py +++ b/src/PIL/ImageGrab.py @@ -132,4 +132,18 @@ def grabclipboard(): return BmpImagePlugin.DibImageFile(data) return None else: - raise NotImplementedError("ImageGrab.grabclipboard() is macOS and Wi...
diff --git a/Tests/test_imagegrab.py b/Tests/test_imagegrab.py --- a/Tests/test_imagegrab.py +++ b/Tests/test_imagegrab.py @@ -64,9 +64,13 @@ def test_grabclipboard(self): ) p.communicate() else: - with pytest.raises(NotImplementedError) as e: - ImageGrab.gra...
Support ImageGrab from clipboard on Linux via xclip and wl-clipboard Currently, `grabclipboard` raises `NotImplementedError` on Linux. But I think we can use xclip or wl-clipboard if they are installed. A subprocess call saving the image to a temporary file should be enough. ```sh xclip -selection clipboard -t imag...
Considering that we support [`gnome-screenshot` in `ImageGrab.grab`](https://github.com/python-pillow/Pillow/blob/0ec32a30120cb22b533fd8563749d44bd5d3f78f/src/PIL/ImageGrab.py#L64-L75), this seems reasonable. I experimented with this, but found when I copied an image, `xclip` didn't work. https://user-images.githu...
2022-12-07T10:30:11Z
9.3
python-pillow/Pillow
6,647
python-pillow__Pillow-6647
[ "6643" ]
243402e78e2bf2b7af478c6d891816e372b5c3f9
diff --git a/src/PIL/Image.py b/src/PIL/Image.py --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -1027,6 +1027,19 @@ def convert_transparency(m, v): warnings.warn("Couldn't allocate palette entry for transparency") return new + if "LAB" in (self.mode, mode): + othe...
diff --git a/Tests/test_image_convert.py b/Tests/test_image_convert.py --- a/Tests/test_image_convert.py +++ b/Tests/test_image_convert.py @@ -242,6 +242,17 @@ def test_p2pa_palette(): assert im_pa.getpalette() == im.getpalette() +@pytest.mark.parametrize("mode", ("RGB", "RGBA", "RGBX")) +def test_rgb_lab(mode...
convert("LAB") fails for RGB ### What did you do? Called PIL.Image.Image.convert(mode='LAB') for an RGB image ```python img = PIL.Image.open('filename.png').convert(mode='LAB') ``` ### What did you expect to happen? Conversion of data to LAB colourspace. ### What actually happened? ValueError: conversio...
2022-10-07T11:37:10Z
9.2
python-pillow/Pillow
6,582
python-pillow__Pillow-6582
[ "6580" ]
1d1a22bde37baaf162f4dd26e7b94cd96d3116a2
diff --git a/src/PIL/WebPImagePlugin.py b/src/PIL/WebPImagePlugin.py --- a/src/PIL/WebPImagePlugin.py +++ b/src/PIL/WebPImagePlugin.py @@ -311,9 +311,11 @@ def _save(im, fp, filename): lossless = im.encoderinfo.get("lossless", False) quality = im.encoderinfo.get("quality", 80) icc_profile = im.encoderinf...
diff --git a/Tests/test_file_webp_metadata.py b/Tests/test_file_webp_metadata.py --- a/Tests/test_file_webp_metadata.py +++ b/Tests/test_file_webp_metadata.py @@ -55,9 +55,7 @@ def test_write_exif_metadata(): test_buffer.seek(0) with Image.open(test_buffer) as webp_image: webp_exif = webp_image.info....
EXIF prefix saved in WebP ### What did you do? I saved 2 copies of a webp file, one with exif=exif_bytes as shown, one without, then added the exif data by piexif.insert ### What did you expect to happen? exif data to be the same ### What actually happened? winmerge binary comparison reveals "Exif" is qu...
2022-09-15T11:46:15Z
9.2
python-pillow/Pillow
6,517
python-pillow__Pillow-6517
[ "6515" ]
964e0aa0790a7d3d9dadb03b3045de6c7e124a6e
diff --git a/src/PIL/ImageDraw.py b/src/PIL/ImageDraw.py --- a/src/PIL/ImageDraw.py +++ b/src/PIL/ImageDraw.py @@ -482,8 +482,8 @@ def draw_text(ink, stroke_width=0, stroke_offset=None): # extract mask and set text alpha color, mask = mask, mask.getband(3) color.fillba...
diff --git a/Tests/images/text_float_coord.png b/Tests/images/text_float_coord.png new file mode 100644 Binary files /dev/null and b/Tests/images/text_float_coord.png differ diff --git a/Tests/images/text_float_coord_1_alt.png b/Tests/images/text_float_coord_1_alt.png new file mode 100644 Binary files /dev/null and b/T...
Can't use "align=center" together with "embedded_color=True" ### What did you do? ```python textwrapped = "Hello, world! 👋 Here are some emojis: 🎨 🌊 😎" font = ImageFont.truetype(THIS_FOLDER+"/fonts/seguiemj.ttf", font_size) //[merged font](https://github.com/thedemons/merge_color_emoji_font) d.text((int(qx),int...
2022-08-22T02:43:44Z
9.2
python-pillow/Pillow
6,500
python-pillow__Pillow-6500
[ "6572" ]
92b0f2c919897713bde2860a5fd13e3ca333c6e8
diff --git a/src/PIL/BmpImagePlugin.py b/src/PIL/BmpImagePlugin.py --- a/src/PIL/BmpImagePlugin.py +++ b/src/PIL/BmpImagePlugin.py @@ -375,6 +375,16 @@ def _save(im, fp, filename, bitmap_header=True): header = 40 # or 64 for OS/2 version 2 image = stride * im.size[1] + if im.mode == "1": + palett...
diff --git a/Tests/test_file_bmp.py b/Tests/test_file_bmp.py --- a/Tests/test_file_bmp.py +++ b/Tests/test_file_bmp.py @@ -51,6 +51,18 @@ def test_save_to_bytes(): assert reloaded.format == "BMP" +def test_small_palette(tmp_path): + im = Image.new("P", (1, 1)) + colors = [0, 0, 0, 125, 125, 125, 255,...
Invalid 8-bit BMP files written when not all palette colours are used ### What did you do? I loaded an image (BMP or PNG) in 8-bit format. (i.e. with a palette of up to 256 colours) The image did use a palette with _less than_ 256 colours. Then I edited the image and saved it again, as 8-bit BMP. EDIT: This m...
2022-08-13T09:53:12Z
9.2
python-pillow/Pillow
6,481
python-pillow__Pillow-6481
[ "6387" ]
1b5abea0431b6ea2f111a5f72a8f25a1af397490
diff --git a/src/PIL/PsdImagePlugin.py b/src/PIL/PsdImagePlugin.py --- a/src/PIL/PsdImagePlugin.py +++ b/src/PIL/PsdImagePlugin.py @@ -75,6 +75,9 @@ def _open(self): if channels > psd_channels: raise OSError("not enough channels") + if mode == "RGB" and psd_channels == 4: + mod...
diff --git a/Tests/images/rgba.psd b/Tests/images/rgba.psd new file mode 100644 Binary files /dev/null and b/Tests/images/rgba.psd differ diff --git a/Tests/test_file_psd.py b/Tests/test_file_psd.py --- a/Tests/test_file_psd.py +++ b/Tests/test_file_psd.py @@ -4,7 +4,7 @@ from PIL import Image, PsdImagePlugin -fro...
PSD incorrectly loaded ### What did you do? I opened the TIFF in Pillow and converted it to JPG. ### What did you expect to happen? The JPG image to look the same as the original TIFF. ### What actually happened? The converted JPG looks malformed and has messed up colors. ### What are your OS, Python and Pillow v...
Here is the right place to report it - taking a look, your file is actually not a TIFF, but a Photoshop file. The fact that we're not loading it correctly has nothing to do with those other libraries. @radarhere My bad, I should have checked the mimetype...
2022-08-05T13:43:28Z
9.2
python-pillow/Pillow
6,431
python-pillow__Pillow-6431
[ "6430" ]
4db2ed3a6f330efcb66c9b6f36cc668a913d371c
diff --git a/src/PIL/PngImagePlugin.py b/src/PIL/PngImagePlugin.py --- a/src/PIL/PngImagePlugin.py +++ b/src/PIL/PngImagePlugin.py @@ -509,6 +509,10 @@ def chunk_sRGB(self, pos, length): # 3 absolute colorimetric s = ImageFile._safe_read(self.fp, length) + if length < 1: + if Image...
diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -635,7 +635,9 @@ def test_padded_idat(self): assert_image_equal_tofile(im, "Tests/images/bw_gradient.png") - @pytest.mark.parametrize("cid", (b"IHDR", b"pHYs", b"acTL", b"fcTL", ...
[PNG] IndexError is raised when the sRGB chunk is broken ### What did you do? ```python3 from PIL import Image import io # assumes the current directory is the root of this repository. with open('Tests/images/imagedraw_polygon_1px_high.png', 'rb') as f: data = bytearray(f.read()) # insert the sRGB ...
2022-07-11T10:05:05Z
9.2
python-pillow/Pillow
6,381
python-pillow__Pillow-6381
[ "5816" ]
11918eac0628ec8ac0812670d9838361ead2d6a4
diff --git a/src/PIL/ImageDraw.py b/src/PIL/ImageDraw.py --- a/src/PIL/ImageDraw.py +++ b/src/PIL/ImageDraw.py @@ -32,8 +32,10 @@ import math import numbers +import warnings from . import Image, ImageColor +from ._deprecate import deprecate """ A simple 2D drawing interface for PIL images. @@ -372,6 +374,19 ...
diff --git a/Tests/images/rectangle_surrounding_text.png b/Tests/images/rectangle_surrounding_text.png Binary files a/Tests/images/rectangle_surrounding_text.png and b/Tests/images/rectangle_surrounding_text.png differ diff --git a/Tests/oss-fuzz/fuzzers.py b/Tests/oss-fuzz/fuzzers.py --- a/Tests/oss-fuzz/fuzzers.py ++...
getsize_multiline doesn't take into account characters that extend below the baseline ### What did you do? I'm using `getsize_multiline` to compute the size of a text label that I render to an image. The image is exactly the size of the text label. I noticed that my text labels where cropped; specifically, when t...
Of course, _immediately_ after opening that issue, I find a very promising method: `getmetrics()`, that precisely returns the ascent and the descend of a font. It looks like all I need to do is add the "descent" at the bottom of the label. I'll check that and if it works, I'll see if I can propose a patch for `getsize_...
2022-06-20T04:29:21Z
9.1
python-pillow/Pillow
6,265
python-pillow__Pillow-6265
[ "6259" ]
9d988dab6aeb4346960a24b2ec423d8f16f8cddc
diff --git a/src/PIL/GifImagePlugin.py b/src/PIL/GifImagePlugin.py --- a/src/PIL/GifImagePlugin.py +++ b/src/PIL/GifImagePlugin.py @@ -561,7 +561,7 @@ def _write_single_frame(im, fp, palette): def _write_multiple_frames(im, fp, palette): - duration = im.encoderinfo.get("duration", im.info.get("duration")) + ...
diff --git a/Tests/test_file_gif.py b/Tests/test_file_gif.py --- a/Tests/test_file_gif.py +++ b/Tests/test_file_gif.py @@ -3,7 +3,7 @@ import pytest -from PIL import GifImagePlugin, Image, ImageDraw, ImagePalette, features +from PIL import GifImagePlugin, Image, ImageDraw, ImagePalette, ImageSequence, features ...
GIF durations should be preserved from frame info <!-- Thank you for reporting an issue. Follow these guidelines to ensure your issue is handled properly. If you have a ... 1. General question: consider asking the question on Stack Overflow with the python-imaging-library tag: * https://stackover...
2022-05-03T10:15:17Z
9.1
python-pillow/Pillow
6,234
python-pillow__Pillow-6234
[ "6209" ]
de1ba373e10065e7bffe4bdb18a4aec40ef306a2
diff --git a/src/PIL/ImageFont.py b/src/PIL/ImageFont.py --- a/src/PIL/ImageFont.py +++ b/src/PIL/ImageFont.py @@ -711,8 +711,13 @@ def font_variant( :return: A FreeTypeFont object. """ + if font is None: + try: + font = BytesIO(self.font_bytes) + except A...
diff --git a/Tests/test_imagefont.py b/Tests/test_imagefont.py --- a/Tests/test_imagefont.py +++ b/Tests/test_imagefont.py @@ -65,9 +65,12 @@ def _font_as_bytes(self): return font_bytes def test_font_with_filelike(self): - ImageFont.truetype( + ttf = ImageFont.truetype( self._...
Using font_variant on a font whose path is defined by BytesIO fails ### What did you do? Opened a font using ```py font = ImageFont.truetype( BytesIO(pkgutil.get_data(__package__, path)), size ) ``` then tried to edit the font using font_variant. ```py # doesn't work, it raises "OSError: cannot open ...
https://pillow.readthedocs.io/en/stable/reference/ImageFont.html#PIL.ImageFont.truetype > Load a TrueType or OpenType font from a file or file-like object, and create a font object. This function loads a font object from the given file or file-like object, and creates a font object for a font of the given size. Whi...
2022-04-21T21:41:19Z
9.1
python-pillow/Pillow
6,242
python-pillow__Pillow-6242
[ "6240" ]
7d5162cb371a7199a9a141a70789aa95d41daeb5
diff --git a/src/PIL/PpmImagePlugin.py b/src/PIL/PpmImagePlugin.py --- a/src/PIL/PpmImagePlugin.py +++ b/src/PIL/PpmImagePlugin.py @@ -116,6 +116,10 @@ def _open(self): break elif ix == 2: # token is maxval maxval = token + if not 0 < maxval < 65536: + ...
diff --git a/Tests/test_file_ppm.py b/Tests/test_file_ppm.py --- a/Tests/test_file_ppm.py +++ b/Tests/test_file_ppm.py @@ -145,6 +145,19 @@ def test_truncated_file(tmp_path): im.load() +@pytest.mark.parametrize("maxval", (0, 65536)) +def test_invalid_maxval(maxval, tmp_path): + path = str(tmp_path /...
ZeroDivisionError is raised when the `maxval` of the PPM metadata is 0 <!-- Thank you for reporting an issue. Follow these guidelines to ensure your issue is handled properly. If you have a ... 1. General question: consider asking the question on Stack Overflow with the python-imaging-library tag: ...
http://netpbm.sourceforge.net/doc/ppm.html states that maxval "Must be less than 65536 and more than zero", so yes, I agree it is broken. I've created #6242 to raise a "Invalid maxval" ValueError. Thank you. LGTM!
2022-04-25T00:19:54Z
9.1
python-pillow/Pillow
6,188
python-pillow__Pillow-6188
[ "6187" ]
4996f84fb3fb80dc1d4e8288ff45ef11f8b162cc
diff --git a/src/PIL/Image.py b/src/PIL/Image.py --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -1720,6 +1720,8 @@ def point(self, data): # FIXME: _imaging returns a confusing error message for this case raise ValueError("point operation not supported for this mode") + if mode != "F...
diff --git a/Tests/test_image_point.py b/Tests/test_image_point.py --- a/Tests/test_image_point.py +++ b/Tests/test_image_point.py @@ -10,6 +10,7 @@ def test_sanity(): im.point(list(range(256))) im.point(list(range(256)) * 3) im.point(lambda x: x) + im.point(lambda x: x * 1.2) im = im.conve...
'float' object cannot be interpreted as an integer exception when applying point transforms ### What did you do? Following the docs to apply point transforms: https://pillow.readthedocs.io/en/stable/handbook/tutorial.html?highlight=.point(#applying-point-transforms ### What actually happened? The following except...
Thanks. This would be because of https://docs.python.org/3/c-api/long.html#c.PyLong_AsLong > Changed in version 3.10: This function will no longer use `__int__()`. I've created PR #6188 to resolve this.
2022-04-06T22:55:39Z
9.1
python-pillow/Pillow
6,128
python-pillow__Pillow-6128
[ "6115" ]
475b7233d6c6341f750829dbdd5123002bed57b7
diff --git a/src/PIL/GifImagePlugin.py b/src/PIL/GifImagePlugin.py --- a/src/PIL/GifImagePlugin.py +++ b/src/PIL/GifImagePlugin.py @@ -424,7 +424,7 @@ def _close__fp(self): RAWMODE = {"1": "L", "L": "L", "P": "P"} -def _normalize_mode(im, initial_call=False): +def _normalize_mode(im): """ Takes an image ...
diff --git a/Tests/test_file_gif.py b/Tests/test_file_gif.py --- a/Tests/test_file_gif.py +++ b/Tests/test_file_gif.py @@ -842,6 +842,17 @@ def test_rgb_transparency(tmp_path): assert "transparency" not in reloaded.info +def test_rgba_transparency(tmp_path): + out = str(tmp_path / "temp.gif") + + im ...
Broken background on transparent GIFs built from individual frames The background of transparent GIFs constructed from Images seems to not quite see the transparent color correctly. ```py from PIL import Image with Image.open('test.gif') as im: images = [] durations = [] for i in range(im.n_frames): im....
I suspect that setting transparency and background to 255 is the issue. These values are indexes into the color palette but your palette only has 13 entries, not 255. I fed the test input and output .gifs provided by @balt-is-you-and-shift into a small script I wrote, and here is the output: ``` % python3 mk_ani.py ...
2022-03-12T04:19:19Z
9
python-pillow/Pillow
6,124
python-pillow__Pillow-6124
[ "6123" ]
515957b2ac2cd1b85a3008550a99820bf643e9e4
diff --git a/src/PIL/Image.py b/src/PIL/Image.py --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -3478,12 +3478,12 @@ def load(self, data): self._loaded_exif = data self._data.clear() self._ifds.clear() + if data and data.startswith(b"Exif\x00\x00"): + data = data[6:] ...
diff --git a/Tests/test_image.py b/Tests/test_image.py --- a/Tests/test_image.py +++ b/Tests/test_image.py @@ -666,6 +666,19 @@ def act(fp): assert not fp.closed + def test_empty_exif(self): + with Image.open("Tests/images/exif.png") as im: + exif = im.getexif() + assert dic...
Support for a "blank" exif <!-- Thank you for reporting an issue. Follow these guidelines to ensure your issue is handled properly. If you have a ... 1. General question: consider asking the question on Stack Overflow with the python-imaging-library tag: * https://stackoverflow.com/questions/tagg...
2022-03-11T21:27:11Z
9
python-pillow/Pillow
6,101
python-pillow__Pillow-6101
[ "6100" ]
37d28ce5143d0eb7ca9cd59d24d623855072506a
diff --git a/src/PIL/MpoImagePlugin.py b/src/PIL/MpoImagePlugin.py --- a/src/PIL/MpoImagePlugin.py +++ b/src/PIL/MpoImagePlugin.py @@ -46,6 +46,7 @@ def _open(self): self._after_jpeg_open() def _after_jpeg_open(self, mpheader=None): + self._initial_size = self.size self.mpinfo = mpheader...
diff --git a/Tests/test_file_mpo.py b/Tests/test_file_mpo.py --- a/Tests/test_file_mpo.py +++ b/Tests/test_file_mpo.py @@ -85,6 +85,9 @@ def test_frame_size(): im.seek(1) assert im.size == (680, 480) + im.seek(0) + assert im.size == (640, 480) + def test_ignore_frame_size(): # ...
Cannot modify the first frame of a MPO with asymmetric sized frames after seek ### What did you do? Did a seek(1) to the second frame followed by a seek(0) back to the first, and a transpose ### What did you expect to happen? The transpose ### What actually happened? Segmentation fault: 11 ### What are ...
2022-03-01T08:16:25Z
9
python-pillow/Pillow
6,097
python-pillow__Pillow-6097
[ "4513" ]
37d28ce5143d0eb7ca9cd59d24d623855072506a
diff --git a/src/PIL/Image.py b/src/PIL/Image.py --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -49,7 +49,7 @@ # PILLOW_VERSION was removed in Pillow 9.0.0. # Use __version__ instead. from . import ImageMode, TiffTags, UnidentifiedImageError, __version__, _plugins -from ._binary import i32le +from ._binary import ...
diff --git a/Tests/images/hopper_bigtiff.tif b/Tests/images/hopper_bigtiff.tif new file mode 100644 Binary files /dev/null and b/Tests/images/hopper_bigtiff.tif differ diff --git a/Tests/test_file_tiff.py b/Tests/test_file_tiff.py --- a/Tests/test_file_tiff.py +++ b/Tests/test_file_tiff.py @@ -87,6 +87,10 @@ def test_m...
PIL cannot read BigTIFF <!-- Thank you for reporting an issue. Follow these guidelines to ensure your issue is handled properly. If you have a ... 1. General question: consider asking the question on Stack Overflow with the python-imaging-library tag: * https://stackoverflow.com/questions/tagged/...
Could be a [BigTIFF](https://www.awaresystems.be/imaging/tiff/bigtiff.html) file, which is not supported by Pillow. The first 4 bytes in BigTIFF files are `b'II\x2B\x00'` or `b'MM\x00\x2B'` > Could be a [BigTIFF](https://www.awaresystems.be/imaging/tiff/bigtiff.html) file, which is not supported by Pillow. The first 4 ...
2022-02-28T22:05:19Z
9
python-pillow/Pillow
6,086
python-pillow__Pillow-6086
[ "6084" ]
37d28ce5143d0eb7ca9cd59d24d623855072506a
diff --git a/src/PIL/GifImagePlugin.py b/src/PIL/GifImagePlugin.py --- a/src/PIL/GifImagePlugin.py +++ b/src/PIL/GifImagePlugin.py @@ -167,9 +167,15 @@ def _seek(self, frame): if self.__frame == 1: self.pyaccess = None if "transparency" in self.info: - self.mode = "RGBA...
diff --git a/Tests/images/no_palette_with_transparency.gif b/Tests/images/no_palette_with_transparency.gif new file mode 100644 Binary files /dev/null and b/Tests/images/no_palette_with_transparency.gif differ diff --git a/Tests/test_file_gif.py b/Tests/test_file_gif.py --- a/Tests/test_file_gif.py +++ b/Tests/test_fil...
Pillow no longer reads grayscale multi-frame gifs The following breaks in pillow 9.0.1 but works fine if I downgrade to pillow 8.4.0. My guess is that the new loader that converts to RGB/RGBA when seeking doesn't account for the possibility of a grayscale GIF. ```python from PIL import Image import numpy as np ...
I've created PR #6086 to resolve this.
2022-02-22T10:30:31Z
9
python-pillow/Pillow
6,054
python-pillow__Pillow-6054
[ "6027" ]
cac305f8d2db5eca3ce18f8d334a9ff35f9c7fde
diff --git a/src/PIL/Image.py b/src/PIL/Image.py --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -821,12 +821,6 @@ def load(self): if self.im and self.palette and self.palette.dirty: # realize palette mode, arr = self.palette.getdata() - if mode == "RGBA": - ...
diff --git a/Tests/test_image_putpalette.py b/Tests/test_image_putpalette.py --- a/Tests/test_image_putpalette.py +++ b/Tests/test_image_putpalette.py @@ -62,3 +62,16 @@ def test_putpalette_with_alpha_values(): im.putpalette(palette_with_alpha_values, "RGBA") assert_image_equal(im.convert("RGBA"), e...
Palettes with rawmode RGBA;15 don't work ### What did you do? In an attempt to convert a PlayStation TIM image format to a bitmap, I turned to Pillow to handle image processing for me. This proved to be reasonably straightforward, but when operating on 8-bit palettized TIM files, I seem to be unable to preserve tran...
Hi. You're calling `putpalette` with a `rawmode` argument of "RGBA;15". As noted in https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.putpalette > rawmode – The raw mode of the palette. Either “RGB”, “RGBA”, or a mode that can be transformed to “RGB” (e.g. “R”, “BGR;15”, “RGBA;L”). I'v...
2022-02-14T09:41:32Z
9
python-pillow/Pillow
5,891
python-pillow__Pillow-5891
[ "5890" ]
2a3867016978f540b258f7653940cc410a4eb85e
diff --git a/src/PIL/Image.py b/src/PIL/Image.py --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -644,6 +644,22 @@ def __repr__(self): id(self), ) + def _repr_pretty_(self, p, cycle): + """IPython plain text display support""" + + # Same as __repr__ but without unpredicatable i...
diff --git a/Tests/test_image.py b/Tests/test_image.py --- a/Tests/test_image.py +++ b/Tests/test_image.py @@ -88,6 +88,17 @@ def test_sanity(self): # with pytest.raises(MemoryError): # Image.new("L", (1000000, 1000000)) + def test_repr_pretty(self): + class Pretty: + def text...
Changing Jupyter plain text output on every cell run ### What did you do? I'm using Pillow to generate simple images in Jupyter environment: ```python from PIL import Image Image.frombuffer('RGB', (16,16), bytes([100]*(16*16))) ``` It works nicely! ![image](https://user-images.githubusercontent.com/51067...
2021-12-15T20:37:48Z
8.4
python-pillow/Pillow
5,845
python-pillow__Pillow-5845
[ "5590" ]
e1eefe4486401738740a6ad4b3b5998df7a02d5b
diff --git a/src/PIL/IcnsImagePlugin.py b/src/PIL/IcnsImagePlugin.py --- a/src/PIL/IcnsImagePlugin.py +++ b/src/PIL/IcnsImagePlugin.py @@ -337,23 +337,28 @@ def _save(im, fp, filename): entries = [] for type, size in sizes.items(): stream = size_streams[size] - entries.append({"type": type, "s...
diff --git a/Tests/test_file_icns.py b/Tests/test_file_icns.py --- a/Tests/test_file_icns.py +++ b/Tests/test_file_icns.py @@ -1,8 +1,9 @@ import io +import os import pytest -from PIL import IcnsImagePlugin, Image, features +from PIL import IcnsImagePlugin, Image, _binary, features from .helper import assert_i...
App icns modification breaks the icon display on macOS <!-- Thank you for reporting an issue. Follow these guidelines to ensure your issue is handled properly. If you have a ... 1. General question: consider asking the question on Stack Overflow with the python-imaging-library tag: * https://stac...
Using an application on my computer, I'm not able to replicate this. Could you upload the original ICNS file? What version of macOS do you have? @radarhere Sorry about the invalid example, I've rechecked it and it requires drawing prior to saving in order to break the icon (Finder may cache the old icon, so it's easier...
2021-11-20T03:18:00Z
8.4
python-pillow/Pillow
5,839
python-pillow__Pillow-5839
[ "5838" ]
d6e42f330710ddb854ba56eda7a025b4025fab1e
diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -89,7 +89,10 @@ ARTIST = 315 PREDICTOR = 317 COLORMAP = 320 +TILEWIDTH = 322 +TILELENGTH = 323 TILEOFFSETS = 324 +TILEBYTECOUNTS = 325 SUBIFD = 330 EXTRASAMPLES = 338 SAMPLEFO...
diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py --- a/Tests/test_file_libtiff.py +++ b/Tests/test_file_libtiff.py @@ -920,6 +920,23 @@ def test_strip_planar_16bit_RGBa(self): with Image.open("Tests/images/tiff_strip_planar_16bit_RGBa.tiff") as im: assert_image_equal_tofile(im,...
Three TIFF tags cause display issues in GIS software When I run my GeoTIFF though Pillow while trying to preserve the TIFF info I end up with 3 additional TIFF tags in the output (`StripOffsets`, `RowsPerStrip`, `StripByteCounts`). The resulting output GeoTIFF is now displayed incorrectly in the GIS software `ESRI ArcM...
I suspect that you're much more likely to be losing the geo metadata or converting data types than seeing those tags cause an error. I'd recommend checking the metadata with `gdalinfo`. And generally, depending on what you're doing, `gdal` (command line/python) or `rasterio` (better python bindings to gdal) will p...
2021-11-18T11:02:45Z
8.4
python-pillow/Pillow
5,696
python-pillow__Pillow-5696
[ "5695" ]
d50052a75c4d0d17d3d37c24a4558c9e0736f0e8
diff --git a/src/PIL/Image.py b/src/PIL/Image.py --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -1130,7 +1130,9 @@ def quantize(self, colors=256, method=None, kmeans=0, palette=None, dither=1): "only RGB or L mode images can be quantized to a palette" ) im = self.im....
diff --git a/Tests/test_image_quantize.py b/Tests/test_image_quantize.py --- a/Tests/test_image_quantize.py +++ b/Tests/test_image_quantize.py @@ -63,6 +63,7 @@ def test_quantize_no_dither(): converted = image.quantize(dither=0, palette=palette) assert_image(converted, "P", converted.size) + assert conve...
PNG palette quantized save functionality different between 8.1.0 and 8.3.1 ### What did you do? Create a palette, quantize an image using this palette and save it. ### What did you expect to happen? The palette information is stored correctly. I.e. the list of RGB values is the same in the saved image. E.g. [0, 0...
2021-08-30T14:38:21Z
8.3
python-pillow/Pillow
5,756
python-pillow__Pillow-5756
[ "5656" ]
2d7c487cf8fbee80428248138d5632a5da1758f9
diff --git a/src/PIL/GifImagePlugin.py b/src/PIL/GifImagePlugin.py --- a/src/PIL/GifImagePlugin.py +++ b/src/PIL/GifImagePlugin.py @@ -271,11 +271,9 @@ def _seek(self, frame): Image._decompression_bomb_check(dispose_size) # by convention, attempt to use transparency first - ...
diff --git a/Tests/images/dispose_bgnd_transparency.gif b/Tests/images/dispose_bgnd_transparency.gif new file mode 100644 Binary files /dev/null and b/Tests/images/dispose_bgnd_transparency.gif differ diff --git a/Tests/test_file_gif.py b/Tests/test_file_gif.py --- a/Tests/test_file_gif.py +++ b/Tests/test_file_gif.py ...
AnimGIF not transparent The frames of the down below animated GIF are not transparent (first frame works). Testcase: ````python import base64, io import PIL.Image animgif = ''' R0lGODlhJgAgAPdEAAIBAQsKChkGBCUdBy4lByoqKUw5AFlFAltJE2dNAkVFRU1OTlZVVWFiYoIgAIRjAJJxApx1AaJ6AK2MJMGRAM+bANKdANagANmjAOKqBOewC+a5L//MM...
Experimenting, I find that prioritising the global transparency over frame transparency when replacing with background color fixes this. ```diff diff --git a/src/PIL/GifImagePlugin.py b/src/PIL/GifImagePlugin.py index db6944267..128afc428 100644 --- a/src/PIL/GifImagePlugin.py +++ b/src/PIL/GifImagePlugin.py @@...
2021-10-11T22:49:17Z
8.3
python-pillow/Pillow
5,647
python-pillow__Pillow-5647
[ "5643" ]
eee0953bb33a5648c454b4628801034071d4f07d
diff --git a/src/PIL/Image.py b/src/PIL/Image.py --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -2479,6 +2479,8 @@ def getdata(self): raise ValueError("missing method data") im = new(self.mode, size, fillcolor) + if self.mode == "P" and self.palette: + im.palette = self.palet...
diff --git a/Tests/test_image_transform.py b/Tests/test_image_transform.py --- a/Tests/test_image_transform.py +++ b/Tests/test_image_transform.py @@ -32,6 +32,11 @@ def test_info(self): new_im = im.transform((100, 100), transform) assert new_im.info["comment"] == comment + def test_palette(s...
Problem rotating P images ```python from PIL import Image import random img = Image.open('test.png') rate = random.randint(30, 330) img = img.rotate(rate) img.show() img.save('test_rotate.png') ``` ![test](https://user-images.githubusercontent.com/37957822/127455530-f7437db9-b2df-4b89-be5b-5582b67b4eb8.png) ...
The image generated by rotating the picture is a binary image If you're looking for an immediate solution, you can convert it to RGB after opening. ```python from PIL import Image import random img = Image.open('test.png').convert('RGB') rate = random.randint(30, 330) img = img.rotate(rate) img.show() img.s...
2021-07-30T10:14:15Z
8.3
python-pillow/Pillow
5,609
python-pillow__Pillow-5609
[ "5608" ]
83c05aaf8daa930086257eb38b254f06808d13e5
diff --git a/src/PIL/PngImagePlugin.py b/src/PIL/PngImagePlugin.py --- a/src/PIL/PngImagePlugin.py +++ b/src/PIL/PngImagePlugin.py @@ -1117,12 +1117,12 @@ def _write_multiple_frames(im, fp, chunk, rawmode): and prev_disposal == encoderinfo.get("disposal") and prev_blend == enco...
diff --git a/Tests/test_file_apng.py b/Tests/test_file_apng.py --- a/Tests/test_file_apng.py +++ b/Tests/test_file_apng.py @@ -433,7 +433,9 @@ def test_apng_save_duration_loop(tmp_path): # test removal of duplicated frames frame = Image.new("RGBA", (128, 64), (255, 0, 0, 255)) - frame.save(test_file, sav...
type list doesn't define __round__ method <!-- Thank you for reporting an issue. Follow these guidelines to ensure your issue is handled properly. If you have a ... 1. General question: consider asking the question on Stack Overflow with the python-imaging-library tag: * https://stackoverflow.com...
2021-07-13T03:48:36Z
8.3
python-pillow/Pillow
5,572
python-pillow__Pillow-5572
[ "5571" ]
53ce23c74972d43971585a0d2f2e8ce850964fac
diff --git a/src/PIL/Image.py b/src/PIL/Image.py --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -681,7 +681,7 @@ def _repr_png_(self): raise ValueError("Could not save to PNG for display") from e return b.getvalue() - def __array__(self): + def __array__(self, dtype=None): # num...
diff --git a/Tests/test_image_array.py b/Tests/test_image_array.py --- a/Tests/test_image_array.py +++ b/Tests/test_image_array.py @@ -14,6 +14,10 @@ def test(mode): ai = numpy.array(im.convert(mode)) return ai.shape, ai.dtype.str, ai.nbytes + def test_with_dtype(dtype): + ai = numpy.array...
Pillow 8.3 and NumPy Throws exception with Pillow 8.3: `TypeError: __array__() takes 1 positional argument but 2 were given` ````python with PIL.Image.open(filepath) as img: numpy.array( img, dtype=numpy.float32 ) ````
What version of Python are you using? What version of numpy? Same problem here. Python 3.7.4 numpy 1.21.0 workaround: ```python with PIL.Image.open(filepath) as img: numpy.array(img).astype(np.float32) ``` Works with just about anything. The problem is that pillow newly implemented `__array__`, but only wi...
2021-07-01T11:11:56Z
8.3
python-pillow/Pillow
5,557
python-pillow__Pillow-5557
[ "5548" ]
70ef50cf72992ab6c9330412d6f1340c593e2d8f
diff --git a/src/PIL/GifImagePlugin.py b/src/PIL/GifImagePlugin.py --- a/src/PIL/GifImagePlugin.py +++ b/src/PIL/GifImagePlugin.py @@ -269,9 +269,14 @@ def _seek(self, frame): dispose_size = (x1 - x0, y1 - y0) Image._decompression_bomb_check(dispose_size) - self.dispos...
diff --git a/Tests/images/first_frame_transparency.gif b/Tests/images/first_frame_transparency.gif new file mode 100644 Binary files /dev/null and b/Tests/images/first_frame_transparency.gif differ diff --git a/Tests/images/transparent_dispose.gif b/Tests/images/transparent_dispose.gif new file mode 100644 Binary files...
AnimGIF not transparent Loading some anim-GIFs result in opaque background. Example to reproduce: PNG has a black border on the right inside (should be transparent): ````python import base64, io import PIL.Image animgif = 'R0lGODlhJgAgAPdEAAIBAQsKChkGBCUdBy4lByoqKUw5AFlFAltJE2dNAkVFRU1OTlZVVWFiYoIgAIRjAJJxApx1...
The first frame has a `dispose_extent` of (0, 0, 27, 32) - which is not the full size of the image. #3434 would fix this image, by setting the uncovered parts of the first frame to transparency. I just don't understand why this is the solution on a theoretical level, as the [spec](https://www.w3.org/Graphics/GIF/...
2021-06-25T12:38:46Z
8.2
python-pillow/Pillow
5,554
python-pillow__Pillow-5554
[ "5553" ]
52856bceb71f3e9f774f9593c735094fe8ade092
diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -465,7 +465,7 @@ class ImageFileDirectory_v2(MutableMapping): """ - def __init__(self, ifh=b"II\052\0\0\0\0\0", prefix=None): + def __init__(self, ifh=b"II\052\0\0\0\0...
diff --git a/Tests/test_file_tiff_metadata.py b/Tests/test_file_tiff_metadata.py --- a/Tests/test_file_tiff_metadata.py +++ b/Tests/test_file_tiff_metadata.py @@ -378,6 +378,20 @@ def test_too_many_entries(): pytest.warns(UserWarning, lambda: ifd[277]) +def test_tag_group_data(): + base_ifd = TiffImagePlugi...
EXIF tag `InteropVersion` has wrong type ## What did you do? Open an image with Pillow and save it with its exif data. ## What did you expect to happen? The content of the exif field `InteropVersion` must be the same in both files. ## What actually happened? The type of `InteropVersion` field value is s...
A workaround, from a user perspective, is to save file to a buffer, then seek and change the type of the IFD tag, and save the file.
2021-06-24T10:26:31Z
8.2
python-pillow/Pillow
5,549
python-pillow__Pillow-5549
[ "4830" ]
384a4bf01ec8d631dcde2c3246bd08e37fa1b7cd
diff --git a/src/PIL/Image.py b/src/PIL/Image.py --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -830,7 +830,7 @@ def load(self): arr = bytes( value for (index, value) in enumerate(arr) if index % 4 != 3 ) - self.im.putpalette(mode, arr) + pa...
diff --git a/Tests/test_file_tga.py b/Tests/test_file_tga.py --- a/Tests/test_file_tga.py +++ b/Tests/test_file_tga.py @@ -65,10 +65,15 @@ def roundtrip(original_im): roundtrip(original_im) -def test_palette_depth_16(): +def test_palette_depth_16(tmp_path): with Image.open("Tests/image...
PIL doesn't seem to handle the color map correctly in some color indexed TGA files Please see my question in [Stack Overflow](https://stackoverflow.com/questions/63151906/is-there-any-other-attribute-that-affetcts-how-colors-are-displayed-on-an-indexe) where I explain everything in greater detail and more importantly, ...
Do you have images that demonstrate this problem, that are able to be added to the test suite under the Pillow license? I have recreated those images which you can add to the test suite. [TGA_samples.zip](https://github.com/python-pillow/Pillow/files/5013124/TGA_samples.zip) Thank you. I've created #5396 to fix a...
2021-06-18T23:23:56Z
8.2
python-pillow/Pillow
5,437
python-pillow__Pillow-5437
[ "5436" ]
ef9a8e5f7f7cbc28309dd5431e626ebd36ce5c9f
diff --git a/src/PIL/EpsImagePlugin.py b/src/PIL/EpsImagePlugin.py --- a/src/PIL/EpsImagePlugin.py +++ b/src/PIL/EpsImagePlugin.py @@ -354,56 +354,46 @@ def _save(im, fp, filename, eps=1): # # determine PostScript image mode if im.mode == "L": - operator = (8, 1, "image") + operator = (8, 1...
diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -1,4 +1,5 @@ import re +import sys import zlib from io import BytesIO @@ -10,6 +11,7 @@ PillowLeakTestCase, assert_image, assert_image_equal, + assert_image_equal_tofile, ...
Can't save PNG to sys.stdout <!-- Thank you for reporting an issue. Follow these guidelines to ensure your issue is handled properly. If you have a ... 1. General question: consider asking the question on Stack Overflow with the python-imaging-library tag: * https://stackoverflow.com/questions/ta...
Hi. You're free to say that Pillow should be able to work with your code, and that you'd like it to be fixed in the next Pillow release - but if you'd like an immediate solution, I'd suggest changing `sys.stdout` to `sys.stdout.buffer`. ```python import sys from PIL import Image, ImageDraw # list of dots, in th...
2021-04-25T04:40:30Z
8.2
python-pillow/Pillow
5,425
python-pillow__Pillow-5425
[ "2278" ]
ab8955b48e84b18c578d165e7d10868794311ce2
diff --git a/src/PIL/TiffTags.py b/src/PIL/TiffTags.py --- a/src/PIL/TiffTags.py +++ b/src/PIL/TiffTags.py @@ -178,7 +178,7 @@ def lookup(tag): 532: ("ReferenceBlackWhite", RATIONAL, 6), 700: ("XMP", BYTE, 0), 33432: ("Copyright", ASCII, 1), - 33723: ("IptcNaaInfo", UNDEFINED, 0), + 33723: ("IptcNa...
diff --git a/Tests/test_file_tiff_metadata.py b/Tests/test_file_tiff_metadata.py --- a/Tests/test_file_tiff_metadata.py +++ b/Tests/test_file_tiff_metadata.py @@ -179,6 +179,12 @@ def test_no_duplicate_50741_tag(): assert TAG_IDS["BestQualityScale"] == 50780 +def test_iptc(tmp_path): + out = str(tmp_path / ...
AttributeError: 'tuple' object has no attribute 'ljust' when trying to save image ### What did you do? Ran a snippet of code, see below. ### What did you expect to happen? The script to complete without error. ### What actually happened? Stack trace, see below. ### What versions of Pillow and Python a...
Minimal repro is: ```python from PIL import Image im = Image.open('phototest.tif') im.save('tmp.tif') ``` It's 3.x only, this works in 2.7. It succeeded before the great metadata rewrite of Pillow 3.0. Error is in a metadata entry: ``` Tag 34377, Type: 1, Value: ("8BIM\x03\xed\x00\x00\x00\x00\x00\x10\x...
2021-04-21T12:56:12Z
8.2
python-pillow/Pillow
5,417
python-pillow__Pillow-5417
[ "5415" ]
676f4dbefb22c349c2f78f4f6aabf26e00d5efc2
diff --git a/src/PIL/ImageOps.py b/src/PIL/ImageOps.py --- a/src/PIL/ImageOps.py +++ b/src/PIL/ImageOps.py @@ -236,15 +236,43 @@ def colorize(image, black, white, mid=None, blackpoint=0, whitepoint=255, midpoi return _lut(image, red + green + blue) +def contain(image, size, method=Image.BICUBIC): + """ + ...
diff --git a/Tests/test_imageops.py b/Tests/test_imageops.py --- a/Tests/test_imageops.py +++ b/Tests/test_imageops.py @@ -37,6 +37,9 @@ def test_sanity(): ImageOps.pad(hopper("L"), (128, 128)) ImageOps.pad(hopper("RGB"), (128, 128)) + ImageOps.contain(hopper("L"), (128, 128)) + ImageOps.contain(hoppe...
Function similar to pad but returns resized image without padding I'd sure like a function that looks like ImageOps.pad https://pillow.readthedocs.io/en/stable/_modules/PIL/ImageOps.html#pad but just returns the image after resizing without adding the padding. What would be a good name for such a function? Where...
2021-04-19T10:33:37Z
8.2
python-pillow/Pillow
5,330
python-pillow__Pillow-5330
[ "2202" ]
7235cf313517e03abd23f9de60e23aa392f833d6
diff --git a/src/PIL/PngImagePlugin.py b/src/PIL/PngImagePlugin.py --- a/src/PIL/PngImagePlugin.py +++ b/src/PIL/PngImagePlugin.py @@ -1186,23 +1186,21 @@ def _save(im, fp, filename, chunk=putchunk, save_all=False): # attempt to minimize storage requirements for palette images if "bits" in im.encoderi...
diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -634,6 +634,16 @@ def test_specify_bits(self, tmp_path): with Image.open(out) as reloaded: assert len(reloaded.png.im_palette[1]) == 48 + def test_plte_length(self, tmp_pa...
PNG: unnecessary padding in PLTE _Pillow_ incorrectly enforces a minimum of `2` palette entries. ```Python from PIL import Image img = Image.new(size = (1, 1), mode = 'P') img.putpalette((1, 1, 1)) img.save('file.png') ``` ```Bash $ pngcheck -v file.png ... 1 x 1 image, 1-bit palette, non-interlaced c...
```diff diff --git a/PIL/PngImagePlugin.py b/PIL/PngImagePlugin.py index 5e5eb14..9f883c9 100644 --- a/PIL/PngImagePlugin.py +++ b/PIL/PngImagePlugin.py @@ -671,7 +671,7 @@ def _save(im, fp, filename, chunk=putchunk, check=0): else: # check palette contents if im.palette: - ...
2021-03-15T09:32:07Z
8.1
python-pillow/Pillow
5,313
python-pillow__Pillow-5313
[ "5298" ]
d9e4424a7fa6e6e0cd91fd5da89f0a5ccc00f7b8
diff --git a/src/PIL/Image.py b/src/PIL/Image.py --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -1544,8 +1544,6 @@ def alpha_composite(self, im, dest=(0, 0), source=(0, 0)): raise ValueError("Destination must be a 2-tuple") if min(source) < 0: raise ValueError("Source must be non-ne...
diff --git a/Tests/test_image.py b/Tests/test_image.py --- a/Tests/test_image.py +++ b/Tests/test_image.py @@ -344,6 +344,12 @@ def test_alpha_inplace(self): assert_image_equal(offset.crop((64, 64, 127, 127)), target.crop((0, 0, 63, 63))) assert offset.size == (128, 128) + # with negative off...
alpha_composite should be like paste and allow negative destinations If you try to use `alpha_composite` with a negative dest, it produces an error message. For example: ```python from PIL import Image solid_green = Image.new("RGBA",(100,100),(0,255,0,255)) semidark = Image.new("RGBA",(100,100),(0,0,0,127)) ac...
`alpha_composite` was added in #2595 by @wiredfool. Did he have any thoughts on this?
2021-03-06T10:02:40Z
8.1
python-pillow/Pillow
5,208
python-pillow__Pillow-5208
[ "4765" ]
441a1cf9cf7a6fa018e7cecdfbd70b5680b53f26
diff --git a/src/PIL/ImageDraw.py b/src/PIL/ImageDraw.py --- a/src/PIL/ImageDraw.py +++ b/src/PIL/ImageDraw.py @@ -257,6 +257,96 @@ def rectangle(self, xy, fill=None, outline=None, width=1): if ink is not None and ink != fill and width != 0: self.draw.draw_rectangle(xy, ink, 0, width) + def r...
diff --git a/Tests/images/imagedraw_rounded_rectangle.png b/Tests/images/imagedraw_rounded_rectangle.png new file mode 100644 Binary files /dev/null and b/Tests/images/imagedraw_rounded_rectangle.png differ diff --git a/Tests/images/imagedraw_rounded_rectangle_both.png b/Tests/images/imagedraw_rounded_rectangle_both.pn...
Function for Rounded Rectangle ### Feature Request I got a feature request for the `ImageDraw` module. For more modern design, it's very useful to create a rectangle with rounded corners. Currently, it requires a higher effort to create such a rounded rectangle. My Code: ```py def create_rounded_rectangle_mask(...
So to be clear, you can already achieve the desired outcome with Pillow, you're just suggesting that this code become a part of Pillow? Yeah I think there will be several ppl. which might use such function. I also found those functions in other image libraries (other languages) so might be worth considering to implemen...
2021-01-15T11:48:12Z
8.1
python-pillow/Pillow
5,139
python-pillow__Pillow-5139
[ "5116" ]
b48cfa747cecd02ee4d76d12f7bbf64e186982af
diff --git a/src/PIL/Image.py b/src/PIL/Image.py --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -670,7 +670,10 @@ def _repr_png_(self): :returns: png version of the image as bytes """ b = io.BytesIO() - self.save(b, "PNG") + try: + self.save(b, "PNG") + excep...
diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -537,6 +537,12 @@ def test_repr_png(self): assert repr_png.format == "PNG" assert_image_equal(im, repr_png) + def test_repr_png_error(self): + im = hopper("F") ...
Unclear error when displaying images from arrays of float dtype in notebook Floating point images from numpy arrays via the `PIL.Image.fromarray()` raise an unclear error when accidentally returned in jupyter notebook as the final line in a cell. This triggers `IPython.display.display()` on the image object, which in t...
For A, you may be interested in #2663 and the suggested PR #3172. The idea is that you could append `convert_mode=True` and it would then convert automatically if saving wasn't possible.
2020-12-27T04:49:50Z
8
python-pillow/Pillow
5,125
python-pillow__Pillow-5125
[ "3153" ]
ce3d80e7136710ea81b206fd160484013f913c2e
diff --git a/src/PIL/GifImagePlugin.py b/src/PIL/GifImagePlugin.py --- a/src/PIL/GifImagePlugin.py +++ b/src/PIL/GifImagePlugin.py @@ -301,13 +301,14 @@ def load_end(self): # if the disposal method is 'do not dispose', transparent # pixels should show the content of the previous frame - if se...
diff --git a/Tests/images/dispose_none_load_end.gif b/Tests/images/dispose_none_load_end.gif new file mode 100644 Binary files /dev/null and b/Tests/images/dispose_none_load_end.gif differ diff --git a/Tests/images/dispose_none_load_end_second.gif b/Tests/images/dispose_none_load_end_second.gif new file mode 100644 Bin...
Last frame of gif has second last frame merged to it ### What did you do? I iterated through gif frames and added copies of the frames converted to rgba to a list of the following 4 frame gif ![gif](https://raw.githubusercontent.com/s0hvaperuna/pillow-images/master/eevee.gif "gif") This was the code I used and what...
GIFs have a value called a 'disposal method'. For the last frame in this image, it is set to 'Do not dispose. The graphic is to be left in place.' So from what I can see, Pillow is behaving correctly. Clearly standard image viewers have other ideas about what to do in this situation though, and I don't know what log...
2020-12-23T02:24:34Z
8
python-pillow/Pillow
4,966
python-pillow__Pillow-4966
[ "4939" ]
15c339470d8e0d04370146fecc82038cfc419fa0
diff --git a/src/PIL/BmpImagePlugin.py b/src/PIL/BmpImagePlugin.py --- a/src/PIL/BmpImagePlugin.py +++ b/src/PIL/BmpImagePlugin.py @@ -162,10 +162,6 @@ def _bitmap(self, header=0, offset=0): else (1 << file_info["bits"]) ) - # ------------------------------- Check abnormal values for DOS ...
diff --git a/Tests/test_decompression_bomb.py b/Tests/test_decompression_bomb.py --- a/Tests/test_decompression_bomb.py +++ b/Tests/test_decompression_bomb.py @@ -60,6 +60,10 @@ def test_exception_gif(self): with pytest.raises(Image.DecompressionBombError): Image.open("Tests/images/decompression_b...
[Feature Request] Making BMP pixel size limit configurable Hello, I have been a happy user of Pillow for a long time, but new to the developer community. Thank you for making such amazing work available to the world. I am writing to ask if **the community would be open to the idea of making the hard-coded BMP [file...
Makes sense to me. `MAX_IMAGE_PIXELS * 2` is smaller than `2 ** 31`, so it's not like we would be loosening the restriction either. What would be the action here, removing the check altogether, or making it configurable? I would think the best way forward is to make it configurable, by replacing the check for a size of...
2020-10-12T08:37:08Z
7.2
python-pillow/Pillow
4,677
python-pillow__Pillow-4677
[ "4676" ]
9df95e77c58566dff411b61f44298ebbbeb9efae
diff --git a/src/PIL/Image.py b/src/PIL/Image.py --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -3289,7 +3289,9 @@ def load(self, data): if not data: return - self.fp = io.BytesIO(data[6:]) + if data.startswith(b"Exif\x00\x00"): + data = data[6:] + self.fp = io....
diff --git a/Tests/test_file_webp_metadata.py b/Tests/test_file_webp_metadata.py --- a/Tests/test_file_webp_metadata.py +++ b/Tests/test_file_webp_metadata.py @@ -30,6 +30,15 @@ def test_read_exif_metadata(): assert exif_data == expected_exif +def test_read_exif_metadata_without_prefix(): + with Ima...
getexif() crashes when reading empty EXIF data from a PNG file saved by RawTherapy 5.8 ### What did you do? Converted a RAW file to PNG using RawTherapy 5.8. Opened the image file with Pillow and called getexif() ### What did you expect to happen? Since the file has no EXIF data, the expected output is None or an...
The file actually does have EXIF data. It may not have an eXIf chunk, but it has a zTXt chunk, "Raw profile type exif". See https://exiftool.org/TagNames/PNG.html#TextualData for some more information. Pillow has an assumption that EXIF data starts with "Exif\x00\x00", but that is not the case for your image. Here i...
2020-06-07T10:06:37Z
7.1
python-pillow/Pillow
4,749
python-pillow__Pillow-4749
[ "4731" ]
cc83723d6b1277c9b7b782839d4b5d20cadf88c9
diff --git a/src/PIL/ImageOps.py b/src/PIL/ImageOps.py --- a/src/PIL/ImageOps.py +++ b/src/PIL/ImageOps.py @@ -70,7 +70,9 @@ def autocontrast(image, cutoff=0, ignore=None): becomes white (255). :param image: The image to process. - :param cutoff: How many percent to cut off from the histogram. + :para...
diff --git a/Tests/test_imageops.py b/Tests/test_imageops.py --- a/Tests/test_imageops.py +++ b/Tests/test_imageops.py @@ -300,3 +300,14 @@ def check(orientation_im): "Tests/images/hopper_orientation_" + str(i) + ext ) as orientation_im: check(orientation_im) +...
Autocontrast cutoff improvement <!-- Thank you for reporting an issue. Follow these guidelines to ensure your issue is handled properly. If you have a ... 1. General question: consider asking the question on Stack Overflow with the python-imaging-library tag: * https://stackoverflow.com/questions...
2020-06-30T20:48:44Z
7.2
python-pillow/Pillow
4,741
python-pillow__Pillow-4741
[ "4732" ]
977094d4b5554dc575264800e787472d9343e390
diff --git a/src/PIL/IcnsImagePlugin.py b/src/PIL/IcnsImagePlugin.py --- a/src/PIL/IcnsImagePlugin.py +++ b/src/PIL/IcnsImagePlugin.py @@ -337,6 +337,10 @@ def _save(im, fp, filename): # iconutil -c icns -o {} {} + fp_only = not filename + if fp_only: + f, filename = tempfile.mkste...
diff --git a/Tests/test_file_icns.py b/Tests/test_file_icns.py --- a/Tests/test_file_icns.py +++ b/Tests/test_file_icns.py @@ -55,6 +55,19 @@ def test_save_append_images(tmp_path): assert_image_equal(reread, provided_im) +@pytest.mark.skipif(sys.platform != "darwin", reason="Requires macOS") +def test_...
CalledProcessError saving icns file to io.BytesIO() Currently, writing an icns file to an io.ByteIO object fails. This operation is supported by other filetypes (jpg, png, ico, etc) so I'm not clear if this report falls under feature request or bug ### What did you do? Write icns file to io.BytesIO() object ```pyt...
This would be fixed by merging #4526.
2020-06-28T07:27:27Z
7.1
python-pillow/Pillow
4,664
python-pillow__Pillow-4664
[ "4177" ]
ba58ae752c742f891d5c0a7a7162ec39debd9437
diff --git a/src/PIL/ImageFont.py b/src/PIL/ImageFont.py --- a/src/PIL/ImageFont.py +++ b/src/PIL/ImageFont.py @@ -259,7 +259,7 @@ def getsize( :return: (width, height) """ - size, offset = self.font.getsize(text, direction, features, language) + size, offset = self.font.getsize(text, ...
diff --git a/Tests/images/text_mono.gif b/Tests/images/text_mono.gif new file mode 100644 Binary files /dev/null and b/Tests/images/text_mono.gif differ diff --git a/Tests/test_imagefont.py b/Tests/test_imagefont.py --- a/Tests/test_imagefont.py +++ b/Tests/test_imagefont.py @@ -11,6 +11,7 @@ from .helper import ( ...
Truetype fonts not being rendered correctly with the TEXT method ### What did you do? Created an image suitable for the Pimoroni InkyHat display Added italic text onto the image object at different places ### What did you expect to happen? The whole of the last character of the text to be displayed as it did to r...
Have now discovered that: 1) It is not only Italic fonts (can reproduce on various 'light' fonts) 2) The range of ending positions is not limited to 110 Pixels - I now have one at 129 pixels I can replicate this error on macOS with updated libs. I've seen issues similar to this using Pillow to render text for litt...
2020-06-01T20:53:06Z
7.1
python-pillow/Pillow
4,605
python-pillow__Pillow-4605
[ "3677" ]
794e9f0f0e85535e6bd1791e2ec127dec345f319
diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -553,9 +553,10 @@ def _setitem(self, tag, value, legacy_api): ) elif all(isinstance(v, float) for v in values): self.ta...
diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py --- a/Tests/test_file_libtiff.py +++ b/Tests/test_file_libtiff.py @@ -299,9 +299,6 @@ def check_tags(tiffinfo): ) continue - if libtiff and isinstance(value, bytes): - ...
Saving TIFF with compression throws Segmentation Fault 11 in 5.4.1, but not 5.3.0 ### What did you do? Opened a bitonal TIFF created with Adobe Photoshop CC (version 20.0.2) then saved it with Group4 compression using Pillow. TIFF Image should be downloadable from Github repository here: [https://github.com/photosb...
<img width="668" alt="screen shot 2019-02-25 at 2 43 28 pm" src="https://user-images.githubusercontent.com/5132339/53363987-ce4bac00-390b-11e9-836e-c71b450beb85.png"> Git bisect points to https://github.com/python-pillow/Pillow/commit/6ead422e91bec1facc644f02bc25a561d0a02383 from PR https://github.com/python-pillow/Pil...
2020-05-03T10:10:52Z
7.1
python-pillow/Pillow
4,474
python-pillow__Pillow-4474
[ "4343" ]
64e7d72ee8b4a95a3ebc3f255f0f3d3de913b1ea
diff --git a/src/PIL/Image.py b/src/PIL/Image.py --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -1866,7 +1866,11 @@ def resize(self, size, resample=BICUBIC, box=None, reducing_gap=None): factor_y = int((box[3] - box[1]) / size[1] / reducing_gap) or 1 if factor_x > 1 or factor_y > 1: ...
diff --git a/Tests/test_file_jpeg2k.py b/Tests/test_file_jpeg2k.py --- a/Tests/test_file_jpeg2k.py +++ b/Tests/test_file_jpeg2k.py @@ -127,10 +127,17 @@ def test_prog_res_rt(): def test_reduce(): with Image.open("Tests/images/test-card-lossless.jp2") as im: + assert callable(im.reduce) + im.redu...
JPEG 2000 file cannot be Image.reduce() 'd JPEG 2000 file cannot be Image.reduce() 'd ... because img.reduce becomes a integer 0 during loading somehow. Can be repeated with [this image](https://drive.google.com/open?id=1UbSkNdOuUCt50TTu7Zc4PnuP6f-5RkKK) ``` $ python -c 'import PIL;from PIL import Image; i...
Hi. Thanks for reporting this. The bug you've found applies to Jpeg2000 images. #4251 added an Image `reduce` method which is here overlapping with Jpeg2KImagePlugin's `reduce` property. I've created PR #4344 to resolve the situation. In the meantime, you can workaround this by simply copying the image first - ``...
2020-03-14T12:18:58Z
7
python-pillow/Pillow
4,471
python-pillow__Pillow-4471
[ "4460" ]
ca00126e2b5eafb742994bb56df351c5b9f473c2
diff --git a/src/PIL/PngImagePlugin.py b/src/PIL/PngImagePlugin.py --- a/src/PIL/PngImagePlugin.py +++ b/src/PIL/PngImagePlugin.py @@ -694,14 +694,24 @@ def load_end(self): def _getexif(self): if "exif" not in self.info: self.load() - if "exif" not in self.info: + if "exif" not ...
diff --git a/Tests/images/exif_imagemagick.png b/Tests/images/exif_imagemagick.png new file mode 100644 Binary files /dev/null and b/Tests/images/exif_imagemagick.png differ diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -592,8 +592,15 @@ def te...
PngStream does not decode EXIF data from "Raw profile" tags <!-- Thank you for reporting an issue. Follow these guidelines to ensure your issue is handled properly. If you have a ... 1. General question: consider asking the question on Stack Overflow with the python-imaging-library tag: * https:/...
I found https://sourceforge.net/p/png-mng/mailman/png-mng-misc/?viewmonth=201612&viewday=31 which pointed out that the data is hexencoded. So I find that this gives me 55 EXIF keys. ```python from PIL import Image reagan = Image.open("ReaganSmallPng.png") exif = reagan.getexif() print("Found Exif tags:", len(e...
2020-03-13T13:01:03Z
7
python-pillow/Pillow
4,283
python-pillow__Pillow-4283
[ "4274" ]
209faf1b62fa7ed6c9d8b2fc7bd46e1c7e54e0bd
diff --git a/src/PIL/BmpImagePlugin.py b/src/PIL/BmpImagePlugin.py --- a/src/PIL/BmpImagePlugin.py +++ b/src/PIL/BmpImagePlugin.py @@ -321,12 +321,15 @@ def _save(im, fp, filename, bitmap_header=True): # bitmap header if bitmap_header: offset = 14 + header + colors * 4 + file_size = offset + i...
diff --git a/Tests/test_file_bmp.py b/Tests/test_file_bmp.py --- a/Tests/test_file_bmp.py +++ b/Tests/test_file_bmp.py @@ -41,6 +41,13 @@ def test_save_to_bytes(self): self.assertEqual(im.size, reloaded.size) self.assertEqual(reloaded.format, "BMP") + def test_save_too_large(self): + ...
Large BMP files crash (i.e. more than 2**32 pixels) I started asking on StackOverflow about my original problem, and the code is pasted over there: https://stackoverflow.com/questions/59353721/python-pillow-opening-1-bit-depth-files-with-8-bits but after moving to a larger machine (256 GB RAM) I moved on from the o...
Pillow Version: 6.2.1 Looks like BMP max filesize is limited to 4GiB. The second field in BMF file header is filesize in bytes, which is 4 bytes int, which can not exceed 2^32 (4GiB). Since your image is 1bpp image, with given dimensions image size would have to be 7,641,879,368 bytes, which exceeds 4 byte int capacity...
2019-12-20T21:34:33Z
6.2
python-pillow/Pillow
4,240
python-pillow__Pillow-4240
[ "4099" ]
a9fc1b66b1fe1d699674350330af9cd0a9f4d277
diff --git a/src/PIL/MpoImagePlugin.py b/src/PIL/MpoImagePlugin.py --- a/src/PIL/MpoImagePlugin.py +++ b/src/PIL/MpoImagePlugin.py @@ -82,7 +82,10 @@ def seek(self, frame): self.offset = self.__mpoffsets[frame] self.fp.seek(self.offset + 2) # skip SOI marker - if i16(self.fp.read(2)) == 0xFF...
diff --git a/Tests/images/sugarshack_no_data.mpo b/Tests/images/sugarshack_no_data.mpo new file mode 100644 Binary files /dev/null and b/Tests/images/sugarshack_no_data.mpo differ diff --git a/Tests/test_file_mpo.py b/Tests/test_file_mpo.py --- a/Tests/test_file_mpo.py +++ b/Tests/test_file_mpo.py @@ -113,6 +113,13 @@ ...
MPO seek error ### What did you do? I perform an `Image.seek` operation. ### What did you expect to happen? I expect a successful function invocation. ### What actually happened? I get an error: ``` ~/.local/share/virtualenvs/muffinchihuahua-VbII3yUl/lib/python3.7/site-packages/PIL/MpoImagePlugin.py in see...
If I navigate to https://srv-file7.gofile.io/download/X30JBL/137.DSC_0733-3-blueberry-muffins-.jpg in my browser, I get 'You are not authorized to download this file.' Hmm that's bizarre @radarhere. My browser (Chrome) just downloads the file. Same for Python if I run the above. Could you just attach the file in a GitH...
2019-11-30T00:09:44Z
6.2
python-pillow/Pillow
4,063
python-pillow__Pillow-4063
[ "4053" ]
929c817014834e3569b6c2d7112641b8a48da216
diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -1098,6 +1098,20 @@ def load(self): return super(TiffImageFile, self).load() def load_end(self): + if self._tile_orientation: + method = { + ...
diff --git a/Tests/images/g4_orientation_1.tif b/Tests/images/g4_orientation_1.tif new file mode 100755 Binary files /dev/null and b/Tests/images/g4_orientation_1.tif differ diff --git a/Tests/images/g4_orientation_2.tif b/Tests/images/g4_orientation_2.tif new file mode 100755 Binary files /dev/null and b/Tests/images/...
TIFF orientation tag handled differently from most other software when loading G4 TIFF files Most image software handles TIFF orientation tags (tag 274) differently from Pillow when loading binary G4 TIFF images. This means that only images having the orientation tag == 1 (The 0th row represents the visual top of the...
Hi. In Pillow 6.0, `ImageOps.exif_tranpose` was added - https://github.com/python-pillow/Pillow/blob/1e3c2c9ce1aea8536e95ce74086a79793e467618/src/PIL/ImageOps.py#L523-L530 So you should be able to simplify your code down to - ```python from PIL import Image, ImageOps from tkinter import filedialog, Tk root = T...
2019-09-13T13:10:42Z
6.1
python-pillow/Pillow
4,003
python-pillow__Pillow-4003
[ "4002" ]
d96f657328cdb864e011fb576529de8d849229c2
diff --git a/src/PIL/GifImagePlugin.py b/src/PIL/GifImagePlugin.py --- a/src/PIL/GifImagePlugin.py +++ b/src/PIL/GifImagePlugin.py @@ -489,6 +489,11 @@ def _write_multiple_frames(im, fp, palette): offset = frame_data["bbox"][:2] _write_frame_data(fp, im_frame, offset, frame_data["encoderin...
diff --git a/Tests/test_file_gif.py b/Tests/test_file_gif.py --- a/Tests/test_file_gif.py +++ b/Tests/test_file_gif.py @@ -495,6 +495,26 @@ def test_identical_frames(self): # Assert that the new duration is the total of the identical frames self.assertEqual(reread.info["duration"], 4500) + def te...
GIF error for multiple duration values ### What did you do? Using same images and a list of durations to produce a gif ### What did you expect to happen? produce the gif the specified durations ### What actually happened? failed when saving ### What are your OS, Python and Pillow versions? * OS: win10 ...
2019-08-02T00:58:04Z
6.1
python-pillow/Pillow
4,147
python-pillow__Pillow-4147
[ "4146" ]
97ea6898cadb23d281fd5e2fd0167902c00ae671
diff --git a/src/PIL/JpegImagePlugin.py b/src/PIL/JpegImagePlugin.py --- a/src/PIL/JpegImagePlugin.py +++ b/src/PIL/JpegImagePlugin.py @@ -172,10 +172,11 @@ def APP(self, marker): # 1 dpcm = 2.54 dpi dpi *= 2.54 self.info["dpi"] = int(dpi + 0.5), int(dpi + 0.5) - ex...
diff --git a/Tests/images/invalid-exif-without-x-resolution.jpg b/Tests/images/invalid-exif-without-x-resolution.jpg new file mode 100644 Binary files /dev/null and b/Tests/images/invalid-exif-without-x-resolution.jpg differ diff --git a/Tests/test_file_jpeg.py b/Tests/test_file_jpeg.py --- a/Tests/test_file_jpeg.py ++...
Specific image can be opened by browser, but not by Pillow 6.2 ### What did you do? Tried to open a .jpg image with PIL ### What did you expect to happen? The photo can be opened in a browser and on Preview in Mac ### What actually happened? ```python from PIL import Image Image.open("/Users/dir/Desktop/3-fu...
Could you attach the image, so that we can also reproduce the problem?
2019-10-17T17:06:22Z
6.2
python-pillow/Pillow
3,897
python-pillow__Pillow-3897
[ "3875" ]
a986fed5b445bc9586476167b08d46e19cba1bbc
diff --git a/src/PIL/IcnsImagePlugin.py b/src/PIL/IcnsImagePlugin.py --- a/src/PIL/IcnsImagePlugin.py +++ b/src/PIL/IcnsImagePlugin.py @@ -251,8 +251,6 @@ def _open(self): self.best_size[0] * self.best_size[2], self.best_size[1] * self.best_size[2], ) - # Just use this to see i...
diff --git a/Tests/images/hopper_draw.ico b/Tests/images/hopper_draw.ico new file mode 100644 Binary files /dev/null and b/Tests/images/hopper_draw.ico differ diff --git a/Tests/test_file_icns.py b/Tests/test_file_icns.py --- a/Tests/test_file_icns.py +++ b/Tests/test_file_icns.py @@ -61,11 +61,10 @@ def test_sizes(sel...
Draw on a ico file without having to convert to png ### What did you do? Load an ico image, draw lines and save it. ### What did you expect to happen? I expect to get lines on the `.ico` image ### What actually happened? No lines ### The solution I have to load the `.ico` image, save it as a png , reload t...
Thanks for reporting this problem. For your immediate use until this is resolved, I can suggest using `im.copy()` instead of needing to save it and then load it again - ```python from PIL import Image, ImageDraw,ImageFont #create an ico file: this step is just for debug, I already have a `ico` file img = Image....
2019-06-10T15:35:24Z
6
python-pillow/Pillow
3,859
python-pillow__Pillow-3859
[ "3849" ]
169961649d1d946c95155d4f046b8cbcdff49e61
diff --git a/src/PIL/Image.py b/src/PIL/Image.py --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -1794,7 +1794,18 @@ def resize(self, size, resample=NEAREST, box=None): if resample not in ( NEAREST, BILINEAR, BICUBIC, LANCZOS, BOX, HAMMING, ): - raise ValueError("unknown r...
diff --git a/Tests/test_image_transform.py b/Tests/test_image_transform.py --- a/Tests/test_image_transform.py +++ b/Tests/test_image_transform.py @@ -160,6 +160,15 @@ def test_missing_method_data(self): im = hopper() self.assertRaises(ValueError, im.transform, (100, 100), None) + def test_unknow...
"Unknown resampling filter" error message can be improved https://github.com/python-pillow/Pillow/blob/2766d943a1a39ea5beafd3cc10b115f5b608a9ab/src/PIL/Image.py#L1797 https://github.com/python-pillow/Pillow/blob/2766d943a1a39ea5beafd3cc10b115f5b608a9ab/src/PIL/Image.py#L2266 1. "unknown" feels vague/wrong. The re...
1. `resize` supports all the available filters, so in that case, the supplied filter is unknown. 2. When you say that it is hard to determine which filters are supported without reading the source code, https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.transform and https://pillow.readthedoc...
2019-05-20T20:09:35Z
6
python-pillow/Pillow
3,825
python-pillow__Pillow-3825
[ "3823" ]
c15dc4d7cafc1147a7353480d4b81c90c82ec68d
diff --git a/src/PIL/Image.py b/src/PIL/Image.py --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -2643,10 +2643,10 @@ def open(fp, mode="r"): exclusive_fp = False filename = "" - if isPath(fp): - filename = fp - elif HAS_PATHLIB and isinstance(fp, Path): + if HAS_PATHLIB and isinstance(fp, ...
diff --git a/Tests/test_image.py b/Tests/test_image.py --- a/Tests/test_image.py +++ b/Tests/test_image.py @@ -76,6 +76,10 @@ def test_bad_mode(self): @unittest.skipUnless(Image.HAS_PATHLIB, "requires pathlib/pathlib2") def test_pathlib(self): from PIL.Image import Path + im = Image.open(Path(...
On Windows, opening a TIFF with a pathlib.Path argument fails ### What did you do? 1. Create a tiff file (e.g. `from pylab import *; savefig("test.tiff")` using matplotlib). 2. Try to load it with Pillow, passing the path as pathlib.Path: `from PIL import Image; from pathlib import Path; Image.open(Path("test.tiff"...
I wasn't able to replicate this on AppVeyor. I don't suppose you could say if you're only experiencing this on Windows 10, and not Windows 7? Also, while you would think this should be easy to reproduce in the right environment, could you provide a script from start to end, attaching a file if necessary, without mat...
2019-05-04T04:17:41Z
6
python-pillow/Pillow
3,778
python-pillow__Pillow-3778
[ "3758" ]
32d10505a30207a81bb9536d46bd12ec1e7b191f
diff --git a/src/PIL/ImageSequence.py b/src/PIL/ImageSequence.py --- a/src/PIL/ImageSequence.py +++ b/src/PIL/ImageSequence.py @@ -54,3 +54,25 @@ def __next__(self): def next(self): return self.__next__() + + +def all_frames(im, func=None): + """ + Applies a given function to all frames in an imag...
diff --git a/Tests/test_imagesequence.py b/Tests/test_imagesequence.py --- a/Tests/test_imagesequence.py +++ b/Tests/test_imagesequence.py @@ -74,3 +74,25 @@ def test_palette_mmap(self): im.seek(0) color2 = im.getpalette()[0:3] self.assertEqual(color1, color2) + + def test_all_frames(self)...
Transforms and enhancements across all frames It would be nice if transforms and enhancements could be applied on animations.
What sort of transforms and enhancements? for example. https://pillow.readthedocs.io/en/stable/handbook/tutorial.html#geometrical-transforms https://pillow.readthedocs.io/en/stable/handbook/tutorial.html#image-enhancement So when you say that you'd like them to be applied on animations, what you mean is that you'd ...
2019-04-08T03:25:12Z
6
python-pillow/Pillow
3,673
python-pillow__Pillow-3673
[ "3659" ]
d167f9e0bd8a71f7d0a5a1098dc9d51eceb67be2
diff --git a/src/PIL/DdsImagePlugin.py b/src/PIL/DdsImagePlugin.py --- a/src/PIL/DdsImagePlugin.py +++ b/src/PIL/DdsImagePlugin.py @@ -123,43 +123,52 @@ def _open(self): # pixel format pfsize, pfflags = struct.unpack("<2I", header.read(8)) fourcc = header.read(4) - bitcount, rmask, gma...
diff --git a/Tests/images/uncompressed_rgb.dds b/Tests/images/uncompressed_rgb.dds new file mode 100755 Binary files /dev/null and b/Tests/images/uncompressed_rgb.dds differ diff --git a/Tests/images/uncompressed_rgb.png b/Tests/images/uncompressed_rgb.png new file mode 100644 Binary files /dev/null and b/Tests/images/...
DDS Plugin cannot handle uncompressed files Loading a DDS file without compression gives me the following error: ``` File "<SNIP>\PIL\Image.py", line 2676, in open im = _open_core(fp, filename, prefix) File "<SNIP>\PIL\Image.py", line 2658, in _open_core im = factory(fp, filename) File "<SNIP>\PIL\I...
The docs say only DXT1, DXT3 and DXT5 in `RGBA`: > DDS is a popular container texture format used in video games and natively supported by DirectX. Currently, DXT1, DXT3, and DXT5 pixel formats are supported and only in `RGBA` mode. https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html?highligh...
2019-02-22T19:45:09Z
5.4
python-pillow/Pillow
3,625
python-pillow__Pillow-3625
[ "520", "2081" ]
ed596499ecf22d1ccbcacc5a818c7659a92a6334
diff --git a/src/PIL/ImageFile.py b/src/PIL/ImageFile.py --- a/src/PIL/ImageFile.py +++ b/src/PIL/ImageFile.py @@ -27,11 +27,20 @@ # See the README file for information on usage and redistribution. # -from . import Image -from ._util import isPath +from . import Image, TiffTags +from ._binary import i32le +from ._u...
diff --git a/Tests/images/fujifilm.mpo b/Tests/images/fujifilm.mpo new file mode 100644 Binary files /dev/null and b/Tests/images/fujifilm.mpo differ diff --git a/Tests/test_file_mpo.py b/Tests/test_file_mpo.py --- a/Tests/test_file_mpo.py +++ b/Tests/test_file_mpo.py @@ -64,6 +64,18 @@ def test_frame_size(self): ...
Make EXIF plugin Exif support (labeled experimental since 2003) is somewhat adequate for reading, but there's no clear way to change a value and then write it out. We currently support writing Exif as byte strings, with no way to make them apart from manually setting up nested `TiffImagePlugin.ImageFileDirectory` inst...
Can the EXIF tags (or any metadata) be preserved when resizing or generating thumbnails? I wrote a Exif class, that is subclass of dict. Methods "to_bytes" and "load" are added. How is this for prototype? https://github.com/hMatoba/EXIF Thanks. I'll take a look, probably after we get 2.6.0 out I noticed the bump to ...
2019-01-31T14:40:54Z
5.4
python-pillow/Pillow
3,588
python-pillow__Pillow-3588
[ "1631" ]
0306b80ef78aa8ab9f36f62cf2b8f21c3145e3d3
diff --git a/src/PIL/MpoImagePlugin.py b/src/PIL/MpoImagePlugin.py --- a/src/PIL/MpoImagePlugin.py +++ b/src/PIL/MpoImagePlugin.py @@ -18,7 +18,8 @@ # See the README file for information on usage and redistribution. # -from . import Image, JpegImagePlugin +from . import Image, ImageFile, JpegImagePlugin +from ._bin...
diff --git a/Tests/images/sugarshack_frame_size.mpo b/Tests/images/sugarshack_frame_size.mpo new file mode 100644 Binary files /dev/null and b/Tests/images/sugarshack_frame_size.mpo differ diff --git a/Tests/test_file_mpo.py b/Tests/test_file_mpo.py --- a/Tests/test_file_mpo.py +++ b/Tests/test_file_mpo.py @@ -55,6 +55...
No n_frames, or bad value for n_frames When I feed the test file flower2.jpg into this code (from #1630) ```python im = Image.open( fn ) imgcnt = im.n_frames colors = im.getcolors( im.width * im.height ) if args.hist: for cnt, col in colors: allcolors[ col ] += cnt for iz in range( 1, imgcnt...
I'd expect .jpg files to always return 1 as the n_frames attribute; some from some cameras have an embedded thumbnail in the metadata, but I don't think that is particularly standard? Same environment as for #1630: Windows 10, Python 3.5.0, Pillow 3.0.0. So I've added a hasattr workaround to avoid the Attribute err...
2019-01-17T13:02:19Z
5.4
python-pillow/Pillow
3,532
python-pillow__Pillow-3532
[ "3527" ]
41fba67fb028807472eddb126fa228214178008d
diff --git a/src/PIL/PngImagePlugin.py b/src/PIL/PngImagePlugin.py --- a/src/PIL/PngImagePlugin.py +++ b/src/PIL/PngImagePlugin.py @@ -677,6 +677,8 @@ def load_end(self): self.png.call(cid, pos, length) except UnicodeDecodeError: break + except EOFError: + ...
diff --git a/Tests/images/hopper_idat_after_image_end.png b/Tests/images/hopper_idat_after_image_end.png new file mode 100644 Binary files /dev/null and b/Tests/images/hopper_idat_after_image_end.png differ diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py --- a/Tests/test_file_png.py +++ b/Tests/test_file_p...
Error when loading some PNG images After update PIL to 5.4.0 I cannot load an image ![mastercard](https://user-images.githubusercontent.com/9046065/50598772-71f08100-0eb4-11e9-99cd-126e65673626.png) [_image duplicate on Google drive_](https://drive.google.com/open?id=19pwEEGBh7h1iYRn3uSC19z8tkiHokPJQ) The example ...
Reproducible with 5.4.0 with: ```python from PIL import Image im = Image.open("mastercard.png") ``` Not reproducible with 5.3.0. @hugovk I find your comment surprising, given that the traceback involves `load()`. Would you be able to post your traceback? Sorry, missed the last line: ```python from PIL impor...
2019-01-03T06:29:19Z
5.4
python-pillow/Pillow
3,558
python-pillow__Pillow-3558
[ "3557" ]
7bf5246b93cc89cfb9d6cca78c4719a943b10585
diff --git a/src/PIL/PngImagePlugin.py b/src/PIL/PngImagePlugin.py --- a/src/PIL/PngImagePlugin.py +++ b/src/PIL/PngImagePlugin.py @@ -533,14 +533,6 @@ def chunk_acTL(self, pos, length): self.im_custom_mimetype = 'image/apng' return s - def chunk_fcTL(self, pos, length): - s = ImageFile._s...
diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -596,6 +596,7 @@ def test_apng(self): im = Image.open("Tests/images/iss634.apng") self.assertEqual(im.get_format_mimetype(), 'image/apng') + # This also tests reading unkn...
Error opening png file ### What did you do? I tried to open image ### What did you expect to happen? Image to be opened without errors ### What actually happened? Pillow raised error. Traceback: ``` File "/usr/local/lib/python3.6/dist-packages/PIL/Image.py", line 915, in convert self.load() File "/u...
With: * macOS High Sierra * Python 3.7.2 Cannot reproduce with: * Pillow 3.4.1 * Pillow 5.3.0 Can reproduce with: * Pillow 5.4.0 * Pillow 5.4.1 (latest) Git bisect points to 22837c37e279a5fb3fb7b482d81e2c4d44c8cdcc from https://github.com/python-pillow/Pillow/pull/3506: ``` 22837c37e279a5fb3fb7b482d81e2...
2019-01-07T20:53:24Z
5.4
python-pillow/Pillow
3,513
python-pillow__Pillow-3513
[ "2745" ]
5d9a3273d5a6952fd111490665f90e160e1dab03
diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -557,26 +557,26 @@ def _setitem(self, tag, value, legacy_api): else: self.tagtype[tag] = 7 if all(isinstance(v, IFDRational) for v in v...
diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py --- a/Tests/test_file_libtiff.py +++ b/Tests/test_file_libtiff.py @@ -235,7 +235,10 @@ def test_additional_metadata(self): def test_custom_metadata(self): custom = { 37000: 4, - 37001: 4.2 + 37001: 4.2,...
Failed to write customized tag into Tiff file I am using python version 2.7 I am trying to write some custom tag(37000 in this case) into new tiff file. It is able to read tag from image but when I am trying to write them it is not successfully written. When I am use pillow 4.1.0 to do that, tag is not added, and...
Unfortunately, Tiff IFD tags are a bit of a mess when writing. The native python tiff writer will write arbitrary tags, but it's limited to raw, uncompressed pixel data. The libtiff writer is limited to only the standard builtin tags, and at that, only a subset. We do not currently implement the api methods require...
2018-12-29T05:35:47Z
5.3
python-pillow/Pillow
3,479
python-pillow__Pillow-3479
[ "1718" ]
080bfd3ee1412b401d520fe26c51e2f5515e3a65
diff --git a/src/PIL/GifImagePlugin.py b/src/PIL/GifImagePlugin.py --- a/src/PIL/GifImagePlugin.py +++ b/src/PIL/GifImagePlugin.py @@ -201,7 +201,13 @@ def _seek(self, frame): # # comment extension # - info["comment"] = block + ...
diff --git a/Tests/images/hopper_zero_comment_subblocks.gif b/Tests/images/hopper_zero_comment_subblocks.gif new file mode 100644 Binary files /dev/null and b/Tests/images/hopper_zero_comment_subblocks.gif differ diff --git a/Tests/test_file_gif.py b/Tests/test_file_gif.py --- a/Tests/test_file_gif.py +++ b/Tests/test_...
GIF decoder can't handle zero-length extension blocks To reproduce: ``` python >>> import io, PIL.Image >>> PIL.Image.open(io.BytesIO(bytes.fromhex('47 49 46 38 39 61 01 00 01 00 80 00 00 FF FF FF 00 00 00 21 FE 00 2C 00 00 00 00 01 00 01 00 00 02 02 44 01 00 3B'))) ```
I presume that this image is able to be redistributed as a image in the test suite under Pillow's license? Just to post information here, an EOFError is being raised at https://github.com/python-pillow/Pillow/blob/384d32969d3f6701477a616356ed5c180215103a/PIL/GifImagePlugin.py#L266
2018-11-27T19:02:54Z
5.3
python-pillow/Pillow
3,364
python-pillow__Pillow-3364
[ "3339" ]
d4000a8f728e051a4da811a9ea23144e6b5fe6c3
diff --git a/src/PIL/ImageOps.py b/src/PIL/ImageOps.py --- a/src/PIL/ImageOps.py +++ b/src/PIL/ImageOps.py @@ -221,6 +221,50 @@ def colorize(image, black, white, mid=None, blackpoint=0, return _lut(image, red + green + blue) +def pad(image, size, method=Image.NEAREST, color=None, centering=(0.5, 0.5)): + ""...
diff --git a/Tests/images/imageops_pad_h_0.jpg b/Tests/images/imageops_pad_h_0.jpg new file mode 100644 Binary files /dev/null and b/Tests/images/imageops_pad_h_0.jpg differ diff --git a/Tests/images/imageops_pad_h_1.jpg b/Tests/images/imageops_pad_h_1.jpg new file mode 100644 Binary files /dev/null and b/Tests/images/...
Suggestion: option to pad instead of crop in ImageOps.fit I recently wanted to use Pillow to generate thumbnails of a directory of images. I wanted each thumbnail to be exactly 300x200, but preserve the aspect ratio of the original image by padding one of the dimensions. I thought [`PIL.ImageOps.fit`](https://pillow...
Here is another method - ```python from PIL import Image im = Image.open("test.png") w, h = 300, 200 ratio = im.width / im.height if ratio == w / h: out = im.resize((w, h)) else: out = Image.new(im.mode, (w, h)) if ratio > w / h: new_h = int(im.height / im.width * w) im = im.resize((w, new_h)) out...
2018-09-18T11:11:01Z
5.2
python-pillow/Pillow
3,338
python-pillow__Pillow-3338
[ "1765" ]
41954f244705b247667f1ea228e932ca6390bcd6
diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -567,6 +567,9 @@ def _setitem(self, tag, value, legacy_api): if self.tagtype[tag] == 7 and py3: values = [value.encode("ascii", 'replace') if isinstance( ...
diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py --- a/Tests/test_file_libtiff.py +++ b/Tests/test_file_libtiff.py @@ -231,6 +231,16 @@ def test_additional_metadata(self): TiffImagePlugin.WRITE_LIBTIFF = False + def test_int_dpi(self): + # issue #1765 + im = hopper('RGB...
Save compressed TIFF only accepts float values for dpi There is a trap in setting the resolution for compressed TIFF images. ```python # pillow v3.1.1 import PIL.Image im = PIL.Image.new('CMYK', (100, 100)) dpi = 100.0 # works dpi = 100 # fails im.save('test.tif', format='TIFF', dpi=(dpi, dp...
2018-09-07T10:51:11Z
5.2
python-pillow/Pillow
3,233
python-pillow__Pillow-3233
[ "3231" ]
5e0682ed6a957ef0e6bf6f70bb0438cfdfc9b48c
diff --git a/src/PIL/ImageDraw.py b/src/PIL/ImageDraw.py --- a/src/PIL/ImageDraw.py +++ b/src/PIL/ImageDraw.py @@ -246,7 +246,7 @@ def multiline_text(self, xy, text, fill=None, font=None, anchor=None, elif align == "right": left += (max_width - widths[idx]) else: - ...
diff --git a/Tests/test_image_access.py b/Tests/test_image_access.py --- a/Tests/test_image_access.py +++ b/Tests/test_image_access.py @@ -1,15 +1,20 @@ from helper import unittest, PillowTestCase, hopper, on_appveyor -try: - from PIL import PyAccess -except ImportError: - # Skip in setUp() - pass - from P...
Pillow cannot be loaded in python optimize (2) mode ### What did you do? I was loading the PIL module with 'import PIL' when running Python with PYTHONOPTIMZE=2 (or python -OO). ### What did you expect to happen? I Expected the PIL/Pillow Library to be imported. ### What actually happened? I received an except...
2018-07-04T17:35:30Z
5.2
python-pillow/Pillow
3,086
python-pillow__Pillow-3086
[ "3073" ]
e24fad40ad67fac3d86e1a826fbf91b4d2fe7c90
diff --git a/src/PIL/GifImagePlugin.py b/src/PIL/GifImagePlugin.py --- a/src/PIL/GifImagePlugin.py +++ b/src/PIL/GifImagePlugin.py @@ -457,7 +457,8 @@ def _save_all(im, fp, filename): def _save(im, fp, filename, save_all=False): - im.encoderinfo.update(im.info) + for k, v in im.info.items(): + im.enco...
diff --git a/Tests/test_file_gif.py b/Tests/test_file_gif.py --- a/Tests/test_file_gif.py +++ b/Tests/test_file_gif.py @@ -305,9 +305,12 @@ def test_duration(self): out = self.tempfile('temp.gif') im = Image.new('L', (100, 100), '#000') + + # Check that the argument has priority over the info...
Gif duration setting is ignored ### What versions of Pillow and Python are you using? Python 3.6.4 Pillow 5.0 Any animated gif I have tried the following lines of code on show no affect on the gif frame duration: ```python > from PIL import Image > f = Image.open('in.gif') > f.save('out.gif', save_all=True, ...
Hi. To help with your immediate problem, try this - ```python from PIL import Image f = Image.open('in.gif') f.info['duration'] = 400 f.save('out.gif', save_all=True) ``` What I'm guessing is happening is that the images you are opening already have a `duration` key, and this key is overwriting the `duration...
2018-04-10T12:34:37Z
5.1
python-pillow/Pillow
3,023
python-pillow__Pillow-3023
[ "3022" ]
262b6d15ccc5af3e31f6b6a8092ff9808bd991ff
diff --git a/src/PIL/ImageFile.py b/src/PIL/ImageFile.py --- a/src/PIL/ImageFile.py +++ b/src/PIL/ImageFile.py @@ -202,44 +202,39 @@ def load(self): for decoder_name, extents, offset, args in self.tile: decoder = Image._getdecoder(self.mode, decoder_name, ...
diff --git a/Tests/images/truncated_jpeg.jpg b/Tests/images/truncated_jpeg.jpg new file mode 100644 Binary files /dev/null and b/Tests/images/truncated_jpeg.jpg differ diff --git a/Tests/test_file_jpeg.py b/Tests/test_file_jpeg.py --- a/Tests/test_file_jpeg.py +++ b/Tests/test_file_jpeg.py @@ -348,6 +348,22 @@ def test...
Corrupt jpeg opens as all black image ### What did you do? ```python from PIL import Image from PIL import ImageFile ImageFile.LOAD_TRUNCATED_IMAGES = True im = Image.open('pic263134.jpg') im.save('1.png') ``` ### What did you expect to happen? Image could be saved up to corruption point. ### What actual...
2018-03-01T06:19:33Z
5
python-pillow/Pillow
2,899
python-pillow__Pillow-2899
[ "2839" ]
6d2a02c6b1e84906ed2060f547d03d71e23f41d4
diff --git a/PIL/TiffImagePlugin.py b/PIL/TiffImagePlugin.py --- a/PIL/TiffImagePlugin.py +++ b/PIL/TiffImagePlugin.py @@ -1029,21 +1029,8 @@ def _decoder(self, rawmode, layer, tile=None): compression = self._compression if compression == "raw": args = (rawmode, 0, 1) - elif compre...
diff --git a/Tests/helper.py b/Tests/helper.py --- a/Tests/helper.py +++ b/Tests/helper.py @@ -14,11 +14,22 @@ HAS_UPLOADER = False -try: - import test_image_results - HAS_UPLOADER = True -except ImportError: - pass + +if os.environ.get('SHOW_ERRORS', None): + # local img.show for errors. + HAS_UPL...
TIFF_LZW decompression is incorrect for 16bpc image Pillow was refusing to open this TIFF in version 4.2.1. In version 4.3.0, it loads it, but then saving it in any format including TIFF produces a silent corruption. Python 2.7.14 in both cases. This is the reproducing script: ``` from PIL import Image ...
If you use libtiff instead of the internal tiff decoder, it works: ``` from PIL import Image, TiffImagePlugin TiffImagePlugin.READ_LIBTIFF=True im = Image.open('issue_2839.tif') im.show() ``` This image is a 16bit RGBA image, with tiff_lzw compression. Pillow 4.3.0 added support for the 16 bit RGBA type, th...
2017-12-20T11:57:54Z
4.3
python-pillow/Pillow
2,852
python-pillow__Pillow-2852
[ "2837" ]
a3b15c4a5f219451d4e6e2929ea9d983f8468ea9
diff --git a/PIL/Image.py b/PIL/Image.py --- a/PIL/Image.py +++ b/PIL/Image.py @@ -2074,7 +2074,8 @@ def thumbnail(self, size, resample=BICUBIC): # FIXME: the different transform methods need further explanation # instead of bloating the method docs, add a separate chapter. - def transform(self, size, me...
diff --git a/Tests/test_image_transform.py b/Tests/test_image_transform.py --- a/Tests/test_image_transform.py +++ b/Tests/test_image_transform.py @@ -52,6 +52,17 @@ def test_quad(self): self.assert_image_equal(transformed, scaled) + def test_fill(self): + im = hopper('RGB') + (w, h) = im....
Affine transformation fill parameter seems to do nothing I would like to use PIL to perform an affine warp on an image, but I want to specify a custom fill value for undefined pixels. The `transform` function seems to have a `fill=1` argument, but it is undocumented and looking further in the code it seems to be unused...
I am also interested in this!
2017-11-13T10:00:35Z
4.3
python-pillow/Pillow
2,683
python-pillow__Pillow-2683
[ "2044" ]
52e9c831767eaa60cc1686842f4019e0e9964ad8
diff --git a/PIL/Image.py b/PIL/Image.py --- a/PIL/Image.py +++ b/PIL/Image.py @@ -2423,7 +2423,7 @@ def fromqpixmap(im): _fromarray_typemap = { # (shape, typestr) => mode, rawmode # first two members of shape are set to one - # ((1, 1), "|b1"): ("1", "1"), # broken + ((1, 1), "|b1"): ("1", "1;8"), ...
diff --git a/Tests/test_numpy.py b/Tests/test_numpy.py --- a/Tests/test_numpy.py +++ b/Tests/test_numpy.py @@ -39,7 +39,7 @@ def test_numpy_to_image(self): def to_image(dtype, bands=1, boolean=0): if bands == 1: if boolean: - data = [0, 1] * 50 + ...
Image.fromarray does not accept array with dtype=bool ### What did you do? ``` >>> im = Image.new("1", (10,10)) >>> a = np.asarray(im) >>> a.dtype dtype('bool') >>> im2 = Image.fromarray(a) Traceback (most recent call last): File "<input>", line 1, in <module> File "/home/moi/Dokumente/Studium/Thesis/Python/local/...
That's a known issue. See #350 Thanks for the hint. @wiredfool Any update on this? #350 is already closed and seems to handle 1-bit image to numpy array conversion, but not the other way around. The exception can still be reproduced following the steps given by the OP. Note that it is even more weird that the `mode='...
2017-08-16T18:51:13Z
4.2
python-pillow/Pillow
2,410
python-pillow__Pillow-2410
[ "2402" ]
130c9c52a4cd821ef099bfe30d46a9dd24a11aee
diff --git a/PIL/GifImagePlugin.py b/PIL/GifImagePlugin.py --- a/PIL/GifImagePlugin.py +++ b/PIL/GifImagePlugin.py @@ -257,7 +257,7 @@ def _seek(self, frame): # only dispose the extent in this frame if self.dispose: - self.dispose = self.dispose.crop(self.dispose_extent) + ...
diff --git a/Tests/test_decompression_bomb.py b/Tests/test_decompression_bomb.py --- a/Tests/test_decompression_bomb.py +++ b/Tests/test_decompression_bomb.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -35,9 +35,24 @@ d...
out of memory when processing this GIF source: http://lavender.b0.upaiyun.com/ex.gif ![example.jpg](http://lavender.b0.upaiyun.com/ex.gif) ```python import PIL import PIL.Image im = PIL.Image.open('example.gif') print(im.size) print(im.n_frames) # will crash ``` ```shell [root /tmp] python3 run.py ...
any idea? Well, as you've noted, the dispose_extent of frame 90 is rather large: ``` (Pdb) self.dispose_extent (37042, 49425, 90174, 109354) (Pdb) frame 90 ``` This is fed to crop, which ultimately returns a new image. Or, tries to, as that's a rather large image. Any potential fix for #2383 could interact...
2017-02-17T15:26:15Z
4.1
python-pillow/Pillow
2,641
python-pillow__Pillow-2641
[ "2639" ]
0cd84cf9b38c37fa27454cf262514308cc84ab2c
diff --git a/PIL/ImageFont.py b/PIL/ImageFont.py --- a/PIL/ImageFont.py +++ b/PIL/ImageFont.py @@ -36,6 +36,7 @@ class _imagingft_not_installed(object): def __getattr__(self, id): raise ImportError("The _imagingft C module is not installed") + try: from . import _imagingft as core except ImportEr...
diff --git a/Tests/test_imagefont.py b/Tests/test_imagefont.py --- a/Tests/test_imagefont.py +++ b/Tests/test_imagefont.py @@ -40,13 +40,15 @@ def __exit__(self, type, value, traceback): else: delattr(self._parent_obj, self._attr_name) + @unittest.skipUnless(HAS_FREETYPE, "ImageFont not Availab...
getmask2() got an unexpected keyword argument 'align' ### What did you do? Run a py script that uses PIL ### What did you expect to happen? The script uses PIL to show an image with text ### What actually happened? Error happened ### What versions of Pillow and Python are you using? PIL 4.2.1 and Python 3....
What kind of font are you using? From https://github.com/Aioxas/ax-cogs/blob/master/horoscope/horoscope.py#L204-L216: ```python def fortune_process(self, fortune): img = Image.open("data/horoscope/cookie.png") draw = ImageDraw.Draw(img) font = ImageFont.truetype("data/horoscope/FortuneC...
2017-07-23T21:03:41Z
4.2
python-pillow/Pillow
2,399
python-pillow__Pillow-2399
[ "2398" ]
0f9233623e20599166581e7d63762e8052e29187
diff --git a/PIL/Image.py b/PIL/Image.py --- a/PIL/Image.py +++ b/PIL/Image.py @@ -1715,7 +1715,10 @@ def save(self, fp, format=None, **params): if not format: if ext not in EXTENSION: init() - format = EXTENSION[ext] + try: + format = EXTENSIO...
diff --git a/Tests/test_image.py b/Tests/test_image.py --- a/Tests/test_image.py +++ b/Tests/test_image.py @@ -87,6 +87,11 @@ def test_tempfile(self): reloaded = Image.open(fp) self.assert_image_similar(im, reloaded, 20) + def test_unknown_extension(self): + im = hopper() + ...
cryptic error message when saving to a file without a valid extension ### What did you do? I tried to save a file with an invalid extension, e. g. ".5" ### What did you expect to happen? I would expect getting an error message telling me that pillow doesn't know this extension. ### What actually happened? I go...
2017-02-13T17:07:44Z
4
python-pillow/Pillow
2,330
python-pillow__Pillow-2330
[ "2032" ]
2152b26515fddab64c6f1e73c7eb0028d8ab1212
diff --git a/PIL/DcxImagePlugin.py b/PIL/DcxImagePlugin.py --- a/PIL/DcxImagePlugin.py +++ b/PIL/DcxImagePlugin.py @@ -41,7 +41,8 @@ class DcxImageFile(PcxImageFile): format = "DCX" format_description = "Intel DCX" - + _close_exclusive_fp_after_loading = False + def _open(self): # Hea...
diff --git a/Tests/test_file_jpeg.py b/Tests/test_file_jpeg.py --- a/Tests/test_file_jpeg.py +++ b/Tests/test_file_jpeg.py @@ -3,6 +3,7 @@ from io import BytesIO import os +import sys from PIL import Image from PIL import ImageFile @@ -501,5 +502,27 @@ def test_save_tiff_with_dpi(self): self.assertEqua...
Close files after loading Draft for #2019 This PR closes files at least for files which we are opening from filename at least for not sequence formats. This breaks consistency across different codecs, though. Is there any reliable place where we can close files for sequence formats?
2017-01-01T20:32:14Z
4
python-pillow/Pillow
2,328
python-pillow__Pillow-2328
[ "2155" ]
f3751a1f3afb956066bfa69accd28e4f58bfbaac
diff --git a/PIL/Image.py b/PIL/Image.py --- a/PIL/Image.py +++ b/PIL/Image.py @@ -1555,7 +1555,7 @@ def resize(self, size, resample=NEAREST): return self._new(self.im.resize(size, resample)) - def rotate(self, angle, resample=NEAREST, expand=0): + def rotate(self, angle, resample=NEAREST, expand=0, ...
diff --git a/Tests/images/hopper_45.png b/Tests/images/hopper_45.png new file mode 100644 Binary files /dev/null and b/Tests/images/hopper_45.png differ diff --git a/Tests/test_image_rotate.py b/Tests/test_image_rotate.py --- a/Tests/test_image_rotate.py +++ b/Tests/test_image_rotate.py @@ -4,32 +4,100 @@ class Test...
Add center and translate option to Image.rotate. Hi, freeimage has a RotateEx function that allows to set a rotation center and a subsequent translation. Due to the affine matrix used for the interpolation, this is super-easy to implement in Pillow, too, and really makes a lot of sense to provide in the API, as calcul...
2017-01-01T11:16:48Z
3.4
python-pillow/Pillow
2,262
python-pillow__Pillow-2262
[ "2259" ]
789ac7aa720cdc81769eddf51cb9729cbb8ad0c1
diff --git a/PIL/Image.py b/PIL/Image.py --- a/PIL/Image.py +++ b/PIL/Image.py @@ -1994,8 +1994,8 @@ def _check_size(size): raise ValueError("Size must be a tuple") if len(size) != 2: raise ValueError("Size must be a tuple of length 2") - if size[0] <= 0 or size[1] <= 0: - raise ValueEr...
diff --git a/Tests/test_image.py b/Tests/test_image.py --- a/Tests/test_image.py +++ b/Tests/test_image.py @@ -256,7 +256,11 @@ def test_check_size(self): with self.assertRaises(ValueError): Image.new('RGB', (0,)) # Tuple too short with self.assertRaises(ValueError): - Image.n...
Image of size zero is not getting initialized I want an image with zero size. I have a lot of use for it. ```py >>> from PIL import Image as im >>> import numpy as np >>> im.fromarray(np.empty((0, 0), dtype=np.uint8)) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/l...
2016-11-29T19:35:22Z
3.4
python-pillow/Pillow
2,115
python-pillow__Pillow-2115
[ "2064" ]
e5fd6d519e5b98584f7e23c3d7fb1783c45f3920
diff --git a/PIL/JpegImagePlugin.py b/PIL/JpegImagePlugin.py --- a/PIL/JpegImagePlugin.py +++ b/PIL/JpegImagePlugin.py @@ -682,13 +682,16 @@ def validate_qtables(qtables): o8(len(markers)) + marker) i += 1 + # "progressive" is the official name, but older documentation + # sa...
diff --git a/Tests/test_file_jpeg.py b/Tests/test_file_jpeg.py --- a/Tests/test_file_jpeg.py +++ b/Tests/test_file_jpeg.py @@ -227,12 +227,20 @@ def test_exif_gps_typeerror(self): def test_progressive_compat(self): im1 = self.roundtrip(hopper()) + self.assertFalse(im1.info.get("progressive")) + ...
unintuitive save properties > **progressive** > If present, indicates that this image should be stored as a progressive JPEG file. It is not completely obvious that `progressive = False` evaluates to it being set. I guess it's difficult to change this whilst keeping backwards compatibility. (I doubt someone passes `pr...
2016-09-17T10:14:27Z
3.3
python-pillow/Pillow
2,131
python-pillow__Pillow-2131
[ "2037", "2037" ]
4129c6e0ebc97f7632458a634017c63d675302eb
diff --git a/PIL/ImageCms.py b/PIL/ImageCms.py --- a/PIL/ImageCms.py +++ b/PIL/ImageCms.py @@ -162,8 +162,11 @@ def __init__(self, profile): self._set(core.profile_open(profile), profile) elif hasattr(profile, "read"): self._set(core.profile_frombytes(profile.read())) + elif is...
diff --git a/Tests/test_imagecms.py b/Tests/test_imagecms.py --- a/Tests/test_imagecms.py +++ b/Tests/test_imagecms.py @@ -321,5 +321,17 @@ def truncate_tuple(tuple_or_float): self.assertEqual(p.viewing_condition, 'Reference Viewing Condition in IEC 61966-2-1') self.assertEqual(p.xcolor_space, 'RGB ')...
segfault: ImageCmsProfile ``` Python >>> from PIL import ImageCms >>> ImageCms.ImageCmsProfile(0).tobytes() python: cmsio0.c:1301: cmsSaveProfileToIOhandler: Assertion '(hProfile != ((void *)0))' failed. >>> ImageCms.ImageCmsProfile(1).tobytes() Segmentation fault ``` segfault: ImageCmsProfile ``` Python >>> from PIL ...
It also accepts `None` and returns a 132-bytes ICC header. Looks like any arbitrary python object is getting passed into cms_profile_tobytes, where it's cast to a CmsProfileObject and then used. Looks like we need some type checks in the python level at ImageCmsProfile.**init** and in the c layer in cms_profile_tobyt...
2016-09-26T13:22:05Z
3.3
python-pillow/Pillow
2,103
python-pillow__Pillow-2103
[ "2098" ]
6e7553fb0f12025306b2819b9b842adf6b598b2e
diff --git a/PIL/GifImagePlugin.py b/PIL/GifImagePlugin.py --- a/PIL/GifImagePlugin.py +++ b/PIL/GifImagePlugin.py @@ -351,34 +351,38 @@ def _save(im, fp, filename, save_all=False): previous = None first_frame = None - for im_frame in ImageSequence.Iterator(im): - im_frame = _conve...
diff --git a/Tests/test_file_gif.py b/Tests/test_file_gif.py --- a/Tests/test_file_gif.py +++ b/Tests/test_file_gif.py @@ -306,6 +306,24 @@ def test_version(self): reread = Image.open(out) self.assertEqual(reread.info["version"], b"GIF87a") + def test_append_images(self): + out = self.temp...
Create an animated GIF from scratch Can Pillow create animated GIFs from scratch at all? Like, having a series of 10 images of the same size, can I turn them into frames and save them as an animated GIF?
Yes you can, check this package https://gist.github.com/jonschoning/7216290 . No offence, but you are practically writing the GIF by hand byte by byte. I could do that as well, but I'd rather have an abstraction over the format of GIF files, that's why I'm using an imaging library. Hi. There isn't a simple way to do ...
2016-09-04T11:17:44Z
3.3
python-pillow/Pillow
1,988
python-pillow__Pillow-1988
[ "1910" ]
8e7f0cb192aa488f6b4622e71ec0ba9eb9a592c0
diff --git a/PIL/TiffImagePlugin.py b/PIL/TiffImagePlugin.py --- a/PIL/TiffImagePlugin.py +++ b/PIL/TiffImagePlugin.py @@ -544,8 +544,7 @@ def _setitem(self, tag, value, legacy_api): self.tagtype[tag] = 2 if self.tagtype[tag] == 7 and bytes is not str: - values = [valu...
diff --git a/Tests/test_file_tiff.py b/Tests/test_file_tiff.py --- a/Tests/test_file_tiff.py +++ b/Tests/test_file_tiff.py @@ -287,7 +287,7 @@ def test_load_byte(self): ifd = TiffImagePlugin.ImageFileDirectory_v2() data = b"abc" ret = ifd.load_byte(data, legacy_api) - s...
Tuple of integers in info['icc_profile'] Test image: http://ucarecdn.com/265ac6b0-2a1f-4128-b198-ee5159581771/ Pillow 3.2 ``` python >>> icc = Image.open('test.tiff').info['icc_profile'] >>> print repr(icc[:30]) (0, 8, 128, 112, 65, 68, 66, 69, 2, 16, 0, 0, 112, 114, 116, 114, 67, 77, 89, 75, 76, 97, 98, 32, 7, 208, ...
Currently, I use the following code to extract ICC profile in Pillow 3.2: ``` python def _extract_icc(self): icc = self.image.info.pop('icc_profile', None) if isinstance(icc, tuple): try: icc = "".join(icc) except TypeError: icc = ''.join(map(...
2016-06-26T11:14:28Z
3.2
python-pillow/Pillow
1,985
python-pillow__Pillow-1985
[ "1593" ]
4a63e9c384d3d581be853fc93bb6445a2d7afe32
diff --git a/PIL/ImagePalette.py b/PIL/ImagePalette.py --- a/PIL/ImagePalette.py +++ b/PIL/ImagePalette.py @@ -38,7 +38,7 @@ class ImagePalette(object): def __init__(self, mode="RGB", palette=None, size=0): self.mode = mode self.rawmode = None # if set, palette contains raw data - self.pa...
diff --git a/Tests/images/chi.gif b/Tests/images/chi.gif new file mode 100644 Binary files /dev/null and b/Tests/images/chi.gif differ diff --git a/Tests/test_imagedraw.py b/Tests/test_imagedraw.py --- a/Tests/test_imagedraw.py +++ b/Tests/test_imagedraw.py @@ -52,6 +52,13 @@ def test_removed_methods(self): se...
Changed int conversion in ImagePalette to ord for Python 2 Error reported in #1592
I'm not convinced that this is the right approach yet. There's got to be something screwy with the palette, because if it was just an bytes/int conversion issue, then we'd likely have run across this before. The code's been in there since the conversion to py3. What's the character that's throwing it off? How is it...
2016-06-25T13:59:28Z
3.2
python-pillow/Pillow
1,647
python-pillow__Pillow-1647
[ "1645" ]
d6bbe295323bf31dbc89d8bd2dcf3644309ad994
diff --git a/PIL/ImageDraw.py b/PIL/ImageDraw.py --- a/PIL/ImageDraw.py +++ b/PIL/ImageDraw.py @@ -241,9 +241,9 @@ def _multiline_split(self, text): return text.split(split_character) - def text(self, xy, text, fill=None, font=None, anchor=None): + def text(self, xy, text, fill=None, font=None, ancho...
diff --git a/Tests/test_imagefont.py b/Tests/test_imagefont.py --- a/Tests/test_imagefont.py +++ b/Tests/test_imagefont.py @@ -121,6 +121,7 @@ def test_textsize_equal(self): size = draw.textsize(txt, ttf) draw.text((10, 10), txt, font=ttf) draw.rectangle((10, 10, 10 + size[0], 10 ...
Provide additional keyword args for ImageDraw.text(...) method for multiline text The check for `if self._multiline_check(text):` inside of the `ImageDraw.text(...)` method [1] is great, but if True, it goes to the next line `return self.multiline_text(xy, text, fill, font, anchor)` and doesn't allow the user to pass i...
2016-01-05T23:46:23Z
3.1
python-pillow/Pillow
1,686
python-pillow__Pillow-1686
[ "1685" ]
3d6e137ff274ab14cedf89d4e54e65095ae89f3d
diff --git a/PIL/ImageSequence.py b/PIL/ImageSequence.py --- a/PIL/ImageSequence.py +++ b/PIL/ImageSequence.py @@ -35,8 +35,7 @@ def __init__(self, im): def __getitem__(self, ix): try: - if ix: - self.im.seek(ix) + self.im.seek(ix) return self.im ...
diff --git a/Tests/test_imagesequence.py b/Tests/test_imagesequence.py --- a/Tests/test_imagesequence.py +++ b/Tests/test_imagesequence.py @@ -44,6 +44,17 @@ def test_libtiff(self): self._test_multipage_tiff() TiffImagePlugin.READ_LIBTIFF = False + def test_consecutive(self): + im = Image....
Repeated looping over image stack shows last frame in place of first frame When looping through the frames in an animation or TIFF stack with `ImageSequence.Iterator`, the frame pointer is not reset for the first frame. Consequently, if the loop is run through a second time the final frame is shown again instead of the...
Sounds fair enough to me. I've created a PR for review.
2016-01-27T01:56:43Z
3.1