mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 09:57:43 +03:00 
			
		
		
		
	Merge pull request #73 from pelson/tiff_tags
Added the ``named`` method to a Tiffs tag getter.
This commit is contained in:
		
						commit
						cd1cc66d4d
					
				| 
						 | 
					@ -216,11 +216,30 @@ class ImageFileDirectory(collections.MutableMapping):
 | 
				
			||||||
        self.reset()
 | 
					        self.reset()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def reset(self):
 | 
					    def reset(self):
 | 
				
			||||||
 | 
					        #: Tags is an incomplete dictionary of the tags of the image.
 | 
				
			||||||
 | 
					        #: For a complete dictionary, use teh as_dict method.
 | 
				
			||||||
        self.tags = {}
 | 
					        self.tags = {}
 | 
				
			||||||
        self.tagdata = {}
 | 
					        self.tagdata = {}
 | 
				
			||||||
        self.tagtype = {} # added 2008-06-05 by Florian Hoech
 | 
					        self.tagtype = {} # added 2008-06-05 by Florian Hoech
 | 
				
			||||||
        self.next = None
 | 
					        self.next = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def __str__(self):
 | 
				
			||||||
 | 
					        return str(self.as_dict())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def as_dict(self):
 | 
				
			||||||
 | 
					        """Return a dictionary of the image's tags."""
 | 
				
			||||||
 | 
					        return dict(self.items())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def named(self):
 | 
				
			||||||
 | 
					        """Returns the complete tag dictionary, with named tags where posible."""
 | 
				
			||||||
 | 
					        from . import TiffTags
 | 
				
			||||||
 | 
					        result = {}
 | 
				
			||||||
 | 
					        for tag_code, value in self.items():
 | 
				
			||||||
 | 
					            tag_name = TiffTags.TAGS.get(tag_code, tag_code)
 | 
				
			||||||
 | 
					            result[tag_name] = value
 | 
				
			||||||
 | 
					        return result
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # dictionary API
 | 
					    # dictionary API
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __len__(self):
 | 
					    def __len__(self):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user