mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-10-31 07:57:27 +03:00 
			
		
		
		
	
						commit
						12028c9789
					
				|  | @ -32,7 +32,7 @@ class TestFileTar(PillowTestCase): | |||
|         tar.close() | ||||
| 
 | ||||
|     def test_contextmanager(self): | ||||
|         with TarIO.TarIO(TEST_TAR_FILE, 'hopper.jpg') as tar: | ||||
|         with TarIO.TarIO(TEST_TAR_FILE, 'hopper.jpg'): | ||||
|             pass | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -429,7 +429,8 @@ class TestFileTiff(PillowTestCase): | |||
|                                        "Tests/images/tiff_adobe_deflate.png") | ||||
| 
 | ||||
|     def test_strip_planar_raw(self): | ||||
|         # gdal_translate -of GTiff -co INTERLEAVE=BAND tiff_strip_raw.tif tiff_strip_planar_raw.tiff | ||||
|         # gdal_translate -of GTiff -co INTERLEAVE=BAND \ | ||||
|         # tiff_strip_raw.tif tiff_strip_planar_raw.tiff | ||||
|         infile = "Tests/images/tiff_strip_planar_raw.tif" | ||||
|         im = Image.open(infile) | ||||
| 
 | ||||
|  | @ -445,7 +446,8 @@ class TestFileTiff(PillowTestCase): | |||
|                                        "Tests/images/tiff_adobe_deflate.png") | ||||
| 
 | ||||
|     def test_tiled_planar_raw(self): | ||||
|         # gdal_translate -of GTiff -co TILED=YES -co BLOCKXSIZE=32 -co BLOCKYSIZE=32 -co INTERLEAVE=BAND \ | ||||
|         # gdal_translate -of GTiff -co TILED=YES -co BLOCKXSIZE=32 \ | ||||
|         # -co BLOCKYSIZE=32 -co INTERLEAVE=BAND \ | ||||
|         # tiff_tiled_raw.tif tiff_tiled_planar_raw.tiff | ||||
|         infile = "Tests/images/tiff_tiled_planar_raw.tif" | ||||
|         im = Image.open(infile) | ||||
|  |  | |||
|  | @ -15,8 +15,10 @@ class TestUnsupportedWebp(PillowTestCase): | |||
|             WebPImagePlugin.SUPPORTED = False | ||||
| 
 | ||||
|         file_path = "Tests/images/hopper.webp" | ||||
|         self.assert_warning(UserWarning, | ||||
|             lambda: self.assertRaises(IOError, Image.open, file_path)) | ||||
|         self.assert_warning( | ||||
|             UserWarning, | ||||
|             lambda: self.assertRaises(IOError, Image.open, file_path) | ||||
|         ) | ||||
| 
 | ||||
|         if HAVE_WEBP: | ||||
|             WebPImagePlugin.SUPPORTED = True | ||||
|  |  | |||
|  | @ -139,7 +139,6 @@ class TestImage(PillowTestCase): | |||
|         # Act/Assert | ||||
|         # Shouldn't cause AttributeError (#774) | ||||
|         self.assertFalse(item is None) | ||||
|         self.assertFalse(item == None) | ||||
|         self.assertFalse(item == num) | ||||
| 
 | ||||
|     def test_expand_x(self): | ||||
|  |  | |||
|  | @ -102,6 +102,7 @@ class TestImagePutPixel(AccessTest): | |||
| 
 | ||||
|         self.assert_image_equal(im1, im2) | ||||
| 
 | ||||
| 
 | ||||
| class TestImageGetPixel(AccessTest): | ||||
|     @staticmethod | ||||
|     def color(mode): | ||||
|  |  | |||
|  | @ -106,7 +106,7 @@ class TestImageFilter(PillowTestCase): | |||
|     def test_consistency_3x3(self): | ||||
|         source = Image.open("Tests/images/hopper.bmp") | ||||
|         reference = Image.open("Tests/images/hopper_emboss.bmp") | ||||
|         kernel = ImageFilter.Kernel((3, 3), | ||||
|         kernel = ImageFilter.Kernel((3, 3),  # noqa: E127 | ||||
|                                     (-1, -1,  0, | ||||
|                                      -1,  0,  1, | ||||
|                                       0,  1,  1), .3) | ||||
|  | @ -122,7 +122,7 @@ class TestImageFilter(PillowTestCase): | |||
|     def test_consistency_5x5(self): | ||||
|         source = Image.open("Tests/images/hopper.bmp") | ||||
|         reference = Image.open("Tests/images/hopper_emboss_more.bmp") | ||||
|         kernel = ImageFilter.Kernel((5, 5), | ||||
|         kernel = ImageFilter.Kernel((5, 5),  # noqa: E127 | ||||
|                                     (-1, -1, -1, -1,  0, | ||||
|                                      -1, -1, -1,  0,  1, | ||||
|                                      -1, -1,  0,  1,  1, | ||||
|  |  | |||
|  | @ -152,7 +152,7 @@ class TestImageTransform(PillowTestCase): | |||
|         ] | ||||
| 
 | ||||
|         # Yeah. Watch some JIT optimize this out. | ||||
|         pattern = None | ||||
|         pattern = None  # noqa: F841 | ||||
| 
 | ||||
|         self.test_mesh() | ||||
| 
 | ||||
|  |  | |||
|  | @ -10,7 +10,7 @@ try: | |||
|     from PIL import ImageCms | ||||
|     from PIL.ImageCms import ImageCmsProfile | ||||
|     ImageCms.core.profile_open | ||||
| except ImportError as v: | ||||
| except ImportError: | ||||
|     # Skipped via setUp() | ||||
|     pass | ||||
| 
 | ||||
|  | @ -294,7 +294,14 @@ class TestImageCms(PillowTestCase): | |||
|             p.blue_primary, | ||||
|             ((0.14306641366715667, 0.06060790921083026, 0.7140960805782015), | ||||
|              (0.15588475410450106, 0.06603820408959558, 0.06060790921083026))) | ||||
|         assert_truncated_tuple_equal(p.chromatic_adaptation, (((1.04791259765625, 0.0229339599609375, -0.050201416015625), (0.02960205078125, 0.9904632568359375, -0.0170745849609375), (-0.009246826171875, 0.0150604248046875, 0.7517852783203125)), ((1.0267159024652783, 0.022470062342089134, 0.0229339599609375), (0.02951378324103937, 0.9875098886387147, 0.9904632568359375), (-0.012205438066465256, 0.01987915407854985, 0.0150604248046875)))) | ||||
|         assert_truncated_tuple_equal( | ||||
|             p.chromatic_adaptation, | ||||
|             (((1.04791259765625, 0.0229339599609375, -0.050201416015625), | ||||
|               (0.02960205078125, 0.9904632568359375, -0.0170745849609375), | ||||
|               (-0.009246826171875, 0.0150604248046875, 0.7517852783203125)), | ||||
|              ((1.0267159024652783, 0.022470062342089134, 0.0229339599609375), | ||||
|               (0.02951378324103937, 0.9875098886387147, 0.9904632568359375), | ||||
|               (-0.012205438066465256, 0.01987915407854985, 0.0150604248046875)))) | ||||
|         self.assertIsNone(p.chromaticity) | ||||
|         self.assertEqual(p.clut, { | ||||
|             0: (False, False, True), | ||||
|  | @ -402,10 +409,10 @@ class TestImageCms(PillowTestCase): | |||
|         def create_test_image(): | ||||
|             # set up test image with something interesting in the tested aux | ||||
|             # channel. | ||||
|             nine_grid_deltas = [ | ||||
|             nine_grid_deltas = [  # noqa: E128 | ||||
|                 (-1, -1), (-1, 0), (-1, 1), | ||||
|                 ( 0, -1), ( 0, 0), ( 0, 1), | ||||
|                 ( 1, -1), ( 1, 0), ( 1, 1), | ||||
|                  (0, -1),  (0, 0),  (0, 1), | ||||
|                  (1, -1),  (1, 0),  (1, 1), | ||||
|             ] | ||||
|             chans = [] | ||||
|             bands = ImageMode.getmode(mode).bands | ||||
|  | @ -421,7 +428,11 @@ class TestImageCms(PillowTestCase): | |||
|                 ) | ||||
|                 channel_data = Image.new(channel_type, channel_pattern.size) | ||||
|                 for delta in nine_grid_deltas: | ||||
|                     channel_data.paste(channel_pattern, tuple(paste_offset[c] + delta[c]*channel_pattern.size[c] for c in range(2))) | ||||
|                     channel_data.paste( | ||||
|                         channel_pattern, | ||||
|                         tuple(paste_offset[c] + delta[c] * channel_pattern.size[c] | ||||
|                               for c in range(2)), | ||||
|                     ) | ||||
|                 chans.append(channel_data) | ||||
|             return Image.merge(mode, chans) | ||||
| 
 | ||||
|  |  | |||
|  | @ -86,7 +86,7 @@ if ImageQt.qt_is_installed: | |||
| 
 | ||||
|             pixmap1 = QtGui.QPixmap.fromImage(qimage) | ||||
| 
 | ||||
|             QHBoxLayout(self) | ||||
|             QHBoxLayout(self)  # hbox | ||||
| 
 | ||||
|             lbl = QLabel(self) | ||||
|             # Segfault in the problem | ||||
|  |  | |||
							
								
								
									
										113
									
								
								docs/conf.py
									
									
									
									
									
								
							
							
						
						
									
										113
									
								
								docs/conf.py
									
									
									
									
									
								
							|  | @ -15,12 +15,16 @@ | |||
| # If extensions (or modules to document with autodoc) are in another directory, | ||||
| # add these directories to sys.path here. If the directory is relative to the | ||||
| # documentation root, use os.path.abspath to make it absolute, like shown here. | ||||
| #sys.path.insert(0, os.path.abspath('.')) | ||||
| # sys.path.insert(0, os.path.abspath('.')) | ||||
| 
 | ||||
| import sphinx_rtd_theme | ||||
| 
 | ||||
| import PIL | ||||
| 
 | ||||
| # -- General configuration ------------------------------------------------ | ||||
| 
 | ||||
| # If your documentation needs a minimal Sphinx version, state it here. | ||||
| #needs_sphinx = '1.0' | ||||
| # needs_sphinx = '1.0' | ||||
| 
 | ||||
| # Add any Sphinx extension module names here, as strings. They can be | ||||
| # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom | ||||
|  | @ -37,7 +41,7 @@ templates_path = ['_templates'] | |||
| source_suffix = '.rst' | ||||
| 
 | ||||
| # The encoding of source files. | ||||
| #source_encoding = 'utf-8-sig' | ||||
| # source_encoding = 'utf-8-sig' | ||||
| 
 | ||||
| # The master toctree document. | ||||
| master_doc = 'index' | ||||
|  | @ -52,7 +56,6 @@ author = u'Fredrik Lundh, Alex Clark and Contributors' | |||
| # built documents. | ||||
| # | ||||
| # The short X.Y version. | ||||
| import PIL | ||||
| version = PIL.__version__ | ||||
| # The full version, including alpha/beta/rc tags. | ||||
| release = PIL.__version__ | ||||
|  | @ -66,9 +69,9 @@ language = None | |||
| 
 | ||||
| # There are two options for replacing |today|: either, you set today to some | ||||
| # non-false value, then it is used: | ||||
| #today = '' | ||||
| # today = '' | ||||
| # Else, today_fmt is used as the format for a strftime call. | ||||
| #today_fmt = '%B %d, %Y' | ||||
| # today_fmt = '%B %d, %Y' | ||||
| 
 | ||||
| # List of patterns, relative to source directory, that match files and | ||||
| # directories to ignore when looking for source files. | ||||
|  | @ -76,27 +79,27 @@ exclude_patterns = ['_build'] | |||
| 
 | ||||
| # The reST default role (used for this markup: `text`) to use for all | ||||
| # documents. | ||||
| #default_role = None | ||||
| # default_role = None | ||||
| 
 | ||||
| # If true, '()' will be appended to :func: etc. cross-reference text. | ||||
| #add_function_parentheses = True | ||||
| # add_function_parentheses = True | ||||
| 
 | ||||
| # If true, the current module name will be prepended to all description | ||||
| # unit titles (such as .. function::). | ||||
| #add_module_names = True | ||||
| # add_module_names = True | ||||
| 
 | ||||
| # If true, sectionauthor and moduleauthor directives will be shown in the | ||||
| # output. They are ignored by default. | ||||
| #show_authors = False | ||||
| # show_authors = False | ||||
| 
 | ||||
| # The name of the Pygments (syntax highlighting) style to use. | ||||
| pygments_style = 'sphinx' | ||||
| 
 | ||||
| # A list of ignored prefixes for module index sorting. | ||||
| #modindex_common_prefix = [] | ||||
| # modindex_common_prefix = [] | ||||
| 
 | ||||
| # If true, keep warnings as "system message" paragraphs in the built documents. | ||||
| #keep_warnings = False | ||||
| # keep_warnings = False | ||||
| 
 | ||||
| # If true, `todo` and `todoList` produce output, else they produce nothing. | ||||
| todo_include_todos = False | ||||
|  | @ -107,33 +110,32 @@ todo_include_todos = False | |||
| # The theme to use for HTML and HTML Help pages.  See the documentation for | ||||
| # a list of builtin themes. | ||||
| 
 | ||||
| import sphinx_rtd_theme | ||||
| html_theme = "sphinx_rtd_theme" | ||||
| html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] | ||||
| 
 | ||||
| # Theme options are theme-specific and customize the look and feel of a theme | ||||
| # further.  For a list of options available for each theme, see the | ||||
| # documentation. | ||||
| #html_theme_options = {} | ||||
| # html_theme_options = {} | ||||
| 
 | ||||
| # Add any paths that contain custom themes here, relative to this directory. | ||||
| #html_theme_path = [] | ||||
| # html_theme_path = [] | ||||
| 
 | ||||
| # The name for this set of Sphinx documents.  If None, it defaults to | ||||
| # "<project> v<release> documentation". | ||||
| #html_title = None | ||||
| # html_title = None | ||||
| 
 | ||||
| # A shorter title for the navigation bar.  Default is the same as html_title. | ||||
| #html_short_title = None | ||||
| # html_short_title = None | ||||
| 
 | ||||
| # The name of an image file (relative to this directory) to place at the top | ||||
| # of the sidebar. | ||||
| #html_logo = None | ||||
| # html_logo = None | ||||
| 
 | ||||
| # The name of an image file (within the static path) to use as favicon of the | ||||
| # docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32 | ||||
| # pixels large. | ||||
| #html_favicon = None | ||||
| # html_favicon = None | ||||
| 
 | ||||
| # Add any paths that contain custom static files (such as style sheets) here, | ||||
| # relative to this directory. They are copied after the builtin static files, | ||||
|  | @ -143,62 +145,62 @@ html_static_path = ['_static'] | |||
| # Add any extra paths that contain custom files (such as robots.txt or | ||||
| # .htaccess) here, relative to this directory. These files are copied | ||||
| # directly to the root of the documentation. | ||||
| #html_extra_path = [] | ||||
| # html_extra_path = [] | ||||
| 
 | ||||
| # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, | ||||
| # using the given strftime format. | ||||
| #html_last_updated_fmt = '%b %d, %Y' | ||||
| # html_last_updated_fmt = '%b %d, %Y' | ||||
| 
 | ||||
| # If true, SmartyPants will be used to convert quotes and dashes to | ||||
| # typographically correct entities. | ||||
| #html_use_smartypants = True | ||||
| # html_use_smartypants = True | ||||
| 
 | ||||
| # Custom sidebar templates, maps document names to template names. | ||||
| #html_sidebars = {} | ||||
| # html_sidebars = {} | ||||
| 
 | ||||
| # Additional templates that should be rendered to pages, maps page names to | ||||
| # template names. | ||||
| #html_additional_pages = {} | ||||
| # html_additional_pages = {} | ||||
| 
 | ||||
| # If false, no module index is generated. | ||||
| #html_domain_indices = True | ||||
| # html_domain_indices = True | ||||
| 
 | ||||
| # If false, no index is generated. | ||||
| #html_use_index = True | ||||
| # html_use_index = True | ||||
| 
 | ||||
| # If true, the index is split into individual pages for each letter. | ||||
| #html_split_index = False | ||||
| # html_split_index = False | ||||
| 
 | ||||
| # If true, links to the reST sources are added to the pages. | ||||
| #html_show_sourcelink = True | ||||
| # html_show_sourcelink = True | ||||
| 
 | ||||
| # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. | ||||
| #html_show_sphinx = True | ||||
| # html_show_sphinx = True | ||||
| 
 | ||||
| # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. | ||||
| #html_show_copyright = True | ||||
| # html_show_copyright = True | ||||
| 
 | ||||
| # If true, an OpenSearch description file will be output, and all pages will | ||||
| # contain a <link> tag referring to it.  The value of this option must be the | ||||
| # base URL from which the finished HTML is served. | ||||
| #html_use_opensearch = '' | ||||
| # html_use_opensearch = '' | ||||
| 
 | ||||
| # This is the file name suffix for HTML files (e.g. ".xhtml"). | ||||
| #html_file_suffix = None | ||||
| # html_file_suffix = None | ||||
| 
 | ||||
| # Language to be used for generating the HTML full-text search index. | ||||
| # Sphinx supports the following languages: | ||||
| #   'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' | ||||
| #   'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' | ||||
| #html_search_language = 'en' | ||||
| # html_search_language = 'en' | ||||
| 
 | ||||
| # A dictionary with options for the search language support, empty by default. | ||||
| # Now only 'ja' uses this config value | ||||
| #html_search_options = {'type': 'default'} | ||||
| # html_search_options = {'type': 'default'} | ||||
| 
 | ||||
| # The name of a javascript file (relative to the configuration directory) that | ||||
| # implements a search results scorer. If empty, the default will be used. | ||||
| #html_search_scorer = 'scorer.js' | ||||
| # html_search_scorer = 'scorer.js' | ||||
| 
 | ||||
| # Output file base name for HTML help builder. | ||||
| htmlhelp_basename = 'PillowPILForkdoc' | ||||
|  | @ -206,17 +208,17 @@ htmlhelp_basename = 'PillowPILForkdoc' | |||
| # -- Options for LaTeX output --------------------------------------------- | ||||
| 
 | ||||
| latex_elements = { | ||||
| # The paper size ('letterpaper' or 'a4paper'). | ||||
| #'papersize': 'letterpaper', | ||||
|     # The paper size ('letterpaper' or 'a4paper'). | ||||
|     # 'papersize': 'letterpaper', | ||||
| 
 | ||||
| # The font size ('10pt', '11pt' or '12pt'). | ||||
| #'pointsize': '10pt', | ||||
|     # The font size ('10pt', '11pt' or '12pt'). | ||||
|     # 'pointsize': '10pt', | ||||
| 
 | ||||
| # Additional stuff for the LaTeX preamble. | ||||
| #'preamble': '', | ||||
|     # Additional stuff for the LaTeX preamble. | ||||
|     # 'preamble': '', | ||||
| 
 | ||||
| # Latex figure (float) alignment | ||||
| #'figure_align': 'htbp', | ||||
|     # Latex figure (float) alignment | ||||
|     # 'figure_align': 'htbp', | ||||
| } | ||||
| 
 | ||||
| # Grouping the document tree into LaTeX files. List of tuples | ||||
|  | @ -229,23 +231,23 @@ latex_documents = [ | |||
| 
 | ||||
| # The name of an image file (relative to this directory) to place at the top of | ||||
| # the title page. | ||||
| #latex_logo = None | ||||
| # latex_logo = None | ||||
| 
 | ||||
| # For "manual" documents, if this is true, then toplevel headings are parts, | ||||
| # not chapters. | ||||
| #latex_use_parts = False | ||||
| # latex_use_parts = False | ||||
| 
 | ||||
| # If true, show page references after internal links. | ||||
| #latex_show_pagerefs = False | ||||
| # latex_show_pagerefs = False | ||||
| 
 | ||||
| # If true, show URL addresses after external links. | ||||
| #latex_show_urls = False | ||||
| # latex_show_urls = False | ||||
| 
 | ||||
| # Documents to append as an appendix to all manuals. | ||||
| #latex_appendices = [] | ||||
| # latex_appendices = [] | ||||
| 
 | ||||
| # If false, no module index is generated. | ||||
| #latex_domain_indices = True | ||||
| # latex_domain_indices = True | ||||
| 
 | ||||
| 
 | ||||
| # -- Options for manual page output --------------------------------------- | ||||
|  | @ -258,7 +260,7 @@ man_pages = [ | |||
| ] | ||||
| 
 | ||||
| # If true, show URL addresses after external links. | ||||
| #man_show_urls = False | ||||
| # man_show_urls = False | ||||
| 
 | ||||
| 
 | ||||
| # -- Options for Texinfo output ------------------------------------------- | ||||
|  | @ -268,18 +270,19 @@ man_pages = [ | |||
| #  dir menu entry, description, category) | ||||
| texinfo_documents = [ | ||||
|   (master_doc, 'PillowPILFork', u'Pillow (PIL Fork) Documentation', | ||||
|    author, 'PillowPILFork', 'Pillow is the friendly PIL fork by Alex Clark and Contributors.', | ||||
|    author, 'PillowPILFork', | ||||
|    'Pillow is the friendly PIL fork by Alex Clark and Contributors.', | ||||
|    'Miscellaneous'), | ||||
| ] | ||||
| 
 | ||||
| # Documents to append as an appendix to all manuals. | ||||
| #texinfo_appendices = [] | ||||
| # texinfo_appendices = [] | ||||
| 
 | ||||
| # If false, no module index is generated. | ||||
| #texinfo_domain_indices = True | ||||
| # texinfo_domain_indices = True | ||||
| 
 | ||||
| # How to display URL addresses: 'footnote', 'no', or 'inline'. | ||||
| #texinfo_show_urls = 'footnote' | ||||
| # texinfo_show_urls = 'footnote' | ||||
| 
 | ||||
| # If true, do not generate a @detailmenu in the "Top" node's menu. | ||||
| #texinfo_no_detailmenu = False | ||||
| # texinfo_no_detailmenu = False | ||||
|  |  | |||
|  | @ -225,7 +225,7 @@ class DdsImageFile(ImageFile.ImageFile): | |||
|         self.mode = "RGBA" | ||||
| 
 | ||||
|         pitch, depth, mipmaps = struct.unpack("<3I", header.read(12)) | ||||
|         reserved = struct.unpack("<11I", header.read(44)) | ||||
|         struct.unpack("<11I", header.read(44))  # reserved | ||||
| 
 | ||||
|         # pixel format | ||||
|         pfsize, pfflags = struct.unpack("<2I", header.read(8)) | ||||
|  | @ -235,10 +235,8 @@ class DdsImageFile(ImageFile.ImageFile): | |||
| 
 | ||||
|         if fourcc == b"DXT1": | ||||
|             self.decoder = "DXT1" | ||||
|             codec = _dxt1 | ||||
|         elif fourcc == b"DXT5": | ||||
|             self.decoder = "DXT5" | ||||
|             codec = _dxt5 | ||||
|         else: | ||||
|             raise NotImplementedError("Unimplemented pixel format %r" % fourcc) | ||||
| 
 | ||||
|  |  | |||
|  | @ -5,7 +5,7 @@ from __future__ import print_function | |||
| import sys | ||||
| import os | ||||
| 
 | ||||
| from PIL import Image, ImageDraw, ImageFilter, ImageMath | ||||
| from PIL import Image | ||||
| from PIL import features | ||||
| 
 | ||||
| try: | ||||
|  | @ -26,6 +26,7 @@ def testimage(): | |||
|     """ | ||||
|     PIL lets you create in-memory images with various pixel types: | ||||
| 
 | ||||
|     >>> from PIL import Image, ImageDraw, ImageFilter, ImageMath | ||||
|     >>> im = Image.new("1", (128, 128)) # monochrome | ||||
|     >>> _info(im) | ||||
|     (None, '1', (128, 128)) | ||||
|  |  | |||
|  | @ -50,16 +50,17 @@ def _accept(prefix): | |||
|     return prefix[:2] == b"BM" | ||||
| 
 | ||||
| 
 | ||||
| # ============================================================================== | ||||
| # ============================================================================= | ||||
| # Image plugin for the Windows BMP format. | ||||
| # ============================================================================== | ||||
| # ============================================================================= | ||||
| class BmpImageFile(ImageFile.ImageFile): | ||||
|     """ Image plugin for the Windows Bitmap format (BMP) """ | ||||
| 
 | ||||
|     # -------------------------------------------------------------- Description | ||||
|     # ------------------------------------------------------------- Description | ||||
|     format_description = "Windows Bitmap" | ||||
|     format = "BMP" | ||||
|     # --------------------------------------------------- BMP Compression values | ||||
| 
 | ||||
|     # -------------------------------------------------- BMP Compression values | ||||
|     COMPRESSIONS = { | ||||
|         'RAW': 0, | ||||
|         'RLE8': 1, | ||||
|  | @ -79,12 +80,14 @@ class BmpImageFile(ImageFile.ImageFile): | |||
|         # read bmp header size @offset 14 (this is part of the header size) | ||||
|         file_info['header_size'] = i32(read(4)) | ||||
|         file_info['direction'] = -1 | ||||
|         # --------------------- If requested, read header at a specific position | ||||
| 
 | ||||
|         # -------------------- If requested, read header at a specific position | ||||
|         # read the rest of the bmp header, without its size | ||||
|         header_data = ImageFile._safe_read(self.fp, | ||||
|                                            file_info['header_size'] - 4) | ||||
|         # --------------------------------------------------- IBM OS/2 Bitmap v1 | ||||
|         # ------ This format has different offsets because of width/height types | ||||
| 
 | ||||
|         # -------------------------------------------------- IBM OS/2 Bitmap v1 | ||||
|         # ----- This format has different offsets because of width/height types | ||||
|         if file_info['header_size'] == 12: | ||||
|             file_info['width'] = i16(header_data[0:2]) | ||||
|             file_info['height'] = i16(header_data[2:4]) | ||||
|  | @ -92,8 +95,10 @@ class BmpImageFile(ImageFile.ImageFile): | |||
|             file_info['bits'] = i16(header_data[6:8]) | ||||
|             file_info['compression'] = self.RAW | ||||
|             file_info['palette_padding'] = 3 | ||||
|         # ---------------------------------------------- Windows Bitmap v2 to v5 | ||||
|         elif file_info['header_size'] in (40, 64, 108, 124):  # v3, OS/2 v2, v4, v5 | ||||
| 
 | ||||
|         # --------------------------------------------- Windows Bitmap v2 to v5 | ||||
|         # v3, OS/2 v2, v4, v5 | ||||
|         elif file_info['header_size'] in (40, 64, 108, 124): | ||||
|             if file_info['header_size'] >= 40:  # v3 and OS/2 | ||||
|                 file_info['y_flip'] = i8(header_data[7]) == 0xff | ||||
|                 file_info['direction'] = 1 if file_info['y_flip'] else -1 | ||||
|  | @ -119,12 +124,15 @@ class BmpImageFile(ImageFile.ImageFile): | |||
|                                                     'g_mask', | ||||
|                                                     'b_mask', | ||||
|                                                     'a_mask']): | ||||
|                             file_info[mask] = i32(header_data[36+idx*4:40+idx*4]) | ||||
|                             file_info[mask] = i32( | ||||
|                                 header_data[36 + idx * 4:40 + idx * 4] | ||||
|                             ) | ||||
|                     else: | ||||
|                         # 40 byte headers only have the three components in the | ||||
|                         # bitfields masks, | ||||
|                         # ref: https://msdn.microsoft.com/en-us/library/windows/desktop/dd183376(v=vs.85).aspx | ||||
|                         # See also https://github.com/python-pillow/Pillow/issues/1293 | ||||
|                         # bitfields masks, ref: | ||||
|                         # https://msdn.microsoft.com/en-us/library/windows/desktop/dd183376(v=vs.85).aspx | ||||
|                         # See also | ||||
|                         # https://github.com/python-pillow/Pillow/issues/1293 | ||||
|                         # There is a 4th component in the RGBQuad, in the alpha | ||||
|                         # location, but it is listed as a reserved component, | ||||
|                         # and it is not generally an alpha channel | ||||
|  | @ -141,20 +149,27 @@ class BmpImageFile(ImageFile.ImageFile): | |||
|         else: | ||||
|             raise IOError("Unsupported BMP header type (%d)" % | ||||
|                           file_info['header_size']) | ||||
| 
 | ||||
|         # ------------------ Special case : header is reported 40, which | ||||
|         # ---------------------- is shorter than real size for bpp >= 16 | ||||
|         self._size = file_info['width'], file_info['height'] | ||||
|         # -------- If color count was not found in the header, compute from bits | ||||
|         file_info['colors'] = file_info['colors'] if file_info.get('colors', 0) else (1 << file_info['bits']) | ||||
|         # -------------------------------- Check abnormal values for DOS attacks | ||||
| 
 | ||||
|         # ------- If color count was not found in the header, compute from bits | ||||
|         file_info["colors"] = (file_info["colors"] | ||||
|                                if file_info.get("colors", 0) | ||||
|                                else (1 << file_info["bits"])) | ||||
| 
 | ||||
|         # ------------------------------- Check abnormal values for DOS attacks | ||||
|         if file_info['width'] * file_info['height'] > 2**31: | ||||
|             raise IOError("Unsupported BMP Size: (%dx%d)" % self.size) | ||||
|         # ----------------------- Check bit depth for unusual unsupported values | ||||
| 
 | ||||
|         # ---------------------- Check bit depth for unusual unsupported values | ||||
|         self.mode, raw_mode = BIT2MODE.get(file_info['bits'], (None, None)) | ||||
|         if self.mode is None: | ||||
|             raise IOError("Unsupported BMP pixel depth (%d)" | ||||
|                           % file_info['bits']) | ||||
|         # ----------------- Process BMP with Bitfields compression (not palette) | ||||
| 
 | ||||
|         # ---------------- Process BMP with Bitfields compression (not palette) | ||||
|         if file_info['compression'] == self.BITFIELDS: | ||||
|             SUPPORTED = { | ||||
|                 32: [(0xff0000, 0xff00, 0xff, 0x0), | ||||
|  | @ -176,7 +191,9 @@ class BmpImageFile(ImageFile.ImageFile): | |||
|             if file_info['bits'] in SUPPORTED: | ||||
|                 if file_info['bits'] == 32 and \ | ||||
|                    file_info['rgba_mask'] in SUPPORTED[file_info['bits']]: | ||||
|                     raw_mode = MASK_MODES[(file_info['bits'], file_info['rgba_mask'])] | ||||
|                     raw_mode = MASK_MODES[ | ||||
|                         (file_info["bits"], file_info["rgba_mask"]) | ||||
|                     ] | ||||
|                     self.mode = "RGBA" if raw_mode in ("BGRA",) else self.mode | ||||
|                 elif (file_info['bits'] in (24, 16) and | ||||
|                       file_info['rgb_mask'] in SUPPORTED[file_info['bits']]): | ||||
|  | @ -193,9 +210,11 @@ class BmpImageFile(ImageFile.ImageFile): | |||
|         else: | ||||
|             raise IOError("Unsupported BMP compression (%d)" % | ||||
|                           file_info['compression']) | ||||
|         # ---------------- Once the header is processed, process the palette/LUT | ||||
| 
 | ||||
|         # --------------- Once the header is processed, process the palette/LUT | ||||
|         if self.mode == "P":  # Paletted for 1, 4 and 8 bit images | ||||
|             # ----------------------------------------------------- 1-bit images | ||||
| 
 | ||||
|             # ---------------------------------------------------- 1-bit images | ||||
|             if not (0 < file_info['colors'] <= 65536): | ||||
|                 raise IOError("Unsupported BMP Palette size (%d)" % | ||||
|                               file_info['colors']) | ||||
|  | @ -205,12 +224,14 @@ class BmpImageFile(ImageFile.ImageFile): | |||
|                 greyscale = True | ||||
|                 indices = (0, 255) if file_info['colors'] == 2 else \ | ||||
|                     list(range(file_info['colors'])) | ||||
|                 # ------------------ Check if greyscale and ignore palette if so | ||||
| 
 | ||||
|                 # ----------------- Check if greyscale and ignore palette if so | ||||
|                 for ind, val in enumerate(indices): | ||||
|                     rgb = palette[ind*padding:ind*padding + 3] | ||||
|                     if rgb != o8(val) * 3: | ||||
|                         greyscale = False | ||||
|                 # -------- If all colors are grey, white or black, ditch palette | ||||
| 
 | ||||
|                 # ------- If all colors are grey, white or black, ditch palette | ||||
|                 if greyscale: | ||||
|                     self.mode = "1" if file_info['colors'] == 2 else "L" | ||||
|                     raw_mode = self.mode | ||||
|  | @ -219,7 +240,7 @@ class BmpImageFile(ImageFile.ImageFile): | |||
|                     self.palette = ImagePalette.raw( | ||||
|                         "BGRX" if padding == 4 else "BGR", palette) | ||||
| 
 | ||||
|         # ----------------------------- Finally set the tile data for the plugin | ||||
|         # ---------------------------- Finally set the tile data for the plugin | ||||
|         self.info['compression'] = file_info['compression'] | ||||
|         self.tile = [ | ||||
|             ('raw', | ||||
|  | @ -243,9 +264,9 @@ class BmpImageFile(ImageFile.ImageFile): | |||
|         self._bitmap(offset=offset) | ||||
| 
 | ||||
| 
 | ||||
| # ============================================================================== | ||||
| # ============================================================================= | ||||
| # Image plugin for the DIB format (BMP alias) | ||||
| # ============================================================================== | ||||
| # ============================================================================= | ||||
| class DibImageFile(BmpImageFile): | ||||
| 
 | ||||
|     format = "DIB" | ||||
|  |  | |||
|  | @ -118,7 +118,7 @@ class DdsImageFile(ImageFile.ImageFile): | |||
|         self.mode = "RGBA" | ||||
| 
 | ||||
|         pitch, depth, mipmaps = struct.unpack("<3I", header.read(12)) | ||||
|         reserved = struct.unpack("<11I", header.read(44)) | ||||
|         struct.unpack("<11I", header.read(44))  # reserved | ||||
| 
 | ||||
|         # pixel format | ||||
|         pfsize, pfflags = struct.unpack("<2I", header.read(8)) | ||||
|  |  | |||
|  | @ -125,10 +125,11 @@ def Ghostscript(tile, size, fp, scale=1): | |||
|                "-dSAFER",                    # safe mode | ||||
|                "-sDEVICE=ppmraw",            # ppm driver | ||||
|                "-sOutputFile=%s" % outfile,  # output file | ||||
|                # adjust for image origin | ||||
|                "-c", "%d %d translate" % (-bbox[0], -bbox[1]), | ||||
|                                              # adjust for image origin | ||||
|                "-f", infile,                 # input file | ||||
|                "-c", "showpage",             # showpage (see: https://bugs.ghostscript.com/show_bug.cgi?id=698272) | ||||
|                # showpage (see https://bugs.ghostscript.com/show_bug.cgi?id=698272) | ||||
|                "-c", "showpage", | ||||
|                ] | ||||
| 
 | ||||
|     if gs_windows_binary is not None: | ||||
|  |  | |||
|  | @ -66,8 +66,8 @@ class FtexImageFile(ImageFile.ImageFile): | |||
|     format_description = "Texture File Format (IW2:EOC)" | ||||
| 
 | ||||
|     def _open(self): | ||||
|         magic = struct.unpack("<I", self.fp.read(4)) | ||||
|         version = struct.unpack("<i", self.fp.read(4)) | ||||
|         struct.unpack("<I", self.fp.read(4))  # magic | ||||
|         struct.unpack("<i", self.fp.read(4))  # version | ||||
|         self._size = struct.unpack("<2i", self.fp.read(8)) | ||||
|         mipmap_count, format_count = struct.unpack("<2i", self.fp.read(8)) | ||||
| 
 | ||||
|  |  | |||
|  | @ -59,7 +59,8 @@ class GdImageFile(ImageFile.ImageFile): | |||
|         if tindex < 256: | ||||
|             self.info["transparency"] = tindex | ||||
| 
 | ||||
|         self.palette = ImagePalette.raw("XBGR", s[7+trueColorOffset+4:7+trueColorOffset+4+256*4]) | ||||
|         self.palette = ImagePalette.raw( | ||||
|             "XBGR", s[7+trueColorOffset+4:7+trueColorOffset+4+256*4]) | ||||
| 
 | ||||
|         self.tile = [("raw", (0, 0)+self.size, 7+trueColorOffset+4+256*4, | ||||
|                       ("L", 0, 1))] | ||||
|  |  | |||
|  | @ -153,7 +153,7 @@ class ImImageFile(ImageFile.ImageFile): | |||
| 
 | ||||
|             try: | ||||
|                 m = split.match(s) | ||||
|             except re.error as v: | ||||
|             except re.error: | ||||
|                 raise SyntaxError("not an IM file") | ||||
| 
 | ||||
|             if m: | ||||
|  |  | |||
|  | @ -34,6 +34,36 @@ import logging | |||
| import warnings | ||||
| import math | ||||
| 
 | ||||
| try: | ||||
|     import builtins | ||||
| except ImportError: | ||||
|     import __builtin__ | ||||
|     builtins = __builtin__ | ||||
| 
 | ||||
| from . import ImageMode | ||||
| from ._binary import i8 | ||||
| from ._util import isPath, isStringType, deferred_error | ||||
| 
 | ||||
| import os | ||||
| import sys | ||||
| import io | ||||
| import struct | ||||
| import atexit | ||||
| 
 | ||||
| # type stuff | ||||
| import numbers | ||||
| try: | ||||
|     # Python 3 | ||||
|     from collections.abc import Callable | ||||
| except ImportError: | ||||
|     # Python 2.7 | ||||
|     from collections import Callable | ||||
| 
 | ||||
| 
 | ||||
| # Silence warnings | ||||
| assert VERSION | ||||
| assert PILLOW_VERSION | ||||
| 
 | ||||
| logger = logging.getLogger(__name__) | ||||
| 
 | ||||
| 
 | ||||
|  | @ -104,39 +134,13 @@ except ImportError as v: | |||
|     # see docs/porting.rst | ||||
|     raise | ||||
| 
 | ||||
| try: | ||||
|     import builtins | ||||
| except ImportError: | ||||
|     import __builtin__ | ||||
|     builtins = __builtin__ | ||||
| 
 | ||||
| from . import ImageMode | ||||
| from ._binary import i8 | ||||
| from ._util import isPath, isStringType, deferred_error | ||||
| 
 | ||||
| import os | ||||
| import sys | ||||
| import io | ||||
| import struct | ||||
| import atexit | ||||
| 
 | ||||
| # type stuff | ||||
| import numbers | ||||
| try: | ||||
|     # Python 3 | ||||
|     from collections.abc import Callable | ||||
| except ImportError: | ||||
|     # Python 2.7 | ||||
|     from collections import Callable | ||||
| 
 | ||||
| 
 | ||||
| # works everywhere, win for pypy, not cpython | ||||
| USE_CFFI_ACCESS = hasattr(sys, 'pypy_version_info') | ||||
| try: | ||||
|     import cffi | ||||
|     HAS_CFFI = True | ||||
| except ImportError: | ||||
|     HAS_CFFI = False | ||||
|     cffi = None | ||||
| 
 | ||||
| try: | ||||
|     from pathlib import Path | ||||
|  | @ -376,26 +380,32 @@ def preinit(): | |||
| 
 | ||||
|     try: | ||||
|         from . import BmpImagePlugin | ||||
|         assert BmpImagePlugin | ||||
|     except ImportError: | ||||
|         pass | ||||
|     try: | ||||
|         from . import GifImagePlugin | ||||
|         assert GifImagePlugin | ||||
|     except ImportError: | ||||
|         pass | ||||
|     try: | ||||
|         from . import JpegImagePlugin | ||||
|         assert JpegImagePlugin | ||||
|     except ImportError: | ||||
|         pass | ||||
|     try: | ||||
|         from . import PpmImagePlugin | ||||
|         assert PpmImagePlugin | ||||
|     except ImportError: | ||||
|         pass | ||||
|     try: | ||||
|         from . import PngImagePlugin | ||||
|         assert PngImagePlugin | ||||
|     except ImportError: | ||||
|         pass | ||||
| #   try: | ||||
| #       import TiffImagePlugin | ||||
| #       assert TiffImagePlugin | ||||
| #   except ImportError: | ||||
| #       pass | ||||
| 
 | ||||
|  | @ -833,7 +843,7 @@ class Image(object): | |||
|                 self.palette.mode = "RGBA" | ||||
| 
 | ||||
|         if self.im: | ||||
|             if HAS_CFFI and USE_CFFI_ACCESS: | ||||
|             if cffi and USE_CFFI_ACCESS: | ||||
|                 if self.pyaccess: | ||||
|                     return self.pyaccess | ||||
|                 from . import PyAccess | ||||
|  |  | |||
|  | @ -727,7 +727,7 @@ def getProfileInfo(profile): | |||
|         # add an extra newline to preserve pyCMS compatibility | ||||
|         # Python, not C. the white point bits weren't working well, | ||||
|         # so skipping. | ||||
|         #    // info was description \r\n\r\n copyright \r\n\r\n K007 tag \r\n\r\n whitepoint | ||||
|         # info was description \r\n\r\n copyright \r\n\r\n K007 tag \r\n\r\n whitepoint | ||||
|         description = profile.profile.product_description | ||||
|         cpright = profile.profile.product_copyright | ||||
|         arr = [] | ||||
|  |  | |||
|  | @ -87,7 +87,10 @@ def getrgb(color): | |||
|             int((int(m.group(3)) * 255) / 100.0 + 0.5) | ||||
|             ) | ||||
| 
 | ||||
|     m = re.match(r"hsl\(\s*(\d+\.?\d*)\s*,\s*(\d+\.?\d*)%\s*,\s*(\d+\.?\d*)%\s*\)$", color) | ||||
|     m = re.match( | ||||
|         r"hsl\(\s*(\d+\.?\d*)\s*,\s*(\d+\.?\d*)%\s*,\s*(\d+\.?\d*)%\s*\)$", | ||||
|         color, | ||||
|     ) | ||||
|     if m: | ||||
|         from colorsys import hls_to_rgb | ||||
|         rgb = hls_to_rgb( | ||||
|  | @ -101,7 +104,10 @@ def getrgb(color): | |||
|             int(rgb[2] * 255 + 0.5) | ||||
|             ) | ||||
| 
 | ||||
|     m = re.match(r"hs[bv]\(\s*(\d+\.?\d*)\s*,\s*(\d+\.?\d*)%\s*,\s*(\d+\.?\d*)%\s*\)$", color) | ||||
|     m = re.match( | ||||
|         r"hs[bv]\(\s*(\d+\.?\d*)\s*,\s*(\d+\.?\d*)%\s*,\s*(\d+\.?\d*)%\s*\)$", | ||||
|         color, | ||||
|     ) | ||||
|     if m: | ||||
|         from colorsys import hsv_to_rgb | ||||
|         rgb = hsv_to_rgb( | ||||
|  |  | |||
|  | @ -54,7 +54,8 @@ def grabclipboard(): | |||
|         fh, filepath = tempfile.mkstemp('.jpg') | ||||
|         os.close(fh) | ||||
|         commands = [ | ||||
|             "set theFile to (open for access POSIX file \""+filepath+"\" with write permission)", | ||||
|             "set theFile to (open for access POSIX file \"" | ||||
|             + filepath + "\" with write permission)", | ||||
|             "try", | ||||
|             "    write (the clipboard as JPEG picture) to theFile", | ||||
|             "end try", | ||||
|  |  | |||
|  | @ -26,15 +26,15 @@ | |||
| # | ||||
| 
 | ||||
| import sys | ||||
| from io import BytesIO | ||||
| 
 | ||||
| from . import Image | ||||
| 
 | ||||
| if sys.version_info.major > 2: | ||||
|     import tkinter | ||||
| else: | ||||
|     import Tkinter as tkinter | ||||
| 
 | ||||
| from . import Image | ||||
| from io import BytesIO | ||||
| 
 | ||||
| 
 | ||||
| # -------------------------------------------------------------------- | ||||
| # Check for Tkinter interface hooks | ||||
|  |  | |||
|  | @ -578,7 +578,7 @@ RAWMODE = { | |||
|     "YCbCr": "YCbCr", | ||||
| } | ||||
| 
 | ||||
| zigzag_index = (0,  1,  5,  6, 14, 15, 27, 28, | ||||
| zigzag_index = (0,  1,  5,  6, 14, 15, 27, 28,  # noqa: E128 | ||||
|                 2,  4,  7, 13, 16, 26, 29, 42, | ||||
|                 3,  8, 12, 17, 25, 30, 41, 43, | ||||
|                 9, 11, 18, 24, 31, 40, 44, 53, | ||||
|  |  | |||
|  | @ -62,11 +62,12 @@ The tables format between im.quantization and quantization in presets differ in | |||
| You can convert the dict format to the preset format with the | ||||
| `JpegImagePlugin.convert_dict_qtables(dict_qtables)` function. | ||||
| 
 | ||||
| Libjpeg ref.: https://web.archive.org/web/20120328125543/http://www.jpegcameras.com/libjpeg/libjpeg-3.html | ||||
| Libjpeg ref.: | ||||
| https://web.archive.org/web/20120328125543/http://www.jpegcameras.com/libjpeg/libjpeg-3.html | ||||
| 
 | ||||
| """ | ||||
| 
 | ||||
| presets = { | ||||
| presets = {  # noqa: E128 | ||||
|             'web_low':      {'subsampling':  2,  # "4:2:0" | ||||
|                              'quantization': [ | ||||
|                                [20, 16, 25, 39, 50, 46, 62, 68, | ||||
|  |  | |||
|  | @ -12,7 +12,7 @@ from ._binary import o8, o16be as o16b | |||
| 
 | ||||
| __version__ = "1.0" | ||||
| 
 | ||||
| _Palm8BitColormapValues = ( | ||||
| _Palm8BitColormapValues = (  # noqa: E131 | ||||
|     (255, 255, 255), (255, 204, 255), (255, 153, 255), (255, 102, 255), | ||||
|     (255,  51, 255), (255,   0, 255), (255, 255, 204), (255, 204, 204), | ||||
|     (255, 153, 204), (255, 102, 204), (255,  51, 204), (255,   0, 204), | ||||
|  |  | |||
|  | @ -230,7 +230,7 @@ class PcfFontFile(FontFile.FontFile): | |||
|         firstCol, lastCol = i16(fp.read(2)), i16(fp.read(2)) | ||||
|         firstRow, lastRow = i16(fp.read(2)), i16(fp.read(2)) | ||||
| 
 | ||||
|         default = i16(fp.read(2)) | ||||
|         i16(fp.read(2))  # default | ||||
| 
 | ||||
|         nencoding = (lastCol - firstCol + 1) * (lastRow - firstRow + 1) | ||||
| 
 | ||||
|  |  | |||
|  | @ -386,7 +386,8 @@ def pdf_repr(x): | |||
| 
 | ||||
| 
 | ||||
| class PdfParser: | ||||
|     """Based on https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf | ||||
|     """Based on | ||||
|     https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf | ||||
|     Supports PDF up to 1.4 | ||||
|     """ | ||||
| 
 | ||||
|  | @ -863,7 +864,8 @@ class PdfParser: | |||
|         raise PdfFormatError( | ||||
|             "unrecognized object: " + repr(data[offset:offset+32])) | ||||
| 
 | ||||
|     re_lit_str_token = re.compile(br"(\\[nrtbf()\\])|(\\[0-9]{1,3})|(\\(\r\n|\r|\n))|(\r\n|\r|\n)|(\()|(\))") | ||||
|     re_lit_str_token = re.compile( | ||||
|         br"(\\[nrtbf()\\])|(\\[0-9]{1,3})|(\\(\r\n|\r|\n))|(\r\n|\r|\n)|(\()|(\))") | ||||
|     escaped_chars = { | ||||
|         b"n": b"\n", | ||||
|         b"r": b"\r", | ||||
|  |  | |||
|  | @ -92,7 +92,7 @@ class PsdImageFile(ImageFile.ImageFile): | |||
|             # load resources | ||||
|             end = self.fp.tell() + size | ||||
|             while self.fp.tell() < end: | ||||
|                 signature = read(4) | ||||
|                 read(4)  # signature | ||||
|                 id = i16(read(2)) | ||||
|                 name = read(i8(read(1))) | ||||
|                 if not (len(name) & 1): | ||||
|  | @ -207,17 +207,13 @@ def _layerinfo(file): | |||
|             mode = None  # unknown | ||||
| 
 | ||||
|         # skip over blend flags and extra information | ||||
|         filler = read(12) | ||||
|         read(12)  # filler | ||||
|         name = "" | ||||
|         size = i32(read(4)) | ||||
|         combined = 0 | ||||
|         if size: | ||||
|             length = i32(read(4)) | ||||
|             if length: | ||||
|                 mask_y = i32(read(4)) | ||||
|                 mask_x = i32(read(4)) | ||||
|                 mask_h = i32(read(4)) - mask_y | ||||
|                 mask_w = i32(read(4)) - mask_x | ||||
|                 file.seek(length - 16, 1) | ||||
|             combined += length + 4 | ||||
| 
 | ||||
|  |  | |||
|  | @ -2,7 +2,7 @@ from . import Image, ImageFile | |||
| try: | ||||
|     from . import _webp | ||||
|     SUPPORTED = True | ||||
| except ImportError as e: | ||||
| except ImportError: | ||||
|     SUPPORTED = False | ||||
| from io import BytesIO | ||||
| 
 | ||||
|  |  | |||
|  | @ -74,7 +74,7 @@ call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %s"" | |||
| 
 | ||||
| 
 | ||||
| def build_one(py_ver, compiler, bit): | ||||
|     # UNDONE virtual envs if we're not running on appveyor | ||||
|     # UNDONE virtual envs if we're not running on AppVeyor | ||||
|     args = {} | ||||
|     args.update(compiler) | ||||
|     if 'PYTHON' in os.environ: | ||||
|  | @ -97,6 +97,8 @@ def build_one(py_ver, compiler, bit): | |||
|     else: | ||||
|         args['imaging_libs'] = '' | ||||
| 
 | ||||
|     args['vc_setup'] = vc_setup(compiler, bit) | ||||
| 
 | ||||
|     script = r""" | ||||
| setlocal EnableDelayedExpansion | ||||
| call "%%ProgramFiles%%\Microsoft SDKs\Windows\%(env_version)s\Bin\SetEnv.Cmd" /Release %(env_flags)s | ||||
|  | @ -105,7 +107,7 @@ set LIB=%%LIB%%;%%INCLIB%%\%(inc_dir)s | |||
| set INCLUDE=%%INCLUDE%%;%%INCLIB%%\%(inc_dir)s;%%INCLIB%%\tcl%(tcl_ver)s\include | ||||
| 
 | ||||
| setlocal | ||||
| set LIB=%%LIB%%;C:\Python%(py_ver)s\tcl""" + vc_setup(compiler, bit) + r""" | ||||
| set LIB=%%LIB%%;C:\Python%(py_ver)s\tcl%(vc_setup)s | ||||
| call %(python_path)s\%(executable)s setup.py %(imaging_libs)s %%BLDOPT%% | ||||
| endlocal | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user