# Path: simple_zpl2/utils.py
# def convert_pil_image(image, width, height, compression_type='A'):
#     """
#     Converts PIL.Image to compression type
# 
#     :param image: PIL image
#     :param width: border to 99999
#     :param height: border to 99999
#     :param compression_type: * 'A' - ASCII hexadecimal
#                              * 'B' - binary
#                              * 'C' - compressed binary
#     """
#     if compression_type != 'A':
#         raise NotImplementedError('Compreesion Type {} not implemented'.format(compression_type))
#     image = image.resize((int(width), int(height)))
#     image = image.convert("RGBA")
#     alpha = image.getchannel("A")
# 
#     image_without_alpha = Image.new("RGBA", image.size, (255, 255, 255) + (255,))
#     image_without_alpha.paste(image, mask=alpha)
#     image_without_alpha = image_without_alpha.convert('L')
#     image_without_alpha = ImageOps.invert(image_without_alpha)
#     image_without_alpha = image_without_alpha.point(lambda x: 255 if x > 5 else 0, '1')
# 
#     return image_without_alpha


import binascii
import math
import requests
from functools import wraps
from simple_zpl2.utils import convert_pil_image
        Produce Circle on Label (^GC)

        :param diameter: 3 to 4095
        :param border: 1 to 4095
        :param color: * 'B' - black
                      * 'W' - white
        """
        self.zpl.append('^GC')
        self._add_int_value_in_range(diameter, 'diameter', 3, 4095, False, True)
        self._add_int_value_in_range(border, 'border', 1, 4095, True, True)
        self._add_line_color(color, True)
        self.zpl.append('^FS')

    @_newline_after
    def add_graphic_field(self, image, width, height=0, compression_type='A'):
        """
        Produce Graphic Field on Label (^GF)

        :param image: PIL image
        :param width: border to 99999
        :param height: border to 99999
        :param compression_type: * 'A' - ASCII hexadecimal
                                 * 'B' - binary
                                 * 'C' - compressed binary
        """
        if not height:
            height = int(float(image.size[1]) / image.size[0] * width)

        bytesperrow = math.ceil(width / 8.00)


# Path: simple_zpl2/utils.py
# def convert_pil_image(image, width, height, compression_type='A'):
#     """
#     Converts PIL.Image to compression type
# 
#     :param image: PIL image
#     :param width: border to 99999
#     :param height: border to 99999
#     :param compression_type: * 'A' - ASCII hexadecimal
#                              * 'B' - binary
#                              * 'C' - compressed binary
#     """
#     if compression_type != 'A':
#         raise NotImplementedError('Compreesion Type {} not implemented'.format(compression_type))
#     image = image.resize((int(width), int(height)))
#     image = image.convert("RGBA")
#     alpha = image.getchannel("A")
# 
#     image_without_alpha = Image.new("RGBA", image.size, (255, 255, 255) + (255,))
#     image_without_alpha.paste(image, mask=alpha)
#     image_without_alpha = image_without_alpha.convert('L')
#     image_without_alpha = ImageOps.invert(image_without_alpha)
#     image_without_alpha = image_without_alpha.point(lambda x: 255 if x > 5 else 0, '1')
# 
#     return image_without_alpha


# Path: simple_zpl2/zpl_document.py
import binascii
import math
import requests
from functools import wraps
from simple_zpl2.utils import convert_pil_image

        Produce Circle on Label (^GC)

        :param diameter: 3 to 4095
        :param border: 1 to 4095
        :param color: * 'B' - black
                      * 'W' - white
        """
        self.zpl.append('^GC')
        self._add_int_value_in_range(diameter, 'diameter', 3, 4095, False, True)
        self._add_int_value_in_range(border, 'border', 1, 4095, True, True)
        self._add_line_color(color, True)
        self.zpl.append('^FS')

    @_newline_after
    def add_graphic_field(self, image, width, height=0, compression_type='A'):
        """
        Produce Graphic Field on Label (^GF)

        :param image: PIL image
        :param width: border to 99999
        :param height: border to 99999
        :param compression_type: * 'A' - ASCII hexadecimal
                                 * 'B' - binary
                                 * 'C' - compressed binary
        """
        if not height:
            height = int(float(image.size[1]) / image.size[0] * width)

        bytesperrow = math.ceil(width / 8.00)


        image = convert_pil_image(image, width, height)