Skip to content

Commit

Permalink
Small update
Browse files Browse the repository at this point in the history
  • Loading branch information
KazukiPrzyborowski committed Nov 19, 2024
1 parent b439698 commit de432fa
Show file tree
Hide file tree
Showing 29 changed files with 418 additions and 111 deletions.
2 changes: 2 additions & 0 deletions upcean/encode/barcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
wandsupport = upcean.support.check_for_wand()
magicksupport = upcean.support.check_for_magick()
pgmagicksupport = upcean.support.check_for_pgmagick()
cv2support = upcean.support.check_for_cv2()
skimagesupport = upcean.support.check_for_skimage()
defaultdraw = upcean.support.defaultdraw
import upcean.getprefix.getprefix

Expand Down
22 changes: 15 additions & 7 deletions upcean/encode/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
wandsupport = upcean.support.check_for_wand()
magicksupport = upcean.support.check_for_magick()
pgmagicksupport = upcean.support.check_for_pgmagick()
cv2support = upcean.support.check_for_cv2()
skimagesupport = upcean.support.check_for_skimage()
defaultdraw = upcean.support.defaultdraw
if(pilsupport or pillowsupport):
import upcean.predraw.prepil
Expand Down Expand Up @@ -109,7 +111,11 @@ def encode_binary_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48,
imageoutlib = "magick"
elif pgmagicksupport and isinstance(upc_img, pgmagick.Image):
imageoutlib = "pgmagick"
elif(imageoutlib != "pillow" and imageoutlib != "cairo" and imageoutlib != "qahirah" and imageoutlib != "cairosvg" and imageoutlib != "svgwrite" and imageoutlib != "wand" and imageoutlib != "magick" and imageoutlib != "pgmagick" and inimage != "none" and inimage is not None):
elif cv2support and upc_preimg=="cv2":
imageoutlib = "cv2"
elif skimagesupport and upc_preimg=="skimage":
imageoutlib = "skimage"
elif(imageoutlib != "pillow" and imageoutlib != "cairo" and imageoutlib != "qahirah" and imageoutlib != "cairosvg" and imageoutlib != "svgwrite" and imageoutlib != "wand" and imageoutlib != "magick" and imageoutlib != "pgmagick" and imageoutlib != "cv2" and imageoutlib != "skimage" and inimage != "none" and inimage is not None):
imageoutlib = None
elif(inimage == "none" or inimage is None):
imageoutlib = None
Expand Down Expand Up @@ -199,12 +205,12 @@ def draw_binary_barcode(upc, resize=1, barheight=(48, 54), barwidth=(1, 1), barc
imageoutlib = "svgwrite"
if(not pgmagicksupport and imageoutlib == "pgmagick"):
imageoutlib = "svgwrite"
if(imageoutlib != "pillow" and imageoutlib != "cairo" and imageoutlib != "qahirah" and imageoutlib != "cairosvg" and imageoutlib != "wand" and imageoutlib != "magick" and imageoutlib != "pgmagick" and imageoutlib != "svgwrite"):
if(not cv2support and imageoutlib == "cv2"):
imageoutlib = "svgwrite"
if(not pilsupport and not cairosupport):
if(not skimagesupport and imageoutlib == "skimage"):
imageoutlib = "svgwrite"
if(imageoutlib != "pillow" and imageoutlib != "cairo" and imageoutlib != "qahirah" and imageoutlib != "cairosvg" and imageoutlib != "wand" and imageoutlib != "magick" and imageoutlib != "pgmagick" and imageoutlib != "cv2" and imageoutlib != "skimage" and imageoutlib != "svgwrite"):
imageoutlib = "svgwrite"
if(not pilsupport and not cairosupport and not svgwritesupport):
return False
upc_size_add = len([item for sublist in upc['code'] for item in sublist]) * (barwidth[0] * int(resize))
upc_img, upc_preimg = upcean.predraw.new_image_surface(upc_size_add, (barheightadd + (upc['heightadd'] * barwidth[1])) * int(resize), barcolor[2], imageoutlib)
imgout = encode_binary_barcode([upc_img, upc_preimg], upc, resize, (0, 0), barheight, barwidth, barcolor, hideinfo)
Expand All @@ -227,9 +233,11 @@ def create_binary_barcode(upc, outfile="./binary.png", resize=1, barheight=(48,
imageoutlib = "svgwrite"
if(not pgmagicksupport and imageoutlib == "pgmagick"):
imageoutlib = "svgwrite"
if(imageoutlib != "pillow" and imageoutlib != "cairo" and imageoutlib != "qahirah" and imageoutlib != "cairosvg" and imageoutlib != "wand" and imageoutlib != "magick" and imageoutlib != "pgmagick" and imageoutlib != "svgwrite"):
if(not cv2support and imageoutlib == "cv2"):
imageoutlib = "svgwrite"
if(not skimagesupport and imageoutlib == "skimage"):
imageoutlib = "svgwrite"
if(not pilsupport and not cairosupport):
if(imageoutlib != "pillow" and imageoutlib != "cairo" and imageoutlib != "qahirah" and imageoutlib != "cairosvg" and imageoutlib != "wand" and imageoutlib != "magick" and imageoutlib != "pgmagick" and imageoutlib != "cv2" and imageoutlib != "skimage" and imageoutlib != "svgwrite"):
imageoutlib = "svgwrite"
if(outfile is None):
if(imageoutlib == "cairosvg"):
Expand Down
8 changes: 6 additions & 2 deletions upcean/encode/codabar.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
wandsupport = upcean.support.check_for_wand()
magicksupport = upcean.support.check_for_magick()
pgmagicksupport = upcean.support.check_for_pgmagick()
cv2support = upcean.support.check_for_cv2()
skimagesupport = upcean.support.check_for_skimage()
defaultdraw = upcean.support.defaultdraw
if(pilsupport or pillowsupport):
import upcean.predraw.prepil
Expand Down Expand Up @@ -347,9 +349,11 @@ def create_codabar_barcode(upc, outfile="./codabar.png", resize=1, barheight=(48
imageoutlib = "svgwrite"
if(not pgmagicksupport and imageoutlib == "pgmagick"):
imageoutlib = "svgwrite"
if(imageoutlib != "pillow" and imageoutlib != "cairo" and imageoutlib != "qahirah" and imageoutlib != "cairosvg" and imageoutlib != "wand" and imageoutlib != "magick" and imageoutlib != "pgmagick" and imageoutlib != "svgwrite"):
if(not cv2support and imageoutlib == "cv2"):
imageoutlib = "svgwrite"
if(not pilsupport and not cairosupport):
if(not skimagesupport and imageoutlib == "skimage"):
imageoutlib = "svgwrite"
if(imageoutlib != "pillow" and imageoutlib != "cairo" and imageoutlib != "qahirah" and imageoutlib != "cairosvg" and imageoutlib != "wand" and imageoutlib != "magick" and imageoutlib != "pgmagick" and imageoutlib != "cv2" and imageoutlib != "skimage" and imageoutlib != "svgwrite"):
imageoutlib = "svgwrite"
if(outfile is None):
if(imageoutlib == "cairosvg"):
Expand Down
14 changes: 11 additions & 3 deletions upcean/encode/code11.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
wandsupport = upcean.support.check_for_wand()
magicksupport = upcean.support.check_for_magick()
pgmagicksupport = upcean.support.check_for_pgmagick()
cv2support = upcean.support.check_for_cv2()
skimagesupport = upcean.support.check_for_skimage()
defaultdraw = upcean.support.defaultdraw
if(pilsupport or pillowsupport):
import upcean.predraw.prepil
Expand Down Expand Up @@ -119,7 +121,11 @@ def encode_code11_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48,
imageoutlib = "magick"
elif pgmagicksupport and isinstance(upc_img, pgmagick.Image):
imageoutlib = "pgmagick"
elif(imageoutlib != "pillow" and imageoutlib != "cairo" and imageoutlib != "qahirah" and imageoutlib != "cairosvg" and imageoutlib != "svgwrite" and imageoutlib != "wand" and imageoutlib != "magick" and imageoutlib != "pgmagick" and inimage != "none" and inimage is not None):
elif cv2support and upc_preimg=="cv2":
imageoutlib = "cv2"
elif skimagesupport and upc_preimg=="skimage":
imageoutlib = "skimage"
elif(imageoutlib != "pillow" and imageoutlib != "cairo" and imageoutlib != "qahirah" and imageoutlib != "cairosvg" and imageoutlib != "svgwrite" and imageoutlib != "wand" and imageoutlib != "magick" and imageoutlib != "pgmagick" and imageoutlib != "cv2" and imageoutlib != "skimage" and inimage != "none" and inimage is not None):
imageoutlib = None
elif(inimage == "none" or inimage is None):
imageoutlib = None
Expand Down Expand Up @@ -329,9 +335,11 @@ def create_code11_barcode(upc, outfile="./code11.png", resize=1, barheight=(48,
imageoutlib = "svgwrite"
if(not pgmagicksupport and imageoutlib == "pgmagick"):
imageoutlib = "svgwrite"
if(imageoutlib != "pillow" and imageoutlib != "cairo" and imageoutlib != "qahirah" and imageoutlib != "cairosvg" and imageoutlib != "wand" and imageoutlib != "magick" and imageoutlib != "pgmagick" and imageoutlib != "svgwrite"):
if(not cv2support and imageoutlib == "cv2"):
imageoutlib = "svgwrite"
if(not pilsupport and not cairosupport):
if(not skimagesupport and imageoutlib == "skimage"):
imageoutlib = "svgwrite"
if(imageoutlib != "pillow" and imageoutlib != "cairo" and imageoutlib != "qahirah" and imageoutlib != "cairosvg" and imageoutlib != "wand" and imageoutlib != "magick" and imageoutlib != "pgmagick" and imageoutlib != "cv2" and imageoutlib != "skimage" and imageoutlib != "svgwrite"):
imageoutlib = "svgwrite"
if(outfile is None):
if(imageoutlib == "cairosvg"):
Expand Down
26 changes: 20 additions & 6 deletions upcean/encode/code128.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
wandsupport = upcean.support.check_for_wand()
magicksupport = upcean.support.check_for_magick()
pgmagicksupport = upcean.support.check_for_pgmagick()
cv2support = upcean.support.check_for_cv2()
skimagesupport = upcean.support.check_for_skimage()
defaultdraw = upcean.support.defaultdraw
if(pilsupport or pillowsupport):
import upcean.predraw.prepil
Expand Down Expand Up @@ -114,7 +116,11 @@ def encode_code128_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48
imageoutlib = "magick"
elif pgmagicksupport and isinstance(upc_img, pgmagick.Image):
imageoutlib = "pgmagick"
elif(imageoutlib != "pillow" and imageoutlib != "cairo" and imageoutlib != "qahirah" and imageoutlib != "cairosvg" and imageoutlib != "svgwrite" and imageoutlib != "wand" and imageoutlib != "magick" and imageoutlib != "pgmagick" and inimage != "none" and inimage is not None):
elif cv2support and upc_preimg=="cv2":
imageoutlib = "cv2"
elif skimagesupport and upc_preimg=="skimage":
imageoutlib = "skimage"
elif(imageoutlib != "pillow" and imageoutlib != "cairo" and imageoutlib != "qahirah" and imageoutlib != "cairosvg" and imageoutlib != "svgwrite" and imageoutlib != "wand" and imageoutlib != "magick" and imageoutlib != "pgmagick" and imageoutlib != "cv2" and imageoutlib != "skimage" and inimage != "none" and inimage is not None):
imageoutlib = None
elif(inimage == "none" or inimage is None):
imageoutlib = None
Expand Down Expand Up @@ -666,9 +672,11 @@ def create_code128_barcode(upc, outfile="./code128.png", resize=1, barheight=(48
imageoutlib = "svgwrite"
if(not pgmagicksupport and imageoutlib == "pgmagick"):
imageoutlib = "svgwrite"
if(imageoutlib != "pillow" and imageoutlib != "cairo" and imageoutlib != "qahirah" and imageoutlib != "cairosvg" and imageoutlib != "wand" and imageoutlib != "magick" and imageoutlib != "pgmagick" and imageoutlib != "svgwrite"):
if(not cv2support and imageoutlib == "cv2"):
imageoutlib = "svgwrite"
if(not pilsupport and not cairosupport):
if(not skimagesupport and imageoutlib == "skimage"):
imageoutlib = "svgwrite"
if(imageoutlib != "pillow" and imageoutlib != "cairo" and imageoutlib != "qahirah" and imageoutlib != "cairosvg" and imageoutlib != "wand" and imageoutlib != "magick" and imageoutlib != "pgmagick" and imageoutlib != "cv2" and imageoutlib != "skimage" and imageoutlib != "svgwrite"):
imageoutlib = "svgwrite"
if(outfile is None):
if(imageoutlib == "cairosvg"):
Expand Down Expand Up @@ -752,7 +760,11 @@ def encode_code128old_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=
imageoutlib = "magick"
elif pgmagicksupport and isinstance(upc_img, pgmagick.Image):
imageoutlib = "pgmagick"
elif(imageoutlib != "pillow" and imageoutlib != "cairo" and imageoutlib != "qahirah" and imageoutlib != "cairosvg" and imageoutlib != "svgwrite" and imageoutlib != "wand" and imageoutlib != "magick" and imageoutlib != "pgmagick" and inimage != "none" and inimage is not None):
elif cv2support and upc_preimg=="cv2":
imageoutlib = "cv2"
elif skimagesupport and upc_preimg=="skimage":
imageoutlib = "skimage"
elif(imageoutlib != "pillow" and imageoutlib != "cairo" and imageoutlib != "qahirah" and imageoutlib != "cairosvg" and imageoutlib != "svgwrite" and imageoutlib != "wand" and imageoutlib != "magick" and imageoutlib != "pgmagick" and imageoutlib != "cv2" and imageoutlib != "skimage" and inimage != "none" and inimage is not None):
imageoutlib = None
elif(inimage == "none" or inimage is None):
imageoutlib = None
Expand Down Expand Up @@ -1220,9 +1232,11 @@ def create_code128old_barcode(upc, outfile="./code128.png", resize=1, barheight=
imageoutlib = "svgwrite"
if(not pgmagicksupport and imageoutlib == "pgmagick"):
imageoutlib = "svgwrite"
if(imageoutlib != "pillow" and imageoutlib != "cairo" and imageoutlib != "qahirah" and imageoutlib != "cairosvg" and imageoutlib != "wand" and imageoutlib != "magick" and imageoutlib != "pgmagick" and imageoutlib != "svgwrite"):
if(not cv2support and imageoutlib == "cv2"):
imageoutlib = "svgwrite"
if(not skimagesupport and imageoutlib == "skimage"):
imageoutlib = "svgwrite"
if(not pilsupport and not cairosupport):
if(imageoutlib != "pillow" and imageoutlib != "cairo" and imageoutlib != "qahirah" and imageoutlib != "cairosvg" and imageoutlib != "wand" and imageoutlib != "magick" and imageoutlib != "pgmagick" and imageoutlib != "cv2" and imageoutlib != "skimage" and imageoutlib != "svgwrite"):
imageoutlib = "svgwrite"
if(outfile is None):
if(imageoutlib == "cairosvg"):
Expand Down
14 changes: 11 additions & 3 deletions upcean/encode/code32.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
wandsupport = upcean.support.check_for_wand()
magicksupport = upcean.support.check_for_magick()
pgmagicksupport = upcean.support.check_for_pgmagick()
cv2support = upcean.support.check_for_cv2()
skimagesupport = upcean.support.check_for_skimage()
defaultdraw = upcean.support.defaultdraw
if(pilsupport or pillowsupport):
import upcean.predraw.prepil
Expand Down Expand Up @@ -116,7 +118,11 @@ def encode_code32_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48,
imageoutlib = "magick"
elif pgmagicksupport and isinstance(upc_img, pgmagick.Image):
imageoutlib = "pgmagick"
elif(imageoutlib != "pillow" and imageoutlib != "cairo" and imageoutlib != "qahirah" and imageoutlib != "cairosvg" and imageoutlib != "svgwrite" and imageoutlib != "wand" and imageoutlib != "magick" and imageoutlib != "pgmagick" and inimage != "none" and inimage is not None):
elif cv2support and upc_preimg=="cv2":
imageoutlib = "cv2"
elif skimagesupport and upc_preimg=="skimage":
imageoutlib = "skimage"
elif(imageoutlib != "pillow" and imageoutlib != "cairo" and imageoutlib != "qahirah" and imageoutlib != "cairosvg" and imageoutlib != "svgwrite" and imageoutlib != "wand" and imageoutlib != "magick" and imageoutlib != "pgmagick" and imageoutlib != "cv2" and imageoutlib != "skimage" and inimage != "none" and inimage is not None):
imageoutlib = None
elif(inimage == "none" or inimage is None):
imageoutlib = None
Expand Down Expand Up @@ -355,9 +361,11 @@ def create_code32_barcode(upc, outfile="./code32.png", resize=1, barheight=(48,
imageoutlib = "svgwrite"
if(not pgmagicksupport and imageoutlib == "pgmagick"):
imageoutlib = "svgwrite"
if(imageoutlib != "pillow" and imageoutlib != "cairo" and imageoutlib != "qahirah" and imageoutlib != "cairosvg" and imageoutlib != "wand" and imageoutlib != "magick" and imageoutlib != "pgmagick" and imageoutlib != "svgwrite"):
if(not cv2support and imageoutlib == "cv2"):
imageoutlib = "svgwrite"
if(not pilsupport and not cairosupport):
if(not skimagesupport and imageoutlib == "skimage"):
imageoutlib = "svgwrite"
if(imageoutlib != "pillow" and imageoutlib != "cairo" and imageoutlib != "qahirah" and imageoutlib != "cairosvg" and imageoutlib != "wand" and imageoutlib != "magick" and imageoutlib != "pgmagick" and imageoutlib != "cv2" and imageoutlib != "skimage" and imageoutlib != "svgwrite"):
imageoutlib = "svgwrite"
if(outfile is None):
if(imageoutlib == "cairosvg"):
Expand Down
Loading

0 comments on commit de432fa

Please sign in to comment.