Commit Graph

37 Commits

Author SHA1 Message Date
Andrew Murray
58b5c9187d Replaced absolute PIL imports with relative imports (#2349) 2017-01-17 13:22:18 +00:00
Jon Dufresne
6bc8fdd342 Close file after reading in ImagePalette.load()
Fixes some "ResourceWarning: unclosed file ..." when running tests with
warnings enabled.
2016-11-11 16:59:32 -08:00
wiredfool
31521dc64f Merge pull request #1832 from radarhere/imagepalette
Removed duplicate code in ImagePalette
2016-06-29 22:50:39 +01:00
wiredfool
c6489e6fb7 bytearray as preferred palette storage 2016-06-09 22:32:16 +01:00
Andrew Murray
4f6f5f9182 Changed int conversion in ImagePalette to ord for Python 2 2016-06-09 22:28:29 +01:00
Andrew Murray
f9b3a5dbe4 Removed duplicate code in ImagePalette 2016-04-14 19:54:25 +10:00
wiredfool
89ccf66ff7 Merge pull request #1343 from radarhere/deprecated
Removed deprecated code
2015-09-29 15:38:34 +01:00
Andrew Murray
47366692d9 Removed ImagePalette methods, deprecated in 2.6 2015-09-19 21:06:12 +10:00
Andrew Murray
3e47ddbeeb Removed comment that Python 2 behaviour is deprecated 2015-09-19 21:06:11 +10:00
Andrew Murray
105e963505 Flake8 fixes 2015-09-11 19:28:19 +10:00
wiredfool
5473766490 Merge pull request #1381 from bwrsandman/patch-1
ImagePalette: Add param documentation
2015-09-09 16:52:33 +01:00
Andrew Murray
c6b13d294f Flake8 fixes 2015-08-25 22:27:18 +10:00
Sandy
93a8e43ddf ImagePalette: Add param documentation 2015-08-20 15:25:08 -04:00
wiredfool
30631902d6 Merge pull request #1231 from radarhere/image_palette
Copy image when saving in GifImagePlugin
2015-06-16 11:49:41 -07:00
Andrew Murray
3c7e37d2d7 Replaced old-style classes 2015-05-27 00:07:21 +10:00
Andrew Murray
b1e8a68df8 When copying Image, copy ImagePalette as well 2015-05-14 09:57:56 +10:00
Andrew Murray
540a225ea0 Removed unnecessary pass lines and commented debugging lines 2015-04-24 16:02:38 +10:00
hugovk
d06735b49e More ImagePalette.py tests and remove unused and uncallable new() 2014-07-21 23:18:46 +03:00
hugovk
751f672058 Call public, non-warning versions internally 2014-07-20 21:08:14 +03:00
hugovk
37691bc1e4 Make _make_linear_lut public and issue deprecation warnings from old private methods 2014-07-20 10:13:26 +03:00
hugovk
3c39a44f6e Make _make_gamma_lut() public 2014-07-19 01:45:57 +03:00
hugovk
17223001df flake8 2014-07-15 18:38:10 +03:00
brightpisces
8755bda4e3 Update ImagePalette.py
According to __init__, using `len(self.mode)` might be better. Tested on my machine.
2014-06-24 16:27:35 +08:00
brightpisces
e9821edd94 Match real palette format in ImagePalette.save() 2014-06-24 15:34:43 +08:00
David Schmidt
93a8bc9bd3 * fix palette handling for converted gifs
* fix gif optimization
* better auto convert paramter for gif save
2014-03-04 21:44:32 -08:00
Stephen Johnson
7881c86bba Document PIL.ImagePalette as best I can 2013-10-13 21:27:07 -07:00
wiredfool
2322619372 fixed deprecation warnings for tostring on array.array 2013-05-23 10:33:27 -07:00
Alex Clark
3020c16eaa Fix imports 2013-03-07 11:20:28 -05:00
Mikhail Korobov
c59c6609f3 Restore fromstring & tostring aliases in 3.x 2013-03-07 15:23:40 +06:00
Brian Crowell
a7e3b2e47b py3k: The big push
There are two main issues fixed with this commit:

* bytes vs. str: All file, image, and palette data are now handled as
  bytes. A new _binary module consolidates the hacks needed to do this
  across Python versions. tostring/fromstring methods have been renamed to
  tobytes/frombytes, but the Python 2.6/2.7 versions alias them to the old
  names for compatibility. Users should move to tobytes/frombytes.

  One other potentially-breaking change is that text data in image files
  (such as tags, comments) are now explicitly handled with a specific
  character encoding in mind. This works well with the Unicode str in
  Python 3, but may trip up old code expecting a straight byte-for-byte
  translation to a Python string. This also required a change to Gohlke's
  tags tests (in Tests/test_file_png.py) to expect Unicode strings from
  the code.

* True div vs. floor div: Many division operations used the "/" operator
  to do floor division, which is now the "//" operator in Python 3. These
  were fixed.

As of this commit, on the first pass, I have one failing test (improper
handling of a slice object in a C module, test_imagepath.py) in Python 3,
and three that that I haven't tried running yet (test_imagegl,
test_imagegrab, and test_imageqt). I also haven't tested anything on
Windows. All but the three skipped tests run flawlessly against Pythons
2.6 and 2.7.
2013-01-10 08:46:56 -06:00
Brian Crowell
31c454b925 py3k: 2to3's "idiom" filter
This is, I guess, a few things the Python devs were just fed up with.

* "while 1" is now "while True"
* Types are compared with isinstance instead of ==
* Sort a list in one go with sorted()

My own twist is to also replace type('') with str, type(()) with tuple,
type([]) with list, type(1) with int, and type(5000.0) with float.
2013-01-10 08:46:53 -06:00
Brian Crowell
dfb1b144d8 py3k: Remove Image types import
For awhile now, str == type("") and so on. So we use the appropriate int,
str, basestring, or tuple type where applicable.
2013-01-10 08:46:49 -06:00
Brian Crowell
83ff0b3b31 py3k: Use relative imports
In py3k, imports are absolute unless using the "from . import" syntax.

This commit also solves a recursive import between Image, ImageColor, and
ImagePalette by delay-importing ImagePalette in Image.

I'm not too keen on this commit because the syntax is ugly. I might go back
and prefer the prettier "from PIL import".
2013-01-10 08:46:48 -06:00
Brian Crowell
fc035814bd py3k: map and filter to list comprehensions
What's really going on is that map() and filter() return iterators in py3k.
I've just gone ahead and turned them all into list comprehensions, because
I find them much easier to read.
2013-01-10 08:46:43 -06:00
Brian Crowell
09f1081c95 py3k: Fix up uses of dictionary views, ranges, and has_key()
y.has_key(x) is gone (use x in y), and keys(), values(), items(), and
range() all return views.

Some iterables needed to be packed into lists, either because the code
expected a list (such as "range(256) * 3") or because the original
collection was being modified (automatic global declarations).

The Tiff ImageFileDictionary is a special case and will be dealt with in
another commit.
2013-01-10 08:46:42 -06:00
Brian Crowell
78575798d7 py3k: Update exception usage to modern syntax 2013-01-10 08:46:33 -06:00
Alex Clark
9a640e3157 Forking PIL 2010-07-30 22:52:47 -04:00