mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-10-31 16:07:30 +03:00 
			
		
		
		
	unsupported modes
This commit is contained in:
		
							parent
							
								
									008c1c88e2
								
							
						
					
					
						commit
						1d1f3be27a
					
				|  | @ -32,6 +32,19 @@ class TestImageReduce(PillowTestCase): | ||||||
|         with self.assertRaises(ValueError): |         with self.assertRaises(ValueError): | ||||||
|             im.reduce((0, 10)) |             im.reduce((0, 10)) | ||||||
| 
 | 
 | ||||||
|  |     def test_unsupported_modes(self): | ||||||
|  |         im = Image.new("P", (10, 10)) | ||||||
|  |         with self.assertRaises(ValueError): | ||||||
|  |             im.reduce(3) | ||||||
|  | 
 | ||||||
|  |         im = Image.new("1", (10, 10)) | ||||||
|  |         with self.assertRaises(ValueError): | ||||||
|  |             im.reduce(3) | ||||||
|  | 
 | ||||||
|  |         im = Image.new("I;16", (10, 10)) | ||||||
|  |         with self.assertRaises(ValueError): | ||||||
|  |             im.reduce(3) | ||||||
|  | 
 | ||||||
|     def get_image(self, mode): |     def get_image(self, mode): | ||||||
|         bands = [self.gradients_image] |         bands = [self.gradients_image] | ||||||
|         for _ in ImageMode.getmode(mode).bands[1:]: |         for _ in ImageMode.getmode(mode).bands[1:]: | ||||||
|  |  | ||||||
|  | @ -963,6 +963,12 @@ ImagingReduce(Imaging imIn, int xscale, int yscale) | ||||||
|     ImagingSectionCookie cookie; |     ImagingSectionCookie cookie; | ||||||
|     Imaging imOut = NULL; |     Imaging imOut = NULL; | ||||||
| 
 | 
 | ||||||
|  |     if (strcmp(imIn->mode, "P") == 0 || strcmp(imIn->mode, "1") == 0) | ||||||
|  |         return (Imaging) ImagingError_ModeError(); | ||||||
|  | 
 | ||||||
|  |     if (imIn->type == IMAGING_TYPE_SPECIAL) | ||||||
|  |         return (Imaging) ImagingError_ModeError(); | ||||||
|  | 
 | ||||||
|     imOut = ImagingNewDirty(imIn->mode, |     imOut = ImagingNewDirty(imIn->mode, | ||||||
|                             (imIn->xsize + xscale - 1) / xscale, |                             (imIn->xsize + xscale - 1) / xscale, | ||||||
|                             (imIn->ysize + yscale - 1) / yscale); |                             (imIn->ysize + yscale - 1) / yscale); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user