mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 09:57:43 +03:00 
			
		
		
		
	Corrected EMF DPI
This commit is contained in:
		
							parent
							
								
									331e4e7517
								
							
						
					
					
						commit
						55579084cd
					
				| 
						 | 
					@ -1,5 +1,6 @@
 | 
				
			||||||
from __future__ import annotations
 | 
					from __future__ import annotations
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from io import BytesIO
 | 
				
			||||||
from pathlib import Path
 | 
					from pathlib import Path
 | 
				
			||||||
from typing import IO
 | 
					from typing import IO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -61,6 +62,12 @@ def test_load_float_dpi() -> None:
 | 
				
			||||||
    with Image.open("Tests/images/drawing.emf") as im:
 | 
					    with Image.open("Tests/images/drawing.emf") as im:
 | 
				
			||||||
        assert im.info["dpi"] == 1423.7668161434979
 | 
					        assert im.info["dpi"] == 1423.7668161434979
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    with open("Tests/images/drawing.emf", "rb") as fp:
 | 
				
			||||||
 | 
					        data = fp.read()
 | 
				
			||||||
 | 
					    b = BytesIO(data[:8] + b"\x06\xFA" + data[10:])
 | 
				
			||||||
 | 
					    with Image.open(b) as im:
 | 
				
			||||||
 | 
					        assert im.info["dpi"][0] == 2540
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_load_set_dpi() -> None:
 | 
					def test_load_set_dpi() -> None:
 | 
				
			||||||
    with Image.open("Tests/images/drawing.wmf") as im:
 | 
					    with Image.open("Tests/images/drawing.wmf") as im:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -128,7 +128,7 @@ class WmfStubImageFile(ImageFile.StubImageFile):
 | 
				
			||||||
            size = x1 - x0, y1 - y0
 | 
					            size = x1 - x0, y1 - y0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            # calculate dots per inch from bbox and frame
 | 
					            # calculate dots per inch from bbox and frame
 | 
				
			||||||
            xdpi = 2540.0 * (x1 - y0) / (frame[2] - frame[0])
 | 
					            xdpi = 2540.0 * (x1 - x0) / (frame[2] - frame[0])
 | 
				
			||||||
            ydpi = 2540.0 * (y1 - y0) / (frame[3] - frame[1])
 | 
					            ydpi = 2540.0 * (y1 - y0) / (frame[3] - frame[1])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            self.info["wmf_bbox"] = x0, y0, x1, y1
 | 
					            self.info["wmf_bbox"] = x0, y0, x1, y1
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user