diff --git a/upcean/encode/binary.py b/upcean/encode/binary.py index 460d475a..166094a4 100644 --- a/upcean/encode/binary.py +++ b/upcean/encode/binary.py @@ -120,21 +120,16 @@ def encode_binary_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, if(not re.findall("^([0-9]*[\\.]?[0-9])", str(resize)) or int(resize) < 1): resize = 1 if(pilsupport and imageoutlib == "pillow"): - pil_addon_fix = 0 - cairo_addon_fix = 0 + vertical_text_fix = 0 elif((cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")) or (svgwritesupport and cairosvgsupport and imageoutlib == "svgwrite") or (qahirahsupport and imageoutlib == "qahirah")): - pil_addon_fix = 0 - cairo_addon_fix = (9 * (int(resize) * barwidth[1])) + vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): - pil_addon_fix = 0 - cairo_addon_fix = (10 * (int(resize) * barwidth[1])) + vertical_text_fix = (10 * (int(resize) * barwidth[1])) elif(svgwritesupport and imageoutlib == "svgwrite"): - pil_addon_fix = 0 - cairo_addon_fix = (8 * (int(resize) * barwidth[1])) + vertical_text_fix = (8 * (int(resize) * barwidth[1])) else: - pil_addon_fix = 0 - cairo_addon_fix = 0 - cairo_addon_fix += (shiftxy[1] * (int(resize) * barwidth[1])) + vertical_text_fix = 0 + vertical_text_fix += (shiftxy[1] * (int(resize) * barwidth[1])) upc_size_add = (len([item for sublist in upc['code'] for item in sublist]) + shiftxy[0]) * (barwidth[0] * int(resize)) drawColorRectangle(upc_img, 0 + (shiftxy[0] * barwidth[0]) * int(resize), 0 + (shiftxy[1] * barwidth[1]) * int(resize), upc_size_add, ((barheightadd + shiftxy[1]) + ((upc['heightadd'] + shiftxy[1]) * barwidth[1])) * int(resize), barcolor[2], imageoutlib) bari = 0 @@ -172,8 +167,8 @@ def encode_binary_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, if hidetext or (upc['text']['type'][txtbari] == "sn" and (hidesn is None or hidesn)) or (upc['text']['type'][txtbari] == "cd" and (hidecd is None or hidecd)): texthidden = True if(not texthidden): - drawColorText(upc_img, 10 * int(resize * barwidth[1]), (shiftxy[0] + (upc['text']['location'][txtbari] * int(resize))) * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, upc['text']['text'][txtbari], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), (shiftxy[0] + (upc['text']['location'][txtbari] * int(resize))) * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), upc['text']['text'][txtbari], barcolor[1], "ocrb", imageoutlib) txtbari += 1 if((cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg"))): upc_preimg.flush() diff --git a/upcean/encode/codabar.py b/upcean/encode/codabar.py index f62e6932..98f3e816 100644 --- a/upcean/encode/codabar.py +++ b/upcean/encode/codabar.py @@ -128,21 +128,16 @@ def encode_codabar_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48 if(not re.findall("^([0-9]*[\\.]?[0-9])", str(resize)) or int(resize) < 1): resize = 1 if(pilsupport and imageoutlib == "pillow"): - pil_addon_fix = 0 - cairo_addon_fix = 0 + vertical_text_fix = 0 elif((cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")) or (svgwritesupport and cairosvgsupport and imageoutlib == "svgwrite") or (qahirahsupport and imageoutlib == "qahirah")): - pil_addon_fix = 0 - cairo_addon_fix = (9 * (int(resize) * barwidth[1])) + vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): - pil_addon_fix = 0 - cairo_addon_fix = (10 * (int(resize) * barwidth[1])) + vertical_text_fix = (10 * (int(resize) * barwidth[1])) elif(svgwritesupport and imageoutlib == "svgwrite"): - pil_addon_fix = 0 - cairo_addon_fix = (8 * (int(resize) * barwidth[1])) + vertical_text_fix = (8 * (int(resize) * barwidth[1])) else: - pil_addon_fix = 0 - cairo_addon_fix = 0 - cairo_addon_fix += (shiftxy[1] * (int(resize) * barwidth[1])) + vertical_text_fix = 0 + vertical_text_fix += (shiftxy[1] * (int(resize) * barwidth[1])) pre_upc_matches = upc_matches = re.findall( "^([a-dA-DeEnN\\*tT])([0-9\\-\\$\\:\\/\\.\\+]+)([a-dA-DeEnN\\*tT])$", upc) pre_upc_matches = pre_upc_matches[0] @@ -290,8 +285,8 @@ def encode_codabar_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48 if hidetext or (NumTxtZero == 0 and (hidesn is None or hidesn)) or (NumTxtZero == 11 and (hidecd is None or hidecd)): texthidden = True if(not texthidden): - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, upc_matches[NumTxtZero], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), upc_matches[NumTxtZero], barcolor[1], "ocrb", imageoutlib) upc_array['text']['location'].append(LineTxtStartNorm) upc_array['text']['text'].append(upc_matches[NumTxtZero]) upc_array['text']['type'].append("txt") diff --git a/upcean/encode/code11.py b/upcean/encode/code11.py index 359533ba..f683791b 100644 --- a/upcean/encode/code11.py +++ b/upcean/encode/code11.py @@ -134,21 +134,16 @@ def encode_code11_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, if(not re.findall("^([0-9]*[\\.]?[0-9])", str(resize)) or int(resize) < 1): resize = 1 if(pilsupport and imageoutlib == "pillow"): - pil_addon_fix = 0 - cairo_addon_fix = 0 + vertical_text_fix = 0 elif((cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")) or (svgwritesupport and cairosvgsupport and imageoutlib == "svgwrite") or (qahirahsupport and imageoutlib == "qahirah")): - pil_addon_fix = 0 - cairo_addon_fix = (9 * (int(resize) * barwidth[1])) + vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): - pil_addon_fix = 0 - cairo_addon_fix = (10 * (int(resize) * barwidth[1])) + vertical_text_fix = (10 * (int(resize) * barwidth[1])) elif(svgwritesupport and imageoutlib == "svgwrite"): - pil_addon_fix = 0 - cairo_addon_fix = (8 * (int(resize) * barwidth[1])) + vertical_text_fix = (8 * (int(resize) * barwidth[1])) else: - pil_addon_fix = 0 - cairo_addon_fix = 0 - cairo_addon_fix += (shiftxy[1] * (int(resize) * barwidth[1])) + vertical_text_fix = 0 + vertical_text_fix += (shiftxy[1] * (int(resize) * barwidth[1])) upc = upc.upper() upc_matches = list(upc) upc_print = upc_matches @@ -259,8 +254,8 @@ def encode_code11_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, if hidetext or (NumTxtZero == 0 and (hidesn is None or hidesn)) or (NumTxtZero == 11 and (hidecd is None or hidecd)): texthidden = True if(not texthidden): - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, upc_print[NumTxtZero], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), upc_print[NumTxtZero], barcolor[1], "ocrb", imageoutlib) upc_array['text']['location'].append(LineTxtStartNorm) upc_array['text']['text'].append(upc_print[NumTxtZero]) upc_array['text']['type'].append("txt") diff --git a/upcean/encode/code128.py b/upcean/encode/code128.py index 6cb96096..c04b0ce2 100644 --- a/upcean/encode/code128.py +++ b/upcean/encode/code128.py @@ -131,21 +131,16 @@ def encode_code128_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48 if(not re.findall("^([0-9]*[\\.]?[0-9])", str(resize)) or int(resize) < 1): resize = 1 if(pilsupport and imageoutlib == "pillow"): - pil_addon_fix = 0 - cairo_addon_fix = 0 + vertical_text_fix = 0 elif((cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")) or (svgwritesupport and cairosvgsupport and imageoutlib == "svgwrite") or (qahirahsupport and imageoutlib == "qahirah")): - pil_addon_fix = 0 - cairo_addon_fix = (9 * (int(resize) * barwidth[1])) + vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): - pil_addon_fix = 0 - cairo_addon_fix = (10 * (int(resize) * barwidth[1])) + vertical_text_fix = (10 * (int(resize) * barwidth[1])) elif(svgwritesupport and imageoutlib == "svgwrite"): - pil_addon_fix = 0 - cairo_addon_fix = (8 * (int(resize) * barwidth[1])) + vertical_text_fix = (8 * (int(resize) * barwidth[1])) else: - pil_addon_fix = 0 - cairo_addon_fix = 0 - cairo_addon_fix += (shiftxy[1] * (int(resize) * barwidth[1])) + vertical_text_fix = 0 + vertical_text_fix += (shiftxy[1] * (int(resize) * barwidth[1])) upc = upc.lower() if(not re.findall("[0-9a-f]{2}", upc)): return False @@ -591,8 +586,8 @@ def encode_code128_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48 texthidden = True if(len(upc_print[NumTxtZero]) == 1): if(not texthidden): - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, upc_print[NumTxtZero], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), upc_print[NumTxtZero], barcolor[1], "ocrb", imageoutlib) upc_array['text']['location'].append(LineTxtStartNorm) upc_array['text']['text'].append(upc_print[NumTxtZero]) upc_array['text']['type'].append("txt") @@ -600,8 +595,8 @@ def encode_code128_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48 LineTxtStartNorm += 11 if(len(upc_print[NumTxtZero]) == 2): if(not texthidden): - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, upc_print[NumTxtZero][0], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), upc_print[NumTxtZero][0], barcolor[1], "ocrb", imageoutlib) LineTxtStart += 6 * int(resize) upc_array['text']['location'].append(LineTxtStartNorm) upc_array['text']['text'].append(upc_print[NumTxtZero][0]) @@ -609,8 +604,8 @@ def encode_code128_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48 LineTxtStart += 11 * int(resize) LineTxtStartNorm += 6 if(not texthidden): - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, upc_print[NumTxtZero][1], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), upc_print[NumTxtZero][1], barcolor[1], "ocrb", imageoutlib) LineTxtStart += 5 * int(resize) upc_array['text']['location'].append(LineTxtStartNorm) upc_array['text']['text'].append(upc_print[NumTxtZero][1]) @@ -774,21 +769,16 @@ def encode_code128old_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight= if(not re.findall("^([0-9]*[\\.]?[0-9])", str(resize)) or int(resize) < 1): resize = 1 if(pilsupport and imageoutlib == "pillow"): - pil_addon_fix = 0 - cairo_addon_fix = 0 + vertical_text_fix = 0 elif((cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")) or (svgwritesupport and cairosvgsupport and imageoutlib == "svgwrite") or (qahirahsupport and imageoutlib == "qahirah")): - pil_addon_fix = 0 - cairo_addon_fix = (9 * (int(resize) * barwidth[1])) + vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): - pil_addon_fix = 0 - cairo_addon_fix = (10 * (int(resize) * barwidth[1])) + vertical_text_fix = (10 * (int(resize) * barwidth[1])) elif(svgwritesupport and imageoutlib == "svgwrite"): - pil_addon_fix = 0 - cairo_addon_fix = (8 * (int(resize) * barwidth[1])) + vertical_text_fix = (8 * (int(resize) * barwidth[1])) else: - pil_addon_fix = 0 - cairo_addon_fix = 0 - cairo_addon_fix += (shiftxy[1] * (int(resize) * barwidth[1])) + vertical_text_fix = 0 + vertical_text_fix += (shiftxy[1] * (int(resize) * barwidth[1])) upc = upc.lower() if(not re.findall("[0-9a-f]{2}", upc)): return False @@ -1152,24 +1142,24 @@ def encode_code128old_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight= upc_print.reverse() while (NumTxtZero < len(upc_print)): if(len(upc_print[NumTxtZero]) == 1): - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, upc_print[NumTxtZero], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), upc_print[NumTxtZero], barcolor[1], "ocrb", imageoutlib) upc_array['text']['location'].append(LineTxtStartNorm) upc_array['text']['text'].append(upc_print[NumTxtZero]) upc_array['text']['type'].append("txt") LineTxtStart += 11 * int(resize) LineTxtStartNorm += 11 if(len(upc_print[NumTxtZero]) == 2): - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, upc_print[NumTxtZero][0], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), upc_print[NumTxtZero][0], barcolor[1], "ocrb", imageoutlib) LineTxtStart += 6 * int(resize) upc_array['text']['location'].append(LineTxtStartNorm) upc_array['text']['text'].append(upc_print[NumTxtZero][0]) upc_array['text']['type'].append("txt") LineTxtStart += 11 * int(resize) LineTxtStartNorm += 6 - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, upc_print[NumTxtZero][1], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), upc_print[NumTxtZero][1], barcolor[1], "ocrb", imageoutlib) LineTxtStart += 5 * int(resize) upc_array['text']['location'].append(LineTxtStartNorm) upc_array['text']['text'].append(upc_print[NumTxtZero][1]) diff --git a/upcean/encode/code32.py b/upcean/encode/code32.py index db21d546..af4d4992 100644 --- a/upcean/encode/code32.py +++ b/upcean/encode/code32.py @@ -131,21 +131,16 @@ def encode_code32_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, if(not re.findall("^([0-9]*[\\.]?[0-9])", str(resize)) or int(resize) < 1): resize = 1 if(pilsupport and imageoutlib == "pillow"): - pil_addon_fix = 0 - cairo_addon_fix = 0 + vertical_text_fix = 0 elif((cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")) or (svgwritesupport and cairosvgsupport and imageoutlib == "svgwrite") or (qahirahsupport and imageoutlib == "qahirah")): - pil_addon_fix = 0 - cairo_addon_fix = (9 * (int(resize) * barwidth[1])) + vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): - pil_addon_fix = 0 - cairo_addon_fix = (10 * (int(resize) * barwidth[1])) + vertical_text_fix = (10 * (int(resize) * barwidth[1])) elif(svgwritesupport and imageoutlib == "svgwrite"): - pil_addon_fix = 0 - cairo_addon_fix = (8 * (int(resize) * barwidth[1])) + vertical_text_fix = (8 * (int(resize) * barwidth[1])) else: - pil_addon_fix = 0 - cairo_addon_fix = 0 - cairo_addon_fix += (shiftxy[1] * (int(resize) * barwidth[1])) + vertical_text_fix = 0 + vertical_text_fix += (shiftxy[1] * (int(resize) * barwidth[1])) upc = upc.upper() upc_matches = list(upc) upc_size_add = ((len(upc_matches) * 15) + @@ -300,8 +295,8 @@ def encode_code32_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, if hidetext or (NumTxtZero == 0 and (hidesn is None or hidesn)) or (NumTxtZero == 11 and (hidecd is None or hidecd)): texthidden = True if(not texthidden): - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, upc_matches[NumTxtZero], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), upc_matches[NumTxtZero], barcolor[1], "ocrb", imageoutlib) upc_array['text']['location'].append(LineTxtStartNorm) upc_array['text']['text'].append(upc_matches[NumTxtZero]) upc_array['text']['type'].append("txt") diff --git a/upcean/encode/code39.py b/upcean/encode/code39.py index 1b4c1442..efdf0dff 100644 --- a/upcean/encode/code39.py +++ b/upcean/encode/code39.py @@ -131,21 +131,16 @@ def encode_code39_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, if(not re.findall("^([0-9]*[\\.]?[0-9])", str(resize)) or int(resize) < 1): resize = 1 if(pilsupport and imageoutlib == "pillow"): - pil_addon_fix = 0 - cairo_addon_fix = 0 + vertical_text_fix = 0 elif((cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")) or (svgwritesupport and cairosvgsupport and imageoutlib == "svgwrite") or (qahirahsupport and imageoutlib == "qahirah")): - pil_addon_fix = 0 - cairo_addon_fix = (9 * (int(resize) * barwidth[1])) + vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): - pil_addon_fix = 0 - cairo_addon_fix = (10 * (int(resize) * barwidth[1])) + vertical_text_fix = (10 * (int(resize) * barwidth[1])) elif(svgwritesupport and imageoutlib == "svgwrite"): - pil_addon_fix = 0 - cairo_addon_fix = (8 * (int(resize) * barwidth[1])) + vertical_text_fix = (8 * (int(resize) * barwidth[1])) else: - pil_addon_fix = 0 - cairo_addon_fix = 0 - cairo_addon_fix += (shiftxy[1] * (int(resize) * barwidth[1])) + vertical_text_fix = 0 + vertical_text_fix += (shiftxy[1] * (int(resize) * barwidth[1])) upc = upc.upper() upc_matches = list(upc) upc_size_add = ((len(upc_matches) * 15) + @@ -317,8 +312,8 @@ def encode_code39_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, NumTxtZero = 0 LineTxtStart = ((shiftxy[0] + 15) * int(resize)) LineTxtStartNorm = 15 - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, "*", barcolor[1], "ocrb", imageoutlib) + 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) upc_array['text']['text'].append("*") upc_array['text']['type'].append("sn") @@ -329,16 +324,16 @@ def encode_code39_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, if hidetext or (NumTxtZero == 0 and (hidesn is None or hidesn)) or (NumTxtZero == 11 and (hidecd is None or hidecd)): texthidden = True if(not texthidden): - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, upc_matches[NumTxtZero], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), upc_matches[NumTxtZero], barcolor[1], "ocrb", imageoutlib) upc_array['text']['location'].append(LineTxtStartNorm) upc_array['text']['text'].append(upc_matches[NumTxtZero]) upc_array['text']['type'].append("txt") LineTxtStart += 16 * int(resize) LineTxtStartNorm += 16 NumTxtZero += 1 - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, "*", barcolor[1], "ocrb", imageoutlib) + 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) upc_array['text']['text'].append("*") upc_array['text']['type'].append("cd") @@ -495,21 +490,16 @@ def encode_code39extended_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barhei if(not re.findall("^([0-9]*[\\.]?[0-9])", str(resize)) or int(resize) < 1): resize = 1 if(pilsupport and imageoutlib == "pillow"): - pil_addon_fix = 0 - cairo_addon_fix = 0 + vertical_text_fix = 0 elif((cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")) or (svgwritesupport and cairosvgsupport and imageoutlib == "svgwrite") or (qahirahsupport and imageoutlib == "qahirah")): - pil_addon_fix = 0 - cairo_addon_fix = (9 * (int(resize) * barwidth[1])) + vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): - pil_addon_fix = 0 - cairo_addon_fix = (10 * (int(resize) * barwidth[1])) + vertical_text_fix = (10 * (int(resize) * barwidth[1])) elif(svgwritesupport and imageoutlib == "svgwrite"): - pil_addon_fix = 0 - cairo_addon_fix = (8 * (int(resize) * barwidth[1])) + vertical_text_fix = (8 * (int(resize) * barwidth[1])) else: - pil_addon_fix = 0 - cairo_addon_fix = 0 - cairo_addon_fix += (shiftxy[1] * (int(resize) * barwidth[1])) + vertical_text_fix = 0 + vertical_text_fix += (shiftxy[1] * (int(resize) * barwidth[1])) upc = upc.upper() upc_matches = list(upc) upc_size_add = ((len(upc_matches) * 15) + @@ -683,8 +673,8 @@ def encode_code39extended_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barhei NumTxtZero = 0 LineTxtStart = ((shiftxy[0] + 15) * int(resize)) LineTxtStartNorm = 15 - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, "*", barcolor[1], "ocrb", imageoutlib) + 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) upc_array['text']['text'].append("*") upc_array['text']['type'].append("sn") @@ -696,25 +686,25 @@ def encode_code39extended_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barhei if(NumTxtZeroNext < len(upc_matches) and code39extended.get(upc_matches[NumTxtZero]+upc_matches[NumTxtZeroNext], False)): LineTxtStart += 16 * int(resize) LineTxtStartNorm += 16 - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, code39extended.get(upc_matches[NumTxtZero]+upc_matches[NumTxtZeroNext], " "), barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), code39extended.get(upc_matches[NumTxtZero]+upc_matches[NumTxtZeroNext], " "), barcolor[1], "ocrb", imageoutlib) NumTxtZero += 1 else: - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, code39extended.get(upc_matches[NumTxtZero], upc_matches[NumTxtZero]), barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), code39extended.get(upc_matches[NumTxtZero], upc_matches[NumTxtZero]), barcolor[1], "ocrb", imageoutlib) if hidetext or (NumTxtZero == 0 and (hidesn is None or hidesn)) or (NumTxtZero == 11 and (hidecd is None or hidecd)): texthidden = True if(not texthidden): - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, upc_matches[NumTxtZero], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), upc_matches[NumTxtZero], barcolor[1], "ocrb", imageoutlib) upc_array['text']['location'].append(LineTxtStartNorm) upc_array['text']['text'].append(upc_matches[NumTxtZero]) upc_array['text']['type'].append("txt") LineTxtStart += 16 * int(resize) LineTxtStartNorm += 16 NumTxtZero += 1 - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, "*", barcolor[1], "ocrb", imageoutlib) + 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) upc_array['text']['text'].append("*") upc_array['text']['type'].append("cd") diff --git a/upcean/encode/code93.py b/upcean/encode/code93.py index 4ccdb736..f05d1735 100644 --- a/upcean/encode/code93.py +++ b/upcean/encode/code93.py @@ -130,21 +130,16 @@ def encode_code93_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, if(not re.findall("^([0-9]*[\\.]?[0-9])", str(resize)) or int(resize) < 1): resize = 1 if(pilsupport and imageoutlib == "pillow"): - pil_addon_fix = 0 - cairo_addon_fix = 0 + vertical_text_fix = 0 elif((cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")) or (svgwritesupport and cairosvgsupport and imageoutlib == "svgwrite") or (qahirahsupport and imageoutlib == "qahirah")): - pil_addon_fix = 0 - cairo_addon_fix = (9 * (int(resize) * barwidth[1])) + vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): - pil_addon_fix = 0 - cairo_addon_fix = (10 * (int(resize) * barwidth[1])) + vertical_text_fix = (10 * (int(resize) * barwidth[1])) elif(svgwritesupport and imageoutlib == "svgwrite"): - pil_addon_fix = 0 - cairo_addon_fix = (8 * (int(resize) * barwidth[1])) + vertical_text_fix = (8 * (int(resize) * barwidth[1])) else: - pil_addon_fix = 0 - cairo_addon_fix = 0 - cairo_addon_fix += (shiftxy[1] * (int(resize) * barwidth[1])) + vertical_text_fix = 0 + vertical_text_fix += (shiftxy[1] * (int(resize) * barwidth[1])) upc = upc.upper() upc_matches = list(upc) if(len(upc_matches) <= 0): @@ -330,8 +325,8 @@ def encode_code93_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, if hidetext or (NumTxtZero == 0 and (hidesn is None or hidesn)) or (NumTxtZero == 11 and (hidecd is None or hidecd)): texthidden = True if(not texthidden): - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, upc_matches[NumTxtZero], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), upc_matches[NumTxtZero], barcolor[1], "ocrb", imageoutlib) upc_array['text']['location'].append(LineTxtStartNorm) upc_array['text']['text'].append(upc_matches[NumTxtZero]) upc_array['text']['type'].append("txt") @@ -493,21 +488,16 @@ def encode_code93extended_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barhei if(not re.findall("^([0-9]*[\\.]?[0-9])", str(resize)) or int(resize) < 1): resize = 1 if(pilsupport and imageoutlib == "pillow"): - pil_addon_fix = 0 - cairo_addon_fix = 0 + vertical_text_fix = 0 elif((cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")) or (svgwritesupport and cairosvgsupport and imageoutlib == "svgwrite") or (qahirahsupport and imageoutlib == "qahirah")): - pil_addon_fix = 0 - cairo_addon_fix = (9 * (int(resize) * barwidth[1])) + vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): - pil_addon_fix = 0 - cairo_addon_fix = (10 * (int(resize) * barwidth[1])) + vertical_text_fix = (10 * (int(resize) * barwidth[1])) elif(svgwritesupport and imageoutlib == "svgwrite"): - pil_addon_fix = 0 - cairo_addon_fix = (8 * (int(resize) * barwidth[1])) + vertical_text_fix = (8 * (int(resize) * barwidth[1])) else: - pil_addon_fix = 0 - cairo_addon_fix = 0 - cairo_addon_fix += (shiftxy[1] * (int(resize) * barwidth[1])) + vertical_text_fix = 0 + vertical_text_fix += (shiftxy[1] * (int(resize) * barwidth[1])) upc = upc.upper() upc_matches = list(upc) if(len(upc_matches) <= 0): @@ -698,17 +688,17 @@ def encode_code93extended_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barhei if(NumTxtZeroNext < len(upc_matches) and code93extended.get(upc_matches[NumTxtZero]+upc_matches[NumTxtZeroNext], False)): LineTxtStart += 16 * int(resize) LineTxtStartNorm += 16 - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, code93extended.get(upc_matches[NumTxtZero]+upc_matches[NumTxtZeroNext], " "), barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), code93extended.get(upc_matches[NumTxtZero]+upc_matches[NumTxtZeroNext], " "), barcolor[1], "ocrb", imageoutlib) NumTxtZero += 1 else: - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, code93extended.get(upc_matches[NumTxtZero], upc_matches[NumTxtZero]), barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), code93extended.get(upc_matches[NumTxtZero], upc_matches[NumTxtZero]), barcolor[1], "ocrb", imageoutlib) if hidetext or (NumTxtZero == 0 and (hidesn is None or hidesn)) or (NumTxtZero == 11 and (hidecd is None or hidecd)): texthidden = True if(not texthidden): - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, upc_matches[NumTxtZero], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), upc_matches[NumTxtZero], barcolor[1], "ocrb", imageoutlib) upc_array['text']['location'].append(LineTxtStartNorm) upc_array['text']['text'].append(upc_matches[NumTxtZero]) upc_array['text']['type'].append("txt") diff --git a/upcean/encode/ean13.py b/upcean/encode/ean13.py index d0b7a4ff..cd8fa070 100644 --- a/upcean/encode/ean13.py +++ b/upcean/encode/ean13.py @@ -150,21 +150,16 @@ def encode_ean13_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, if(not re.findall("^([0-9]*[\\.]?[0-9])", str(resize)) or int(resize) < 1): resize = 1 if(pilsupport and imageoutlib == "pillow"): - pil_addon_fix = 0 - cairo_addon_fix = 0 + vertical_text_fix = 0 elif((cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")) or (svgwritesupport and cairosvgsupport and imageoutlib == "svgwrite") or (qahirahsupport and imageoutlib == "qahirah")): - pil_addon_fix = 0 - cairo_addon_fix = (9 * (int(resize) * barwidth[1])) + vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): - pil_addon_fix = 0 - cairo_addon_fix = (10 * (int(resize) * barwidth[1])) + vertical_text_fix = (10 * (int(resize) * barwidth[1])) elif(svgwritesupport and imageoutlib == "svgwrite"): - pil_addon_fix = 0 - cairo_addon_fix = (8 * (int(resize) * barwidth[1])) + vertical_text_fix = (8 * (int(resize) * barwidth[1])) else: - pil_addon_fix = 0 - cairo_addon_fix = 0 - cairo_addon_fix += (shiftxy[1] * (int(resize) * barwidth[1])) + vertical_text_fix = 0 + vertical_text_fix += (shiftxy[1] * (int(resize) * barwidth[1])) upc_matches = re.findall("(\\d{1})(\\d{6})(\\d{6})", upc) if(len(upc_matches) <= 0): return False @@ -431,8 +426,8 @@ def encode_ean13_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, if hidetext or (NumTxtZero == 0 and (hidesn is None or hidesn)) or (NumTxtZero == 13 and (hidecd is None or hidecd)): texthidden = True if(not texthidden): - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, upc_print[NumTxtZero], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), upc_print[NumTxtZero], barcolor[1], "ocrb", imageoutlib) upc_array['text']['location'].append(LineTxtStartNorm) upc_array['text']['text'].append(upc_print[NumTxtZero]) if(NumTxtZero == 0): diff --git a/upcean/encode/ean2.py b/upcean/encode/ean2.py index 83e29223..4c716f79 100644 --- a/upcean/encode/ean2.py +++ b/upcean/encode/ean2.py @@ -127,21 +127,16 @@ def encode_ean2_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 5 if(not re.findall("^([0-9]*[\\.]?[0-9])", str(resize)) or int(resize) < 1): resize = 1 if(pilsupport and imageoutlib == "pillow"): - pil_addon_fix = 0 - cairo_addon_fix = 0 + vertical_text_fix = 0 elif((cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")) or (svgwritesupport and cairosvgsupport and imageoutlib == "svgwrite") or (qahirahsupport and imageoutlib == "qahirah")): - pil_addon_fix = 0 - cairo_addon_fix = (9 * (int(resize) * barwidth[1])) + vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): - pil_addon_fix = 0 - cairo_addon_fix = (10 * (int(resize) * barwidth[1])) + vertical_text_fix = (10 * (int(resize) * barwidth[1])) elif(svgwritesupport and imageoutlib == "svgwrite"): - pil_addon_fix = 0 - cairo_addon_fix = (8 * (int(resize) * barwidth[1])) + vertical_text_fix = (8 * (int(resize) * barwidth[1])) else: - pil_addon_fix = 0 - cairo_addon_fix = 0 - cairo_addon_fix += (shiftxy[1] * (int(resize) * barwidth[1])) + vertical_text_fix = 0 + vertical_text_fix += (shiftxy[1] * (int(resize) * barwidth[1])) CheckSum = int(upc_matches[0]) % 4 LeftDigit = list(upc_matches[0]) upc_size_add = 0 @@ -284,8 +279,8 @@ def encode_ean2_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 5 if hidetext: texthidden = True if(not texthidden): - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - (barheight[0]) * int(resize)) + pil_addon_fix, upc_print[NumTxtZero], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + (barheight[0]) * int(resize)), upc_print[NumTxtZero], barcolor[1], "ocrb", imageoutlib) upc_array['text']['location'].append(LineTxtStartNorm) upc_array['text']['text'].append(upc_print[NumTxtZero]) upc_array['text']['type'].append("txt") diff --git a/upcean/encode/ean5.py b/upcean/encode/ean5.py index b4195490..03f4d07a 100644 --- a/upcean/encode/ean5.py +++ b/upcean/encode/ean5.py @@ -128,21 +128,16 @@ def encode_ean5_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 5 if(not re.findall("^([0-9]*[\\.]?[0-9])", str(resize)) or int(resize) < 1): resize = 1 if(pilsupport and imageoutlib == "pillow"): - pil_addon_fix = 0 - cairo_addon_fix = 0 + vertical_text_fix = 0 elif((cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")) or (svgwritesupport and cairosvgsupport and imageoutlib == "svgwrite") or (qahirahsupport and imageoutlib == "qahirah")): - pil_addon_fix = 0 - cairo_addon_fix = (9 * (int(resize) * barwidth[1])) + vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): - pil_addon_fix = 0 - cairo_addon_fix = (10 * (int(resize) * barwidth[1])) + vertical_text_fix = (10 * (int(resize) * barwidth[1])) elif(svgwritesupport and imageoutlib == "svgwrite"): - pil_addon_fix = 0 - cairo_addon_fix = (8 * (int(resize) * barwidth[1])) + vertical_text_fix = (8 * (int(resize) * barwidth[1])) else: - pil_addon_fix = 0 - cairo_addon_fix = 0 - cairo_addon_fix += (shiftxy[1] * (int(resize) * barwidth[1])) + vertical_text_fix = 0 + vertical_text_fix += (shiftxy[1] * (int(resize) * barwidth[1])) LeftDigit = list(upc_matches[0]) CheckSum = (int(LeftDigit[0]) * 3) + (int(LeftDigit[1]) * 9) + ( int(LeftDigit[2]) * 3) + (int(LeftDigit[3]) * 9) + (int(LeftDigit[4]) * 3) @@ -371,8 +366,8 @@ def encode_ean5_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 5 if hidetext: texthidden = True if(not texthidden): - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - (barheight[0]) * int(resize)) + pil_addon_fix, upc_print[NumTxtZero], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + (barheight[0]) * int(resize)), upc_print[NumTxtZero], barcolor[1], "ocrb", imageoutlib) upc_array['text']['location'].append(LineTxtStartNorm) upc_array['text']['text'].append(upc_print[NumTxtZero]) upc_array['text']['type'].append("txt") diff --git a/upcean/encode/ean8.py b/upcean/encode/ean8.py index dec2477a..84bccdef 100644 --- a/upcean/encode/ean8.py +++ b/upcean/encode/ean8.py @@ -150,21 +150,16 @@ def encode_ean8_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 5 if(not re.findall("^([0-9]*[\\.]?[0-9])", str(resize)) or int(resize) < 1): resize = 1 if(pilsupport and imageoutlib == "pillow"): - pil_addon_fix = 0 - cairo_addon_fix = 0 + vertical_text_fix = 0 elif((cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")) or (svgwritesupport and cairosvgsupport and imageoutlib == "svgwrite") or (qahirahsupport and imageoutlib == "qahirah")): - pil_addon_fix = 0 - cairo_addon_fix = (9 * (int(resize) * barwidth[1])) + vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): - pil_addon_fix = 0 - cairo_addon_fix = (10 * (int(resize) * barwidth[1])) + vertical_text_fix = (10 * (int(resize) * barwidth[1])) elif(svgwritesupport and imageoutlib == "svgwrite"): - pil_addon_fix = 0 - cairo_addon_fix = (8 * (int(resize) * barwidth[1])) + vertical_text_fix = (8 * (int(resize) * barwidth[1])) else: - pil_addon_fix = 0 - cairo_addon_fix = 0 - cairo_addon_fix += (shiftxy[1] * (int(resize) * barwidth[1])) + vertical_text_fix = 0 + vertical_text_fix += (shiftxy[1] * (int(resize) * barwidth[1])) upc_matches = re.findall("(\\d{4})(\\d{4})", upc) upc_matches = upc_matches[0] if(len(upc_matches) <= 0): @@ -438,8 +433,8 @@ def encode_ean8_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 5 if hidetext or (NumTxtZero == 0 and (hidesn is None or hidesn)) or (NumTxtZero == 9 and (hidecd is None or hidecd)): texthidden = True if(not texthidden): - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, upc_print[NumTxtZero], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), upc_print[NumTxtZero], barcolor[1], "ocrb", imageoutlib) upc_array['text']['location'].append(LineTxtStartNorm) upc_array['text']['text'].append(upc_print[NumTxtZero]) if(NumTxtZero == 0): diff --git a/upcean/encode/itf.py b/upcean/encode/itf.py index 5095dee6..2417b9b3 100644 --- a/upcean/encode/itf.py +++ b/upcean/encode/itf.py @@ -134,21 +134,16 @@ def encode_itf_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 54 if(not re.findall("^([0-9]*[\\.]?[0-9])", str(resize)) or int(resize) < 1): resize = 1 if(pilsupport and imageoutlib == "pillow"): - pil_addon_fix = 0 - cairo_addon_fix = 0 + vertical_text_fix = 0 elif((cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")) or (svgwritesupport and cairosvgsupport and imageoutlib == "svgwrite") or (qahirahsupport and imageoutlib == "qahirah")): - pil_addon_fix = 0 - cairo_addon_fix = (9 * (int(resize) * barwidth[1])) + vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): - pil_addon_fix = 0 - cairo_addon_fix = (10 * (int(resize) * barwidth[1])) + vertical_text_fix = (10 * (int(resize) * barwidth[1])) elif(svgwritesupport and imageoutlib == "svgwrite"): - pil_addon_fix = 0 - cairo_addon_fix = (8 * (int(resize) * barwidth[1])) + vertical_text_fix = (8 * (int(resize) * barwidth[1])) else: - pil_addon_fix = 0 - cairo_addon_fix = 0 - cairo_addon_fix += (shiftxy[1] * (int(resize) * barwidth[1])) + vertical_text_fix = 0 + vertical_text_fix += (shiftxy[1] * (int(resize) * barwidth[1])) upc_matches = re.findall("([0-9]{2})", upc) if(threewidebar): upc_size_add = (len(upc_matches) * 18) * barwidth[0] @@ -326,8 +321,8 @@ def encode_itf_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 54 if hidetext or (NumTxtZero == 0 and (hidesn is None or hidesn)) or (NumTxtZero == 11 and (hidecd is None or hidecd)): texthidden = True if(not texthidden): - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, ArrayDigit[0], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), ArrayDigit[0], barcolor[1], "ocrb", imageoutlib) upc_array['text']['location'].append(LineTxtStartNorm) upc_array['text']['text'].append(ArrayDigit[0]) upc_array['text']['type'].append("txt") @@ -338,8 +333,8 @@ def encode_itf_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 54 LineTxtStart += 7 * int(resize) LineTxtStartNorm += 7 if(not texthidden): - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, ArrayDigit[1], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), ArrayDigit[1], barcolor[1], "ocrb", imageoutlib) upc_array['text']['location'].append(LineTxtStartNorm) upc_array['text']['text'].append(ArrayDigit[1]) upc_array['text']['type'].append("txt") diff --git a/upcean/encode/itf14.py b/upcean/encode/itf14.py index c97cd143..c407646c 100644 --- a/upcean/encode/itf14.py +++ b/upcean/encode/itf14.py @@ -134,21 +134,16 @@ def encode_itf14_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, if(not re.findall("^([0-9]*[\\.]?[0-9])", str(resize)) or int(resize) < 1): resize = 1 if(pilsupport and imageoutlib == "pillow"): - pil_addon_fix = 0 - cairo_addon_fix = 0 + vertical_text_fix = 0 elif((cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")) or (svgwritesupport and cairosvgsupport and imageoutlib == "svgwrite") or (qahirahsupport and imageoutlib == "qahirah")): - pil_addon_fix = 0 - cairo_addon_fix = (9 * (int(resize) * barwidth[1])) + vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): - pil_addon_fix = 0 - cairo_addon_fix = (10 * (int(resize) * barwidth[1])) + vertical_text_fix = (10 * (int(resize) * barwidth[1])) elif(svgwritesupport and imageoutlib == "svgwrite"): - pil_addon_fix = 0 - cairo_addon_fix = (8 * (int(resize) * barwidth[1])) + vertical_text_fix = (8 * (int(resize) * barwidth[1])) else: - pil_addon_fix = 0 - cairo_addon_fix = 0 - cairo_addon_fix += (shiftxy[1] * (int(resize) * barwidth[1])) + vertical_text_fix = 0 + vertical_text_fix += (shiftxy[1] * (int(resize) * barwidth[1])) upc_matches = re.findall("([0-9]{2})", upc) if(threewidebar): upc_size_add = (len(upc_matches) * 18) * barwidth[0] @@ -334,8 +329,8 @@ def encode_itf14_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, if hidetext or (NumTxtZero == 0 and (hidesn is None or hidesn)) or (NumTxtZero == 11 and (hidecd is None or hidecd)): texthidden = True if(not texthidden): - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, ArrayDigit[0], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), ArrayDigit[0], barcolor[1], "ocrb", imageoutlib) upc_array['text']['location'].append(LineTxtStartNorm) upc_array['text']['text'].append(ArrayDigit[0]) upc_array['text']['type'].append("txt") @@ -346,8 +341,8 @@ def encode_itf14_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, LineTxtStart += 7 * int(resize) LineTxtStartNorm += 7 if(not texthidden): - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, ArrayDigit[1], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), ArrayDigit[1], barcolor[1], "ocrb", imageoutlib) upc_array['text']['location'].append(LineTxtStartNorm) upc_array['text']['text'].append(ArrayDigit[1]) upc_array['text']['type'].append("txt") diff --git a/upcean/encode/msi.py b/upcean/encode/msi.py index c9a4585c..20458a29 100644 --- a/upcean/encode/msi.py +++ b/upcean/encode/msi.py @@ -128,21 +128,16 @@ def encode_msi_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 54 if(not re.findall("^([0-9]*[\\.]?[0-9])", str(resize)) or int(resize) < 1): resize = 1 if(pilsupport and imageoutlib == "pillow"): - pil_addon_fix = 0 - cairo_addon_fix = 0 + vertical_text_fix = 0 elif((cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")) or (svgwritesupport and cairosvgsupport and imageoutlib == "svgwrite") or (qahirahsupport and imageoutlib == "qahirah")): - pil_addon_fix = 0 - cairo_addon_fix = (9 * (int(resize) * barwidth[1])) + vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): - pil_addon_fix = 0 - cairo_addon_fix = (10 * (int(resize) * barwidth[1])) + vertical_text_fix = (10 * (int(resize) * barwidth[1])) elif(svgwritesupport and imageoutlib == "svgwrite"): - pil_addon_fix = 0 - cairo_addon_fix = (8 * (int(resize) * barwidth[1])) + vertical_text_fix = (8 * (int(resize) * barwidth[1])) else: - pil_addon_fix = 0 - cairo_addon_fix = 0 - cairo_addon_fix += (shiftxy[1] * (int(resize) * barwidth[1])) + vertical_text_fix = 0 + vertical_text_fix += (shiftxy[1] * (int(resize) * barwidth[1])) upc = upc.upper() upc_matches = list(upc) upc_print = list(upc_matches) @@ -240,8 +235,8 @@ def encode_msi_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 54 if hidetext or (NumTxtZero == 0 and (hidesn is None or hidesn)) or (NumTxtZero == 11 and (hidecd is None or hidecd)): texthidden = True if(not texthidden): - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, upc_print[NumTxtZero], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), upc_print[NumTxtZero], barcolor[1], "ocrb", imageoutlib) upc_array['text']['location'].append(LineTxtStartNorm) upc_array['text']['text'].append(upc_print[NumTxtZero]) upc_array['text']['type'].append("txt") diff --git a/upcean/encode/plessey.py b/upcean/encode/plessey.py index ffe66094..776f381a 100644 --- a/upcean/encode/plessey.py +++ b/upcean/encode/plessey.py @@ -131,21 +131,16 @@ def encode_plessey_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48 if(not re.findall("^([0-9]*[\\.]?[0-9])", str(resize)) or int(resize) < 1): resize = 1 if(pilsupport and imageoutlib == "pillow"): - pil_addon_fix = 0 - cairo_addon_fix = 0 + vertical_text_fix = 0 elif((cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")) or (svgwritesupport and cairosvgsupport and imageoutlib == "svgwrite") or (qahirahsupport and imageoutlib == "qahirah")): - pil_addon_fix = 0 - cairo_addon_fix = (9 * (int(resize) * barwidth[1])) + vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): - pil_addon_fix = 0 - cairo_addon_fix = (10 * (int(resize) * barwidth[1])) + vertical_text_fix = (10 * (int(resize) * barwidth[1])) elif(svgwritesupport and imageoutlib == "svgwrite"): - pil_addon_fix = 0 - cairo_addon_fix = (8 * (int(resize) * barwidth[1])) + vertical_text_fix = (8 * (int(resize) * barwidth[1])) else: - pil_addon_fix = 0 - cairo_addon_fix = 0 - cairo_addon_fix += (shiftxy[1] * (int(resize) * barwidth[1])) + vertical_text_fix = 0 + vertical_text_fix += (shiftxy[1] * (int(resize) * barwidth[1])) upc = upc.upper() upc_matches = list(upc) upc_size_add = ((len(upc_matches) * 16) + @@ -268,8 +263,8 @@ def encode_plessey_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48 if hidetext or (NumTxtZero == 0 and (hidesn is None or hidesn)) or (NumTxtZero == 11 and (hidecd is None or hidecd)): texthidden = True if(not texthidden): - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, upc_matches[NumTxtZero], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), upc_matches[NumTxtZero], barcolor[1], "ocrb", imageoutlib) upc_array['text']['location'].append(LineTxtStartNorm) upc_array['text']['text'].append(upc_matches[NumTxtZero]) upc_array['text']['type'].append("txt") diff --git a/upcean/encode/stf.py b/upcean/encode/stf.py index 4fa812e5..81c098c3 100644 --- a/upcean/encode/stf.py +++ b/upcean/encode/stf.py @@ -134,21 +134,16 @@ def encode_stf_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 54 if(not re.findall("^([0-9]*[\\.]?[0-9])", str(resize)) or int(resize) < 1): resize = 1 if(pilsupport and imageoutlib == "pillow"): - pil_addon_fix = 0 - cairo_addon_fix = 0 + vertical_text_fix = 0 elif((cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")) or (svgwritesupport and cairosvgsupport and imageoutlib == "svgwrite") or (qahirahsupport and imageoutlib == "qahirah")): - pil_addon_fix = 0 - cairo_addon_fix = (9 * (int(resize) * barwidth[1])) + vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): - pil_addon_fix = 0 - cairo_addon_fix = (10 * (int(resize) * barwidth[1])) + vertical_text_fix = (10 * (int(resize) * barwidth[1])) elif(svgwritesupport and imageoutlib == "svgwrite"): - pil_addon_fix = 0 - cairo_addon_fix = (8 * (int(resize) * barwidth[1])) + vertical_text_fix = (8 * (int(resize) * barwidth[1])) else: - pil_addon_fix = 0 - cairo_addon_fix = 0 - cairo_addon_fix += (shiftxy[1] * (int(resize) * barwidth[1])) + vertical_text_fix = 0 + vertical_text_fix += (shiftxy[1] * (int(resize) * barwidth[1])) upc_matches = list(upc) if(threewidebar): upc_size_add = (len(upc_matches) * 14) * barwidth[0] @@ -277,8 +272,8 @@ def encode_stf_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 54 if hidetext or (NumTxtZero == 0 and (hidesn is None or hidesn)) or (NumTxtZero == 11 and (hidecd is None or hidecd)): texthidden = True if(not texthidden): - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, upc_matches[NumTxtZero], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), upc_matches[NumTxtZero], barcolor[1], "ocrb", imageoutlib) upc_array['text']['location'].append(LineTxtStartNorm) upc_array['text']['text'].append(upc_matches[NumTxtZero]) upc_array['text']['type'].append("txt") diff --git a/upcean/encode/upca.py b/upcean/encode/upca.py index 7fe9b06a..0a7fd3fe 100644 --- a/upcean/encode/upca.py +++ b/upcean/encode/upca.py @@ -148,21 +148,16 @@ def encode_upca_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 5 if(not re.findall("^([0-9]*[\\.]?[0-9])", str(resize)) or int(resize) < 1): resize = 1 if(pilsupport and imageoutlib == "pillow"): - pil_addon_fix = 0 - cairo_addon_fix = 0 + vertical_text_fix = 0 elif((cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")) or (svgwritesupport and cairosvgsupport and imageoutlib == "svgwrite") or (qahirahsupport and imageoutlib == "qahirah")): - pil_addon_fix = 0 - cairo_addon_fix = (9 * (int(resize) * barwidth[1])) + vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): - pil_addon_fix = 0 - cairo_addon_fix = (10 * (int(resize) * barwidth[1])) + vertical_text_fix = (10 * (int(resize) * barwidth[1])) elif(svgwritesupport and imageoutlib == "svgwrite"): - pil_addon_fix = 0 - cairo_addon_fix = (8 * (int(resize) * barwidth[1])) + vertical_text_fix = (8 * (int(resize) * barwidth[1])) else: - pil_addon_fix = 0 - cairo_addon_fix = 0 - cairo_addon_fix += (shiftxy[1] * (int(resize) * barwidth[1])) + vertical_text_fix = 0 + vertical_text_fix += (shiftxy[1] * (int(resize) * barwidth[1])) upc_matches = re.findall("(\\d{1})(\\d{5})(\\d{5})(\\d{1})", upc) if(len(upc_matches) <= 0): return False @@ -365,8 +360,8 @@ def encode_upca_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 5 if hidetext or (NumTxtZero == 0 and (hidesn is None or hidesn)) or (NumTxtZero == 11 and (hidecd is None or hidecd)): texthidden = True if(not texthidden): - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, upc_print[NumTxtZero], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), upc_print[NumTxtZero], barcolor[1], "ocrb", imageoutlib) upc_array['text']['location'].append(LineTxtStartNorm) upc_array['text']['text'].append(upc_print[NumTxtZero]) if(NumTxtZero == 0): @@ -605,20 +600,16 @@ def encode_upcaean_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48 if(not re.findall("^([0-9]*[\\.]?[0-9])", str(resize)) or int(resize) < 1): resize = 1 if(pilsupport and imageoutlib == "pillow"): - pil_addon_fix = 0 - cairo_addon_fix = 0 + vertical_text_fix = 0 elif((cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")) or (svgwritesupport and cairosvgsupport and imageoutlib == "svgwrite") or (qahirahsupport and imageoutlib == "qahirah")): - pil_addon_fix = 0 - cairo_addon_fix = (9 * (int(resize) * barwidth[1])) + vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): - pil_addon_fix = 0 - cairo_addon_fix = (10 * (int(resize) * barwidth[1])) + vertical_text_fix = (10 * (int(resize) * barwidth[1])) elif(svgwritesupport and imageoutlib == "svgwrite"): - pil_addon_fix = 0 - cairo_addon_fix = (8 * (int(resize) * barwidth[1])) + vertical_text_fix = (8 * (int(resize) * barwidth[1])) else: - pil_addon_fix = 0 - cairo_addon_fix = 0 + vertical_text_fix = 0 + vertical_text_fix += (shiftxy[1] * (int(resize) * barwidth[1])) cairo_addon_fix += (shiftxy[1] * (int(resize) * barwidth[1])) upc_matches = re.findall("(\\d{1})(\\d{5})(\\d{5})(\\d{1})", upc) if(len(upc_matches) <= 0): @@ -811,8 +802,8 @@ def encode_upcaean_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48 if hidetext or (NumTxtZero == 0 and (hidesn is None or hidesn)) or (NumTxtZero == 13 and (hidecd is None or hidecd)): texthidden = True if(not texthidden): - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, upc_print[NumTxtZero], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), upc_print[NumTxtZero], barcolor[1], "ocrb", imageoutlib) upc_array['text']['location'].append(LineTxtStartNorm) upc_array['text']['text'].append(upc_print[NumTxtZero]) if(NumTxtZero == 0): diff --git a/upcean/encode/upcavar.py b/upcean/encode/upcavar.py index 0cec566a..1b8b8728 100644 --- a/upcean/encode/upcavar.py +++ b/upcean/encode/upcavar.py @@ -150,21 +150,16 @@ def encode_upcavar_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48 if(not re.findall("^([0-9]*[\\.]?[0-9])", str(resize)) or int(resize) < 1): resize = 1 if(pilsupport and imageoutlib == "pillow"): - pil_addon_fix = 0 - cairo_addon_fix = 0 + vertical_text_fix = 0 elif((cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")) or (svgwritesupport and cairosvgsupport and imageoutlib == "svgwrite") or (qahirahsupport and imageoutlib == "qahirah")): - pil_addon_fix = 0 - cairo_addon_fix = (9 * (int(resize) * barwidth[1])) + vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): - pil_addon_fix = 0 - cairo_addon_fix = (10 * (int(resize) * barwidth[1])) + vertical_text_fix = (10 * (int(resize) * barwidth[1])) elif(svgwritesupport and imageoutlib == "svgwrite"): - pil_addon_fix = 0 - cairo_addon_fix = (8 * (int(resize) * barwidth[1])) + vertical_text_fix = (8 * (int(resize) * barwidth[1])) else: - pil_addon_fix = 0 - cairo_addon_fix = 0 - cairo_addon_fix += (shiftxy[1] * (int(resize) * barwidth[1])) + vertical_text_fix = 0 + vertical_text_fix += (shiftxy[1] * (int(resize) * barwidth[1])) upchalflen = int((len(upc) - 2) / 2) upc_matches = re.findall("(\\d{1})(\\d{"+str(upchalflen)+"})(\\d{"+str(upchalflen)+"})(\\d{1})", upc) if(len(upc_matches) <= 0): @@ -372,8 +367,8 @@ def encode_upcavar_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48 if hidetext or (NumTxtZero == 0 and (hidesn is None or hidesn)) or (NumTxtZero == 11 and (hidecd is None or hidecd)): texthidden = True if(not texthidden): - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, upc_print[NumTxtZero], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), upc_print[NumTxtZero], barcolor[1], "ocrb", imageoutlib) upc_array['text']['location'].append(LineTxtStartNorm) upc_array['text']['text'].append(upc_print[NumTxtZero]) if(NumTxtZero == 0): @@ -614,21 +609,16 @@ def encode_upcaeanvar_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight= if(not re.findall("^([0-9]*[\\.]?[0-9])", str(resize)) or int(resize) < 1): resize = 1 if(pilsupport and imageoutlib == "pillow"): - pil_addon_fix = 0 - cairo_addon_fix = 0 + vertical_text_fix = 0 elif((cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")) or (svgwritesupport and cairosvgsupport and imageoutlib == "svgwrite") or (qahirahsupport and imageoutlib == "qahirah")): - pil_addon_fix = 0 - cairo_addon_fix = (9 * (int(resize) * barwidth[1])) + vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): - pil_addon_fix = 0 - cairo_addon_fix = (10 * (int(resize) * barwidth[1])) + vertical_text_fix = (10 * (int(resize) * barwidth[1])) elif(svgwritesupport and imageoutlib == "svgwrite"): - pil_addon_fix = 0 - cairo_addon_fix = (8 * (int(resize) * barwidth[1])) + vertical_text_fix = (8 * (int(resize) * barwidth[1])) else: - pil_addon_fix = 0 - cairo_addon_fix = 0 - cairo_addon_fix += (shiftxy[1] * (int(resize) * barwidth[1])) + vertical_text_fix = 0 + vertical_text_fix += (shiftxy[1] * (int(resize) * barwidth[1])) upchalflen = int((len(upc) - 2) / 2) upc_matches = re.findall("(\\d{1})(\\d{"+str(upchalflen)+"})(\\d{"+str(upchalflen)+"})(\\d{1})", upc) if(len(upc_matches) <= 0): @@ -825,8 +815,8 @@ def encode_upcaeanvar_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight= if hidetext or (NumTxtZero == 0 and (hidesn is None or hidesn)) or (NumTxtZero == len(upc_print)-1 and (hidecd is None or hidecd)): texthidden = True if(not texthidden): - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, upc_print[NumTxtZero], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), upc_print[NumTxtZero], barcolor[1], "ocrb", imageoutlib) upc_array['text']['location'].append(LineTxtStartNorm) upc_array['text']['text'].append(upc_print[NumTxtZero]) if(NumTxtZero == 0): diff --git a/upcean/encode/upce.py b/upcean/encode/upce.py index b7671324..d5474639 100644 --- a/upcean/encode/upce.py +++ b/upcean/encode/upce.py @@ -152,21 +152,16 @@ def encode_upce_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 5 if(not re.findall("^([0-9]*[\\.]?[0-9])", str(resize)) or int(resize) < 1): resize = 1 if(pilsupport and imageoutlib == "pillow"): - pil_addon_fix = 0 - cairo_addon_fix = 0 + vertical_text_fix = 0 elif((cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")) or (svgwritesupport and cairosvgsupport and imageoutlib == "svgwrite") or (qahirahsupport and imageoutlib == "qahirah")): - pil_addon_fix = 0 - cairo_addon_fix = (9 * (int(resize) * barwidth[1])) + vertical_text_fix = (9 * (int(resize) * barwidth[1])) elif((wandsupport and imageoutlib == "wand") or (magicksupport and imageoutlib == "magick") or (pgmagicksupport and imageoutlib == "pgmagick")): - pil_addon_fix = 0 - cairo_addon_fix = (10 * (int(resize) * barwidth[1])) + vertical_text_fix = (10 * (int(resize) * barwidth[1])) elif(svgwritesupport and imageoutlib == "svgwrite"): - pil_addon_fix = 0 - cairo_addon_fix = (8 * (int(resize) * barwidth[1])) + vertical_text_fix = (8 * (int(resize) * barwidth[1])) else: - pil_addon_fix = 0 - cairo_addon_fix = 0 - cairo_addon_fix += (shiftxy[1] * (int(resize) * barwidth[1])) + vertical_text_fix = 0 + vertical_text_fix += (shiftxy[1] * (int(resize) * barwidth[1])) if(not re.findall("^(0|1)", upc)): return False upc_matches = re.findall("(\\d{1})(\\d{6})(\\d{1})", upc) @@ -453,8 +448,8 @@ def encode_upce_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 5 if hidetext or (NumTxtZero == 0 and (hidesn is None or hidesn)) or (NumTxtZero == 7 and (hidecd is None or hidecd)): texthidden = True if(not texthidden): - drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], cairo_addon_fix + ( - barheight[0] * int(resize)) + pil_addon_fix, upc_print[NumTxtZero], barcolor[1], "ocrb", imageoutlib) + drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( + barheight[0] * int(resize)), upc_print[NumTxtZero], barcolor[1], "ocrb", imageoutlib) upc_array['text']['location'].append(LineTxtStartNorm) upc_array['text']['text'].append(upc_print[NumTxtZero]) if(NumTxtZero == 0):