Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
KazukiPrzyborowski authored Nov 17, 2024
1 parent 1caabe6 commit 8ab65a9
Show file tree
Hide file tree
Showing 19 changed files with 220 additions and 339 deletions.
21 changes: 8 additions & 13 deletions upcean/encode/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
21 changes: 8 additions & 13 deletions upcean/encode/codabar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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")
Expand Down
21 changes: 8 additions & 13 deletions upcean/encode/code11.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
58 changes: 24 additions & 34 deletions upcean/encode/code128.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -591,26 +586,26 @@ 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")
LineTxtStart += 11 * int(resize)
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])
upc_array['text']['type'].append("txt")
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])
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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])
Expand Down
21 changes: 8 additions & 13 deletions upcean/encode/code32.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) +
Expand Down Expand Up @@ -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")
Expand Down
Loading

0 comments on commit 8ab65a9

Please sign in to comment.