Skip to content

Commit 2985605

Browse files
committed
add optional width and height parameter to barcodeImage()
1 parent a9f744b commit 2985605

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ for product in eanList:
4848
country = eansearch.issuingCountryLookup("5099750442227")
4949
print(ean + " was issued in " + country)
5050

51-
barcode = eansearch.barcodeImage("5099750442227")
51+
barcode = eansearch.barcodeImage("5099750442227", 300, 200)
5252
print("Barcode image for " + ean + " (base64 encoded): " + barcode)
5353

5454
#import base64

eansearch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ def issuingCountryLookup(self, ean):
8888
return None
8989
return data[0]["issuingCountry"]
9090

91-
def barcodeImage(self, ean):
91+
def barcodeImage(self, ean, width=102, height=50):
9292
"""get barcodeimage for EAN"""
93-
contents = self._urlopen(self._apiurl + "&op=barcode-image&ean=" + str(ean))
93+
contents = self._urlopen(self._apiurl + "&op=barcode-image&ean=" + str(ean) + "&width=" + str(width) + "&height=" + str(height))
9494
data = json.loads(contents)
9595
if "error" in data[0]:
9696
return None

test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
country = eansearch.issuingCountryLookup("5099750442227")
4747
print(ean + " was issued in " + country)
4848

49-
barcode = eansearch.barcodeImage("5099750442227")
49+
barcode = eansearch.barcodeImage("5099750442227", 300, 200)
5050
print("Barcode image for " + ean + " (base64 encoded): " + barcode)
5151

5252
#import base64

0 commit comments

Comments
 (0)