From f1a072394e205d5a37e44151faa75f4ba14f7585 Mon Sep 17 00:00:00 2001 From: Kazuki Suzuki Przyborowski Date: Wed, 20 Nov 2024 16:58:35 -0600 Subject: [PATCH] Small update --- upcean/encode/barcode.py | 1 + upcean/encode/binary.py | 20 ++++--------- upcean/encode/codabar.py | 9 ++++-- upcean/encode/code11.py | 9 ++++-- upcean/encode/code128.py | 13 +++++---- upcean/encode/code32.py | 9 ++++-- upcean/encode/code39.py | 17 +++++++---- upcean/encode/code93.py | 17 +++++++---- upcean/encode/ean13.py | 9 ++++-- upcean/encode/ean2.py | 9 ++++-- upcean/encode/ean5.py | 9 ++++-- upcean/encode/ean8.py | 9 ++++-- upcean/encode/goodwill.py | 1 + upcean/encode/itf.py | 9 ++++-- upcean/encode/itf14.py | 9 ++++-- upcean/encode/msi.py | 9 ++++-- upcean/encode/plessey.py | 9 ++++-- upcean/encode/stf.py | 9 ++++-- upcean/encode/upca.py | 17 +++++++---- upcean/encode/upcavar.py | 17 +++++++---- upcean/encode/upce.py | 9 ++++-- upcean/oopfuncs/oopfuncs.py | 1 + upcean/predraw/getsfname.py | 1 + upcean/predraw/prefuncs.py | 4 ++- upcean/predraw/presvgwrite.py | 10 +++++-- upcean/support.py | 53 +++++++++++++++++++++++++++++------ upcean/upcean.ini | 1 + 27 files changed, 194 insertions(+), 96 deletions(-) diff --git a/upcean/encode/barcode.py b/upcean/encode/barcode.py index fb77dfa3..1f37fd0f 100644 --- a/upcean/encode/barcode.py +++ b/upcean/encode/barcode.py @@ -36,6 +36,7 @@ from upcean.encode.ean5 import * from upcean.encode.ean2 import * import upcean.support +tkintersupport = upcean.support.check_for_tkinter() pilsupport = upcean.support.check_for_pil() pillowsupport = upcean.support.check_for_pillow() cairosupport = upcean.support.check_for_cairo() diff --git a/upcean/encode/binary.py b/upcean/encode/binary.py index 9b0d2ffb..8c30f944 100644 --- a/upcean/encode/binary.py +++ b/upcean/encode/binary.py @@ -41,6 +41,8 @@ import upcean.encode.ean2 import upcean.encode.ean5 pilsupport = upcean.support.check_for_pil() +tkintersupport = upcean.support.check_for_tkinter() +pilsupport = upcean.support.check_for_pil() pillowsupport = upcean.support.check_for_pillow() cairosupport = upcean.support.check_for_cairo() qahirahsupport = upcean.support.check_for_qahirah() @@ -53,18 +55,6 @@ skimagesupport = upcean.support.check_for_skimage() imagelibsupport = upcean.support.imagelibsupport defaultdraw = upcean.support.defaultdraw -if(pilsupport or pillowsupport): - import upcean.predraw.prepil -if(cairosupport): - import upcean.predraw.precairo -if(qahirahsupport): - import upcean.predraw.preqahirah -if(svgwritesupport): - import upcean.predraw.presvgwrite -if(wandsupport): - import upcean.predraw.prewand -if(magicksupport): - import upcean.predraw.premagick def get_binary_barcode_size(upc, resize=1, shiftxy=(0, 0), barheight=(48, 54), barwidth=(1, 1)): @@ -107,9 +97,9 @@ def encode_binary_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): vertical_text_fix = (10 * (int(resize) * barwidth[1])) - elif(svgwritesupport and imageoutlib == "svgwrite"): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): vertical_text_fix = (8 * (int(resize) * barwidth[1])) - elif(imageoutlib == "tkinter"): + elif(tkintersupport and imageoutlib == "tkinter"): vertical_text_fix = (5 * (int(resize) * barwidth[1])) else: vertical_text_fix = 0 @@ -146,7 +136,7 @@ def encode_binary_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, txtbari = 0 txtbarmax = len(upc['text']['text']) LineFixTxtStart = 0 - if(imageoutlib == "tkinter"): + if(tkintersupport and imageoutlib == "tkinter"): LineFixTxtStart = 4 while(txtbari < txtbarmax): texthidden = False diff --git a/upcean/encode/codabar.py b/upcean/encode/codabar.py index 29b111da..81bcf92b 100644 --- a/upcean/encode/codabar.py +++ b/upcean/encode/codabar.py @@ -38,6 +38,7 @@ from StringIO import StringIO from StringIO import StringIO as BytesIO +tkintersupport = upcean.support.check_for_tkinter() pilsupport = upcean.support.check_for_pil() pillowsupport = upcean.support.check_for_pillow() cairosupport = upcean.support.check_for_cairo() @@ -115,9 +116,9 @@ def encode_codabar_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48 vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): vertical_text_fix = (10 * (int(resize) * barwidth[1])) - elif(svgwritesupport and imageoutlib == "svgwrite"): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): vertical_text_fix = (8 * (int(resize) * barwidth[1])) - elif(imageoutlib == "tkinter"): + elif(tkintersupport and imageoutlib == "tkinter"): vertical_text_fix = (5 * (int(resize) * barwidth[1])) else: vertical_text_fix = 0 @@ -264,8 +265,10 @@ def encode_codabar_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48 NumTxtZero = 0 LineTxtStart = ((shiftxy[0] + 20) * int(resize)) LineTxtStartNorm = 20 - if(imageoutlib == "tkinter"): + if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) + elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + LineTxtStart += (1 * int(resize)) while (NumTxtZero < len(upc_matches)): texthidden = False if hidetext or (NumTxtZero == 0 and (hidesn is None or hidesn)) or (NumTxtZero == 11 and (hidecd is None or hidecd)): diff --git a/upcean/encode/code11.py b/upcean/encode/code11.py index 4d457189..e8976ce4 100644 --- a/upcean/encode/code11.py +++ b/upcean/encode/code11.py @@ -38,6 +38,7 @@ from StringIO import StringIO from StringIO import StringIO as BytesIO +tkintersupport = upcean.support.check_for_tkinter() pilsupport = upcean.support.check_for_pil() pillowsupport = upcean.support.check_for_pillow() cairosupport = upcean.support.check_for_cairo() @@ -111,9 +112,9 @@ def encode_code11_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): vertical_text_fix = (10 * (int(resize) * barwidth[1])) - elif(svgwritesupport and imageoutlib == "svgwrite"): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): vertical_text_fix = (8 * (int(resize) * barwidth[1])) - elif(imageoutlib == "tkinter"): + elif(tkintersupport and imageoutlib == "tkinter"): vertical_text_fix = (5 * (int(resize) * barwidth[1])) else: vertical_text_fix = 0 @@ -223,8 +224,10 @@ def encode_code11_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, NumTxtZero = 0 LineTxtStart = ((shiftxy[0] + 10) * int(resize)) LineTxtStartNorm = 10 - if(imageoutlib == "tkinter"): + if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) + elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + LineTxtStart += (1 * int(resize)) while (NumTxtZero < len(upc_print)): texthidden = False if hidetext or (NumTxtZero == 0 and (hidesn is None or hidesn)) or (NumTxtZero == 11 and (hidecd is None or hidecd)): diff --git a/upcean/encode/code128.py b/upcean/encode/code128.py index 9831227b..e6f5fe93 100644 --- a/upcean/encode/code128.py +++ b/upcean/encode/code128.py @@ -38,6 +38,7 @@ from StringIO import StringIO from StringIO import StringIO as BytesIO +tkintersupport = upcean.support.check_for_tkinter() pilsupport = upcean.support.check_for_pil() pillowsupport = upcean.support.check_for_pillow() cairosupport = upcean.support.check_for_cairo() @@ -108,9 +109,9 @@ def encode_code128_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48 vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): vertical_text_fix = (10 * (int(resize) * barwidth[1])) - elif(svgwritesupport and imageoutlib == "svgwrite"): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): vertical_text_fix = (8 * (int(resize) * barwidth[1])) - elif(imageoutlib == "tkinter"): + elif(tkintersupport and imageoutlib == "tkinter"): vertical_text_fix = (5 * (int(resize) * barwidth[1])) else: vertical_text_fix = 0 @@ -552,8 +553,10 @@ def encode_code128_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48 NumTxtZero = 0 LineTxtStart = ((shiftxy[0] + 16) * int(resize)) LineTxtStartNorm = 16 - if(imageoutlib == "tkinter"): + if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) + elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + LineTxtStart += (1 * int(resize)) if(barcode_is_rev): upc_print.reverse() while (NumTxtZero < len(upc_print)): @@ -707,9 +710,9 @@ def encode_code128old_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight= vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): vertical_text_fix = (10 * (int(resize) * barwidth[1])) - elif(svgwritesupport and imageoutlib == "svgwrite"): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): vertical_text_fix = (8 * (int(resize) * barwidth[1])) - elif(imageoutlib == "tkinter"): + elif(tkintersupport and imageoutlib == "tkinter"): vertical_text_fix = (5 * (int(resize) * barwidth[1])) else: vertical_text_fix = 0 diff --git a/upcean/encode/code32.py b/upcean/encode/code32.py index c2e298b1..98b86d55 100644 --- a/upcean/encode/code32.py +++ b/upcean/encode/code32.py @@ -38,6 +38,7 @@ from StringIO import StringIO from StringIO import StringIO as BytesIO +tkintersupport = upcean.support.check_for_tkinter() pilsupport = upcean.support.check_for_pil() pillowsupport = upcean.support.check_for_pillow() cairosupport = upcean.support.check_for_cairo() @@ -108,9 +109,9 @@ def encode_code32_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): vertical_text_fix = (10 * (int(resize) * barwidth[1])) - elif(svgwritesupport and imageoutlib == "svgwrite"): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): vertical_text_fix = (8 * (int(resize) * barwidth[1])) - elif(imageoutlib == "tkinter"): + elif(tkintersupport and imageoutlib == "tkinter"): vertical_text_fix = (5 * (int(resize) * barwidth[1])) else: vertical_text_fix = 0 @@ -264,8 +265,10 @@ def encode_code32_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, NumTxtZero = 0 LineTxtStart = ((shiftxy[0] + 30) * int(resize)) LineTxtStartNorm = 30 - if(imageoutlib == "tkinter"): + if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) + elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + LineTxtStart += (1 * int(resize)) while (NumTxtZero < len(upc_matches)): texthidden = False if hidetext or (NumTxtZero == 0 and (hidesn is None or hidesn)) or (NumTxtZero == 11 and (hidecd is None or hidecd)): diff --git a/upcean/encode/code39.py b/upcean/encode/code39.py index cc50969c..b7a0089c 100644 --- a/upcean/encode/code39.py +++ b/upcean/encode/code39.py @@ -38,6 +38,7 @@ from StringIO import StringIO from StringIO import StringIO as BytesIO +tkintersupport = upcean.support.check_for_tkinter() pilsupport = upcean.support.check_for_pil() pillowsupport = upcean.support.check_for_pillow() cairosupport = upcean.support.check_for_cairo() @@ -108,9 +109,9 @@ def encode_code39_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): vertical_text_fix = (10 * (int(resize) * barwidth[1])) - elif(svgwritesupport and imageoutlib == "svgwrite"): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): vertical_text_fix = (8 * (int(resize) * barwidth[1])) - elif(imageoutlib == "tkinter"): + elif(tkintersupport and imageoutlib == "tkinter"): vertical_text_fix = (5 * (int(resize) * barwidth[1])) else: vertical_text_fix = 0 @@ -286,8 +287,10 @@ def encode_code39_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, NumTxtZero = 0 LineTxtStart = ((shiftxy[0] + 15) * int(resize)) LineTxtStartNorm = 15 - if(imageoutlib == "tkinter"): + if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) + elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + LineTxtStart += (1 * int(resize)) drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( barheight[0] * int(resize)), "*", barcolor[1], "ocrb", imageoutlib) upc_array['text']['location'].append(LineTxtStartNorm) @@ -428,9 +431,9 @@ def encode_code39extended_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barhei vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): vertical_text_fix = (10 * (int(resize) * barwidth[1])) - elif(svgwritesupport and imageoutlib == "svgwrite"): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): vertical_text_fix = (8 * (int(resize) * barwidth[1])) - elif(imageoutlib == "tkinter"): + elif(tkintersupport and imageoutlib == "tkinter"): vertical_text_fix = (5 * (int(resize) * barwidth[1])) else: vertical_text_fix = 0 @@ -608,8 +611,10 @@ def encode_code39extended_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barhei NumTxtZero = 0 LineTxtStart = ((shiftxy[0] + 15) * int(resize)) LineTxtStartNorm = 15 - if(imageoutlib == "tkinter"): + if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) + elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + LineTxtStart += (1 * int(resize)) drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( barheight[0] * int(resize)), "*", barcolor[1], "ocrb", imageoutlib) upc_array['text']['location'].append(LineTxtStartNorm) diff --git a/upcean/encode/code93.py b/upcean/encode/code93.py index c8bad4ee..09554123 100644 --- a/upcean/encode/code93.py +++ b/upcean/encode/code93.py @@ -38,6 +38,7 @@ from StringIO import StringIO from StringIO import StringIO as BytesIO +tkintersupport = upcean.support.check_for_tkinter() pilsupport = upcean.support.check_for_pil() pillowsupport = upcean.support.check_for_pillow() cairosupport = upcean.support.check_for_cairo() @@ -107,9 +108,9 @@ def encode_code93_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): vertical_text_fix = (10 * (int(resize) * barwidth[1])) - elif(svgwritesupport and imageoutlib == "svgwrite"): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): vertical_text_fix = (8 * (int(resize) * barwidth[1])) - elif(imageoutlib == "tkinter"): + elif(tkintersupport and imageoutlib == "tkinter"): vertical_text_fix = (5 * (int(resize) * barwidth[1])) else: vertical_text_fix = 0 @@ -294,8 +295,10 @@ def encode_code93_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, NumTxtZero = 0 LineTxtStart = ((shiftxy[0] + 18) * int(resize)) LineTxtStartNorm = 18 - if(imageoutlib == "tkinter"): + if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) + elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + LineTxtStart += (1 * int(resize)) while (NumTxtZero < len(upc_matches)): texthidden = False if hidetext or (NumTxtZero == 0 and (hidesn is None or hidesn)) or (NumTxtZero == 11 and (hidecd is None or hidecd)): @@ -426,9 +429,9 @@ def encode_code93extended_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barhei vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): vertical_text_fix = (10 * (int(resize) * barwidth[1])) - elif(svgwritesupport and imageoutlib == "svgwrite"): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): vertical_text_fix = (8 * (int(resize) * barwidth[1])) - elif(imageoutlib == "tkinter"): + elif(tkintersupport and imageoutlib == "tkinter"): vertical_text_fix = (5 * (int(resize) * barwidth[1])) else: vertical_text_fix = 0 @@ -617,8 +620,10 @@ def encode_code93extended_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barhei NumTxtZero = 0 LineTxtStart = ((shiftxy[0] + 18) * int(resize)) LineTxtStartNorm = 18 - if(imageoutlib == "tkinter"): + if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) + elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + LineTxtStart += (1 * int(resize)) while (NumTxtZero < len(upc_matches)): texthidden = False NumTxtZeroNext = NumTxtZero + 1 diff --git a/upcean/encode/ean13.py b/upcean/encode/ean13.py index e474fd2e..e2010695 100644 --- a/upcean/encode/ean13.py +++ b/upcean/encode/ean13.py @@ -40,6 +40,7 @@ import upcean.encode.ean2 import upcean.encode.ean5 +tkintersupport = upcean.support.check_for_tkinter() pilsupport = upcean.support.check_for_pil() pillowsupport = upcean.support.check_for_pillow() cairosupport = upcean.support.check_for_cairo() @@ -127,9 +128,9 @@ def encode_ean13_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): vertical_text_fix = (10 * (int(resize) * barwidth[1])) - elif(svgwritesupport and imageoutlib == "svgwrite"): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): vertical_text_fix = (8 * (int(resize) * barwidth[1])) - elif(imageoutlib == "tkinter"): + elif(tkintersupport and imageoutlib == "tkinter"): vertical_text_fix = (5 * (int(resize) * barwidth[1])) else: vertical_text_fix = 0 @@ -394,8 +395,10 @@ def encode_ean13_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, NumTxtZero = 0 LineTxtStart = ((shiftxy[0] + 2) * int(resize)) LineTxtStartNorm = 2 - if(imageoutlib == "tkinter"): + if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) + elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + LineTxtStart += (1 * int(resize)) upc_print = list(re.findall("(\\d{13})", upc)[0])+[">"] while (NumTxtZero < len(upc_print)): texthidden = False diff --git a/upcean/encode/ean2.py b/upcean/encode/ean2.py index ea978033..a0b123fa 100644 --- a/upcean/encode/ean2.py +++ b/upcean/encode/ean2.py @@ -38,6 +38,7 @@ from StringIO import StringIO from StringIO import StringIO as BytesIO +tkintersupport = upcean.support.check_for_tkinter() pilsupport = upcean.support.check_for_pil() pillowsupport = upcean.support.check_for_pillow() cairosupport = upcean.support.check_for_cairo() @@ -104,9 +105,9 @@ def encode_ean2_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 5 vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): vertical_text_fix = (10 * (int(resize) * barwidth[1])) - elif(svgwritesupport and imageoutlib == "svgwrite"): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): vertical_text_fix = (8 * (int(resize) * barwidth[1])) - elif(imageoutlib == "tkinter"): + elif(tkintersupport and imageoutlib == "tkinter"): vertical_text_fix = (5 * (int(resize) * barwidth[1])) else: vertical_text_fix = 0 @@ -247,8 +248,10 @@ def encode_ean2_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 5 NumTxtZero = 0 LineTxtStart = ((shiftxy[0] + 6) * int(resize)) LineTxtStartNorm = 6 - if(imageoutlib == "tkinter"): + if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) + elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + LineTxtStart += (1 * int(resize)) upc_print = LeftDigit while (NumTxtZero < len(upc_print)): texthidden = False diff --git a/upcean/encode/ean5.py b/upcean/encode/ean5.py index 087dc28d..c4f4f7f0 100644 --- a/upcean/encode/ean5.py +++ b/upcean/encode/ean5.py @@ -38,6 +38,7 @@ from StringIO import StringIO from StringIO import StringIO as BytesIO +tkintersupport = upcean.support.check_for_tkinter() pilsupport = upcean.support.check_for_pil() pillowsupport = upcean.support.check_for_pillow() cairosupport = upcean.support.check_for_cairo() @@ -105,9 +106,9 @@ def encode_ean5_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 5 vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): vertical_text_fix = (10 * (int(resize) * barwidth[1])) - elif(svgwritesupport and imageoutlib == "svgwrite"): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): vertical_text_fix = (8 * (int(resize) * barwidth[1])) - elif(imageoutlib == "tkinter"): + elif(tkintersupport and imageoutlib == "tkinter"): vertical_text_fix = (5 * (int(resize) * barwidth[1])) else: vertical_text_fix = 0 @@ -334,8 +335,10 @@ def encode_ean5_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 5 NumTxtZero = 0 LineTxtStart = ((shiftxy[0] + 7) * int(resize)) LineTxtStartNorm = 7 - if(imageoutlib == "tkinter"): + if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) + elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + LineTxtStart += (1 * int(resize)) upc_print = LeftDigit while (NumTxtZero < len(upc_print)): texthidden = False diff --git a/upcean/encode/ean8.py b/upcean/encode/ean8.py index 4c474e7d..0b7538b2 100644 --- a/upcean/encode/ean8.py +++ b/upcean/encode/ean8.py @@ -40,6 +40,7 @@ import upcean.encode.ean2 import upcean.encode.ean5 +tkintersupport = upcean.support.check_for_tkinter() pilsupport = upcean.support.check_for_pil() pillowsupport = upcean.support.check_for_pillow() cairosupport = upcean.support.check_for_cairo() @@ -127,9 +128,9 @@ def encode_ean8_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 5 vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): vertical_text_fix = (10 * (int(resize) * barwidth[1])) - elif(svgwritesupport and imageoutlib == "svgwrite"): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): vertical_text_fix = (8 * (int(resize) * barwidth[1])) - elif(imageoutlib == "tkinter"): + elif(tkintersupport and imageoutlib == "tkinter"): vertical_text_fix = (5 * (int(resize) * barwidth[1])) else: vertical_text_fix = 0 @@ -401,8 +402,10 @@ def encode_ean8_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 5 NumTxtZero = 0 LineTxtStart = shiftxy[0] * int(resize) LineTxtStartNorm = 0 - if(imageoutlib == "tkinter"): + if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) + elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + LineTxtStart += (1 * int(resize)) upc_print = ["<"]+list(re.findall("(\\d{8})", upc)[0])+[">"] while (NumTxtZero < len(upc_print)): texthidden = False diff --git a/upcean/encode/goodwill.py b/upcean/encode/goodwill.py index 6bfe995e..7c2a646e 100644 --- a/upcean/encode/goodwill.py +++ b/upcean/encode/goodwill.py @@ -41,6 +41,7 @@ import upcean.encode.ean2 import upcean.encode.ean5 from upcean.encode.upca import * +tkintersupport = upcean.support.check_for_tkinter() pilsupport = upcean.support.check_for_pil() pillowsupport = upcean.support.check_for_pillow() cairosupport = upcean.support.check_for_cairo() diff --git a/upcean/encode/itf.py b/upcean/encode/itf.py index 14beb3da..f87944e0 100644 --- a/upcean/encode/itf.py +++ b/upcean/encode/itf.py @@ -38,6 +38,7 @@ from StringIO import StringIO from StringIO import StringIO as BytesIO +tkintersupport = upcean.support.check_for_tkinter() pilsupport = upcean.support.check_for_pil() pillowsupport = upcean.support.check_for_pillow() cairosupport = upcean.support.check_for_cairo() @@ -111,9 +112,9 @@ def encode_itf_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 54 vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): vertical_text_fix = (10 * (int(resize) * barwidth[1])) - elif(svgwritesupport and imageoutlib == "svgwrite"): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): vertical_text_fix = (8 * (int(resize) * barwidth[1])) - elif(imageoutlib == "tkinter"): + elif(tkintersupport and imageoutlib == "tkinter"): vertical_text_fix = (5 * (int(resize) * barwidth[1])) else: vertical_text_fix = 0 @@ -289,8 +290,10 @@ def encode_itf_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 54 NumTxtZero = 0 LineTxtStart = ((shiftxy[0] + 20) * int(resize)) LineTxtStartNorm = 20 - if(imageoutlib == "tkinter"): + if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) + elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + LineTxtStart += (1 * int(resize)) while (NumTxtZero < len(upc_matches)): ArrayDigit = list(upc_matches[NumTxtZero]) texthidden = False diff --git a/upcean/encode/itf14.py b/upcean/encode/itf14.py index ebe11fe6..f159013a 100644 --- a/upcean/encode/itf14.py +++ b/upcean/encode/itf14.py @@ -38,6 +38,7 @@ from StringIO import StringIO from StringIO import StringIO as BytesIO +tkintersupport = upcean.support.check_for_tkinter() pilsupport = upcean.support.check_for_pil() pillowsupport = upcean.support.check_for_pillow() cairosupport = upcean.support.check_for_cairo() @@ -111,9 +112,9 @@ def encode_itf14_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): vertical_text_fix = (10 * (int(resize) * barwidth[1])) - elif(svgwritesupport and imageoutlib == "svgwrite"): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): vertical_text_fix = (8 * (int(resize) * barwidth[1])) - elif(imageoutlib == "tkinter"): + elif(tkintersupport and imageoutlib == "tkinter"): vertical_text_fix = (5 * (int(resize) * barwidth[1])) else: vertical_text_fix = 0 @@ -297,8 +298,10 @@ def encode_itf14_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, NumTxtZero = 0 LineTxtStart = shiftxy[0] * int(resize) + (23 * int(resize)) LineTxtStartNorm = 23 - if(imageoutlib == "tkinter"): + if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) + elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + LineTxtStart += (1 * int(resize)) while (NumTxtZero < len(upc_matches)): ArrayDigit = list(upc_matches[NumTxtZero]) texthidden = False diff --git a/upcean/encode/msi.py b/upcean/encode/msi.py index 0c22c622..d586261b 100644 --- a/upcean/encode/msi.py +++ b/upcean/encode/msi.py @@ -38,6 +38,7 @@ from StringIO import StringIO from StringIO import StringIO as BytesIO +tkintersupport = upcean.support.check_for_tkinter() pilsupport = upcean.support.check_for_pil() pillowsupport = upcean.support.check_for_pillow() cairosupport = upcean.support.check_for_cairo() @@ -105,9 +106,9 @@ def encode_msi_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 54 vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): vertical_text_fix = (10 * (int(resize) * barwidth[1])) - elif(svgwritesupport and imageoutlib == "svgwrite"): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): vertical_text_fix = (8 * (int(resize) * barwidth[1])) - elif(imageoutlib == "tkinter"): + elif(tkintersupport and imageoutlib == "tkinter"): vertical_text_fix = (5 * (int(resize) * barwidth[1])) else: vertical_text_fix = 0 @@ -204,8 +205,10 @@ def encode_msi_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 54 NumTxtZero = 0 LineTxtStart = ((shiftxy[0] + 16) * int(resize)) LineTxtStartNorm = 16 - if(imageoutlib == "tkinter"): + if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) + elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + LineTxtStart += (1 * int(resize)) while (NumTxtZero < len(upc_print)): texthidden = False if hidetext or (NumTxtZero == 0 and (hidesn is None or hidesn)) or (NumTxtZero == 11 and (hidecd is None or hidecd)): diff --git a/upcean/encode/plessey.py b/upcean/encode/plessey.py index 2f4b0e5e..72bc9c2a 100644 --- a/upcean/encode/plessey.py +++ b/upcean/encode/plessey.py @@ -38,6 +38,7 @@ from StringIO import StringIO from StringIO import StringIO as BytesIO +tkintersupport = upcean.support.check_for_tkinter() pilsupport = upcean.support.check_for_pil() pillowsupport = upcean.support.check_for_pillow() cairosupport = upcean.support.check_for_cairo() @@ -108,9 +109,9 @@ def encode_plessey_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48 vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): vertical_text_fix = (10 * (int(resize) * barwidth[1])) - elif(svgwritesupport and imageoutlib == "svgwrite"): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): vertical_text_fix = (8 * (int(resize) * barwidth[1])) - elif(imageoutlib == "tkinter"): + elif(tkintersupport and imageoutlib == "tkinter"): vertical_text_fix = (5 * (int(resize) * barwidth[1])) else: vertical_text_fix = 0 @@ -232,8 +233,10 @@ def encode_plessey_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48 NumTxtZero = 0 LineTxtStart = ((shiftxy[0] + 30) * int(resize)) LineTxtStartNorm = 30 - if(imageoutlib == "tkinter"): + if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) + elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + LineTxtStart += (1 * int(resize)) while (NumTxtZero < len(upc_matches)): texthidden = False if hidetext or (NumTxtZero == 0 and (hidesn is None or hidesn)) or (NumTxtZero == 11 and (hidecd is None or hidecd)): diff --git a/upcean/encode/stf.py b/upcean/encode/stf.py index e508535d..be9d5b12 100644 --- a/upcean/encode/stf.py +++ b/upcean/encode/stf.py @@ -38,6 +38,7 @@ from StringIO import StringIO from StringIO import StringIO as BytesIO +tkintersupport = upcean.support.check_for_tkinter() pilsupport = upcean.support.check_for_pil() pillowsupport = upcean.support.check_for_pillow() cairosupport = upcean.support.check_for_cairo() @@ -111,9 +112,9 @@ def encode_stf_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 54 vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): vertical_text_fix = (10 * (int(resize) * barwidth[1])) - elif(svgwritesupport and imageoutlib == "svgwrite"): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): vertical_text_fix = (8 * (int(resize) * barwidth[1])) - elif(imageoutlib == "tkinter"): + elif(tkintersupport and imageoutlib == "tkinter"): vertical_text_fix = (5 * (int(resize) * barwidth[1])) else: vertical_text_fix = 0 @@ -241,8 +242,10 @@ def encode_stf_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 54 NumTxtZero = 0 LineTxtStart = shiftxy[0] * int(resize) + (24 * int(resize)) LineTxtStartNorm = 24 - if(imageoutlib == "tkinter"): + if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) + elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + LineTxtStart += (1 * int(resize)) while (NumTxtZero < len(upc_matches)): texthidden = False if hidetext or (NumTxtZero == 0 and (hidesn is None or hidesn)) or (NumTxtZero == 11 and (hidecd is None or hidecd)): diff --git a/upcean/encode/upca.py b/upcean/encode/upca.py index 8701df4f..835628bb 100644 --- a/upcean/encode/upca.py +++ b/upcean/encode/upca.py @@ -40,6 +40,7 @@ import upcean.encode.ean2 import upcean.encode.ean5 +tkintersupport = upcean.support.check_for_tkinter() pilsupport = upcean.support.check_for_pil() pillowsupport = upcean.support.check_for_pillow() cairosupport = upcean.support.check_for_cairo() @@ -125,9 +126,9 @@ def encode_upca_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 5 vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): vertical_text_fix = (10 * (int(resize) * barwidth[1])) - elif(svgwritesupport and imageoutlib == "svgwrite"): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): vertical_text_fix = (8 * (int(resize) * barwidth[1])) - elif(imageoutlib == "tkinter"): + elif(tkintersupport and imageoutlib == "tkinter"): vertical_text_fix = (5 * (int(resize) * barwidth[1])) else: vertical_text_fix = 0 @@ -328,8 +329,10 @@ def encode_upca_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 5 NumTxtZero = 0 LineTxtStart = ((shiftxy[0] + 1) * int(resize)) LineTxtStartNorm = 1 - if(imageoutlib == "tkinter"): + if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) + elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + LineTxtStart += (1 * int(resize)) upc_print = list(re.findall("(\\d{12})", upc)[0]) while (NumTxtZero < len(upc_print)): texthidden = False @@ -528,9 +531,9 @@ def encode_upcaean_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48 vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): vertical_text_fix = (10 * (int(resize) * barwidth[1])) - elif(svgwritesupport and imageoutlib == "svgwrite"): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): vertical_text_fix = (8 * (int(resize) * barwidth[1])) - elif(imageoutlib == "tkinter"): + elif(tkintersupport and imageoutlib == "tkinter"): vertical_text_fix = (5 * (int(resize) * barwidth[1])) else: vertical_text_fix = 0 @@ -721,8 +724,10 @@ def encode_upcaean_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48 NumTxtZero = 0 LineTxtStart = ((shiftxy[0] + 2) * int(resize)) LineTxtStartNorm = 2 - if(imageoutlib == "tkinter"): + if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) + elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + LineTxtStart += (1 * int(resize)) upc_print = [0]+list(re.findall("(\\d{12})", upc)[0])+[">"] while (NumTxtZero < len(upc_print)): texthidden = False diff --git a/upcean/encode/upcavar.py b/upcean/encode/upcavar.py index 227f1229..5890234e 100644 --- a/upcean/encode/upcavar.py +++ b/upcean/encode/upcavar.py @@ -40,6 +40,7 @@ import upcean.encode.ean2 import upcean.encode.ean5 +tkintersupport = upcean.support.check_for_tkinter() pilsupport = upcean.support.check_for_pil() pillowsupport = upcean.support.check_for_pillow() cairosupport = upcean.support.check_for_cairo() @@ -127,9 +128,9 @@ def encode_upcavar_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48 vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): vertical_text_fix = (10 * (int(resize) * barwidth[1])) - elif(svgwritesupport and imageoutlib == "svgwrite"): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): vertical_text_fix = (8 * (int(resize) * barwidth[1])) - elif(imageoutlib == "tkinter"): + elif(tkintersupport and imageoutlib == "tkinter"): vertical_text_fix = (5 * (int(resize) * barwidth[1])) else: vertical_text_fix = 0 @@ -335,8 +336,10 @@ def encode_upcavar_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48 NumTxtZero = 0 LineTxtStart = ((shiftxy[0] + 1) * int(resize)) LineTxtStartNorm = 1 - if(imageoutlib == "tkinter"): + if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) + elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + LineTxtStart += (1 * int(resize)) upc_print = list(re.findall("(\\d+)", upc)[0]) while (NumTxtZero < len(upc_print)): texthidden = False @@ -537,9 +540,9 @@ def encode_upcaeanvar_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight= vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): vertical_text_fix = (10 * (int(resize) * barwidth[1])) - elif(svgwritesupport and imageoutlib == "svgwrite"): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): vertical_text_fix = (8 * (int(resize) * barwidth[1])) - elif(imageoutlib == "tkinter"): + elif(tkintersupport and imageoutlib == "tkinter"): vertical_text_fix = (5 * (int(resize) * barwidth[1])) else: vertical_text_fix = 0 @@ -734,8 +737,10 @@ def encode_upcaeanvar_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight= NumTxtZero = 0 LineTxtStart = ((shiftxy[0] + 2) * int(resize)) LineTxtStartNorm = 2 - if(imageoutlib == "tkinter"): + if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) + elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + LineTxtStart += (1 * int(resize)) upc_print = [0]+list(re.findall("(\\d+)", upc)[0])+[">"] while (NumTxtZero < len(upc_print)): texthidden = False diff --git a/upcean/encode/upce.py b/upcean/encode/upce.py index df71e2eb..7129208c 100644 --- a/upcean/encode/upce.py +++ b/upcean/encode/upce.py @@ -40,6 +40,7 @@ import upcean.encode.ean2 import upcean.encode.ean5 +tkintersupport = upcean.support.check_for_tkinter() pilsupport = upcean.support.check_for_pil() pillowsupport = upcean.support.check_for_pillow() cairosupport = upcean.support.check_for_cairo() @@ -129,9 +130,9 @@ def encode_upce_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 5 vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): vertical_text_fix = (10 * (int(resize) * barwidth[1])) - elif(svgwritesupport and imageoutlib == "svgwrite"): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): vertical_text_fix = (8 * (int(resize) * barwidth[1])) - elif(imageoutlib == "tkinter"): + elif(tkintersupport and imageoutlib == "tkinter"): vertical_text_fix = (5 * (int(resize) * barwidth[1])) else: vertical_text_fix = 0 @@ -416,8 +417,10 @@ def encode_upce_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 5 NumTxtZero = 0 LineTxtStart = ((shiftxy[0] + 1) * int(resize)) LineTxtStartNorm = 1 - if(imageoutlib == "tkinter"): + if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) + elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + LineTxtStart += (1 * int(resize)) upc_print = list(re.findall("(\\d{8})", upc)[0]) while (NumTxtZero < len(upc_print)): texthidden = False diff --git a/upcean/oopfuncs/oopfuncs.py b/upcean/oopfuncs/oopfuncs.py index 001cd065..0a203f85 100644 --- a/upcean/oopfuncs/oopfuncs.py +++ b/upcean/oopfuncs/oopfuncs.py @@ -19,6 +19,7 @@ import upcean.convert import upcean.getprefix import upcean.support +tkintersupport = upcean.support.check_for_tkinter() pilsupport = upcean.support.check_for_pil() pillowsupport = upcean.support.check_for_pillow() cairosupport = upcean.support.check_for_cairo() diff --git a/upcean/predraw/getsfname.py b/upcean/predraw/getsfname.py index efb28ed7..05fcdc59 100644 --- a/upcean/predraw/getsfname.py +++ b/upcean/predraw/getsfname.py @@ -16,6 +16,7 @@ from __future__ import absolute_import, division, print_function, unicode_literals, generators, with_statement, nested_scopes import upcean.support +tkintersupport = upcean.support.check_for_tkinter() pilsupport = upcean.support.check_for_pil() pillowsupport = upcean.support.check_for_pillow() cairosupport = upcean.support.check_for_cairo() diff --git a/upcean/predraw/prefuncs.py b/upcean/predraw/prefuncs.py index 8904bb3c..30e61ae7 100644 --- a/upcean/predraw/prefuncs.py +++ b/upcean/predraw/prefuncs.py @@ -18,8 +18,10 @@ import upcean.fonts import upcean.support +enable_internal_svgwrite = upcean.support.enable_internal_svgwrite # Initialize support flags tkintersupport = upcean.support.check_for_tkinter() +tkintersupport = upcean.support.check_for_tkinter() pilsupport = upcean.support.check_for_pil() pillowsupport = upcean.support.check_for_pillow() cairosupport = upcean.support.check_for_cairo() @@ -128,7 +130,7 @@ logger.warning("skimage support failed to initialize.") # Initialize svgwrite support if available -if svgwritesupport: +if svgwritesupport and not enable_internal_svgwrite: try: import svgwrite import upcean.predraw.presvgwrite diff --git a/upcean/predraw/presvgwrite.py b/upcean/predraw/presvgwrite.py index 00f4e971..3c07ae33 100644 --- a/upcean/predraw/presvgwrite.py +++ b/upcean/predraw/presvgwrite.py @@ -18,9 +18,13 @@ from __future__ import absolute_import, division, print_function, unicode_literals, generators, with_statement, nested_scopes from upcean.xml.downloader import upload_file_to_internet_file import upcean.support -try: - import svgwrite -except ImportError: +enable_internal_svgwrite = upcean.support.enable_internal_svgwrite +if(not enable_internal_svgwrite): + try: + import svgwrite + except ImportError: + import upcean.svgcreate as svgwrite +else: import upcean.svgcreate as svgwrite import os import re diff --git a/upcean/support.py b/upcean/support.py index 1ca890c3..087da24a 100644 --- a/upcean/support.py +++ b/upcean/support.py @@ -37,12 +37,16 @@ def get_importing_script_path(): return os.path.abspath(filename) return None -scriptconf = os.path.join(os.path.dirname(get_importing_script_path()), "upcean.ini") +__use_env_file__ = True +__use_ini_file__ = True +if('PYUPCEAN_CONFIG_FILE' in os.environ and os.path.exists(os.environ['PYUPCEAN_CONFIG_FILE']) and __use_env_file__) + scriptconf = os.path.join(os.path.dirname(get_importing_script_path()), "upcean.ini") +else: + scriptconf = os.path.join(os.path.dirname(get_importing_script_path()), "upcean.ini") if os.path.exists(scriptconf): __config_file__ = scriptconf else: __config_file__ = os.path.join(os.path.dirname(os.path.realpath(__file__)), "upcean.ini") -__use_ini_file__ = True if os.path.exists(__config_file__) and __use_ini_file__: # Create a ConfigParser object @@ -60,6 +64,7 @@ def get_importing_script_path(): enable_pgmagicksupport = config.getboolean('main', 'enable_pgmagicksupport') enable_cv2support = config.getboolean('main', 'enable_cv2support') enable_skimagesupport = config.getboolean('main', 'enable_skimagesupport') + enable_internal_svgwrite = config.getboolean('main', 'enable_internal_svgwrite') else: enable_tkintersupport = True enable_pilsupport = True @@ -71,6 +76,26 @@ def get_importing_script_path(): enable_pgmagicksupport = True enable_cv2support = False enable_skimagesupport = False + enable_internal_svgwrite = False + +if not os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), "predraw", "pretkinter.py")): + enable_tkintersupport = False +if not os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), "predraw", "prepil.py")): + enable_pilsupport = False +if not os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), "predraw", "precairo.py")): + enable_cairosupport = False +if not os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), "predraw", "preqahirah.py")): + enable_qahirahsupport = False +if not os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), "predraw", "prewand.py")): + enable_wandsupport = False +if not os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), "predraw", "premagick.py")): + enable_magicksupport = False +if not os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), "predraw", "prepgmagick.py")): + enable_pgmagicksupport = False +if not os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), "predraw", "precv2.py")): + enable_cv2support = False +if not os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), "predraw", "preskimage.py")): + enable_skimagesupport = False ''' // Barcode Support List ''' bctype_dict = {'EAN2': "ean2", 'UPC2': "upc2", 'UPCS2': "ean2", 'EAN5': "ean5", 'UPC5': "upc5", 'UPCS5': "ean5", 'UPCA': "upca", 'UPCAEan': "upcaean", 'UPCE': "upce", 'EAN13': "ean13", 'EAN8': "ean8", 'STF': "stf", 'ITF': "itf", 'ITF6': "itf6", 'ITF14': "itf14", @@ -155,19 +180,29 @@ def check_for_cairosvg(): cairosvgsupport = False return False -def check_for_svgwrite(): - # SVGWrite Support Check - svgwritesupport = True - try: - import svgwrite +if(not enable_internal_svgwrite): + def check_for_svgwrite(): + # SVGWrite Support Check + svgwritesupport = True + try: + import svgwrite + svgwritesupport = True + except ImportError: + try: + import upcean.svgcreate as svgwrite + svgwritesupport = True + except ImportError: + svgwritesupport = False + return svgwritesupport +else: + def check_for_svgwrite(): svgwritesupport = True - except ImportError: try: import upcean.svgcreate as svgwrite svgwritesupport = True except ImportError: svgwritesupport = False - return svgwritesupport + return svgwritesupport if enable_tkintersupport: def check_for_tkinter(): diff --git a/upcean/upcean.ini b/upcean/upcean.ini index 432c168c..f7b886d5 100644 --- a/upcean/upcean.ini +++ b/upcean/upcean.ini @@ -9,3 +9,4 @@ enable_magicksupport = true enable_pgmagicksupport = true enable_cv2support = false enable_skimagesupport = false +enable_internal_svgwrite = false