mirror of
				https://github.com/python-escpos/python-escpos
				synced 2025-10-23 09:30:00 +00:00 
			
		
		
		
	Merge pull request #381 from Foaly/feature/image-center-doc
Added some documentation and error handling to the image center flag.
This commit is contained in:
		
							
								
								
									
										1
									
								
								AUTHORS
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								AUTHORS
									
									
									
									
									
								
							@@ -20,6 +20,7 @@ Kristi
 | 
				
			|||||||
ldos
 | 
					ldos
 | 
				
			||||||
Lucy Linder
 | 
					Lucy Linder
 | 
				
			||||||
Manuel F Martinez
 | 
					Manuel F Martinez
 | 
				
			||||||
 | 
					Maximilian Wagenbach
 | 
				
			||||||
Michael Billington
 | 
					Michael Billington
 | 
				
			||||||
Michael Elsdörfer
 | 
					Michael Elsdörfer
 | 
				
			||||||
mrwunderbar666
 | 
					mrwunderbar666
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -106,6 +106,9 @@ class Escpos(object):
 | 
				
			|||||||
            * `graphics`: prints with the `GS ( L`-command
 | 
					            * `graphics`: prints with the `GS ( L`-command
 | 
				
			||||||
            * `bitImageColumn`: prints with the `ESC *`-command
 | 
					            * `bitImageColumn`: prints with the `ESC *`-command
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        When trying to center an image make sure you have initialized the printer with a valid profile, that
 | 
				
			||||||
 | 
					        contains a media width pixel field. Otherwise the centering will have no effect.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        :param img_source: PIL image or filename to load: `jpg`, `gif`, `png` or `bmp`
 | 
					        :param img_source: PIL image or filename to load: `jpg`, `gif`, `png` or `bmp`
 | 
				
			||||||
        :param high_density_vertical: print in high density in vertical direction *default:* True
 | 
					        :param high_density_vertical: print in high density in vertical direction *default:* True
 | 
				
			||||||
        :param high_density_horizontal: print in high density in horizontal direction *default:* True
 | 
					        :param high_density_horizontal: print in high density in horizontal direction *default:* True
 | 
				
			||||||
@@ -117,6 +120,10 @@ class Escpos(object):
 | 
				
			|||||||
        im = EscposImage(img_source)
 | 
					        im = EscposImage(img_source)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
 | 
					            if self.profile.profile_data['media']['width']['pixels'] == "Unknown":
 | 
				
			||||||
 | 
					                print("The media.width.pixel field of the printer profile is not set. " +
 | 
				
			||||||
 | 
					                      "The center flag will have no effect.")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            max_width = int(self.profile.profile_data['media']['width']['pixels'])
 | 
					            max_width = int(self.profile.profile_data['media']['width']['pixels'])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if im.width > max_width:
 | 
					            if im.width > max_width:
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user