mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 01:47:47 +03:00 
			
		
		
		
	Do not use CCITTFaxDecode filter if libtiff is not available
This commit is contained in:
		
							parent
							
								
									4c59f77e37
								
							
						
					
					
						commit
						3b4ea7c602
					
				| 
						 | 
					@ -6,7 +6,7 @@ import time
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import pytest
 | 
					import pytest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from PIL import Image, PdfParser
 | 
					from PIL import Image, PdfParser, features
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from .helper import hopper, mark_if_feature_version
 | 
					from .helper import hopper, mark_if_feature_version
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -43,7 +43,7 @@ def test_monochrome(tmp_path):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Act / Assert
 | 
					    # Act / Assert
 | 
				
			||||||
    outfile = helper_save_as_pdf(tmp_path, mode)
 | 
					    outfile = helper_save_as_pdf(tmp_path, mode)
 | 
				
			||||||
    assert os.path.getsize(outfile) < 5000
 | 
					    assert os.path.getsize(outfile) < (5000 if features.check("libtiff") else 15000)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_greyscale(tmp_path):
 | 
					def test_greyscale(tmp_path):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,7 +25,7 @@ import math
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
import time
 | 
					import time
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from . import Image, ImageFile, ImageSequence, PdfParser, __version__
 | 
					from . import Image, ImageFile, ImageSequence, PdfParser, __version__, features
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# --------------------------------------------------------------------
 | 
					# --------------------------------------------------------------------
 | 
				
			||||||
| 
						 | 
					@ -130,20 +130,23 @@ def _save(im, fp, filename, save_all=False):
 | 
				
			||||||
            width, height = im.size
 | 
					            width, height = im.size
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if im.mode == "1":
 | 
					            if im.mode == "1":
 | 
				
			||||||
                filter = "CCITTFaxDecode"
 | 
					                if features.check("libtiff"):
 | 
				
			||||||
                bits = 1
 | 
					                    filter = "CCITTFaxDecode"
 | 
				
			||||||
                params = PdfParser.PdfArray(
 | 
					                    bits = 1
 | 
				
			||||||
                    [
 | 
					                    params = PdfParser.PdfArray(
 | 
				
			||||||
                        PdfParser.PdfDict(
 | 
					                        [
 | 
				
			||||||
                            {
 | 
					                            PdfParser.PdfDict(
 | 
				
			||||||
                                "K": -1,
 | 
					                                {
 | 
				
			||||||
                                "BlackIs1": True,
 | 
					                                    "K": -1,
 | 
				
			||||||
                                "Columns": width,
 | 
					                                    "BlackIs1": True,
 | 
				
			||||||
                                "Rows": height,
 | 
					                                    "Columns": width,
 | 
				
			||||||
                            }
 | 
					                                    "Rows": height,
 | 
				
			||||||
                        )
 | 
					                                }
 | 
				
			||||||
                    ]
 | 
					                            )
 | 
				
			||||||
                )
 | 
					                        ]
 | 
				
			||||||
 | 
					                    )
 | 
				
			||||||
 | 
					                else:
 | 
				
			||||||
 | 
					                    filter = "DCTDecode"
 | 
				
			||||||
                colorspace = PdfParser.PdfName("DeviceGray")
 | 
					                colorspace = PdfParser.PdfName("DeviceGray")
 | 
				
			||||||
                procset = "ImageB"  # grayscale
 | 
					                procset = "ImageB"  # grayscale
 | 
				
			||||||
            elif im.mode == "L":
 | 
					            elif im.mode == "L":
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user