def image(self, img_source, high_density_vertical=True, high_density_horizontal=True, impl="<STR_LIT>",<EOL>fragment_height=<NUM_LIT>, center=False):
im = EscposImage(img_source)<EOL>try:<EOL><INDENT>max_width = int(self.profile.profile_data['<STR_LIT>']['<STR_LIT:width>']['<STR_LIT>'])<EOL>if im.width > max_width:<EOL><INDENT>raise ImageWidthError('<STR_LIT>'.format(im.width, max_width))<EOL><DEDENT>if center:<EOL><INDENT>im.center(max_width)<EOL><DEDENT><DEDENT>except KeyError:<EOL><INDENT>pass<EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT>if im.height > fragment_height:<EOL><INDENT>fragments = im.split(fragment_height)<EOL>for fragment in fragments:<EOL><INDENT>self.image(fragment,<EOL>high_density_vertical=high_density_vertical,<EOL>high_density_horizontal=high_density_horizontal,<EOL>impl=impl,<EOL>fragment_height=fragment_height)<EOL><DEDENT>return<EOL><DEDENT>if impl == "<STR_LIT>":<EOL><INDENT>density_byte = (<NUM_LIT:0> if high_density_horizontal else <NUM_LIT:1>) + (<NUM_LIT:0> if high_density_vertical else <NUM_LIT:2>)<EOL>header = GS + b"<STR_LIT>" + six.int2byte(density_byte) + self._int_low_high(im.width_bytes, <NUM_LIT:2>) +self._int_low_high(im.height, <NUM_LIT:2>)<EOL>self._raw(header + im.to_raster_format())<EOL><DEDENT>if impl == "<STR_LIT>":<EOL><INDENT>img_header = self._int_low_high(im.width, <NUM_LIT:2>) + self._int_low_high(im.height, <NUM_LIT:2>)<EOL>tone = b'<STR_LIT:0>'<EOL>colors = b'<STR_LIT:1>'<EOL>ym = six.int2byte(<NUM_LIT:1> if high_density_vertical else <NUM_LIT:2>)<EOL>xm = six.int2byte(<NUM_LIT:1> if high_density_horizontal else <NUM_LIT:2>)<EOL>header = tone + xm + ym + colors + img_header<EOL>raster_data = im.to_raster_format()<EOL>self._image_send_graphics_data(b'<STR_LIT:0>', b'<STR_LIT:p>', header + raster_data)<EOL>self._image_send_graphics_data(b'<STR_LIT:0>', b'<STR_LIT:2>', b'<STR_LIT>')<EOL><DEDENT>if impl == "<STR_LIT>":<EOL><INDENT>density_byte = (<NUM_LIT:1> if high_density_horizontal else <NUM_LIT:0>) + (<NUM_LIT:32> if high_density_vertical else <NUM_LIT:0>)<EOL>header = ESC + b"<STR_LIT:*>" + six.int2byte(density_byte) + self._int_low_high(im.width, <NUM_LIT:2>)<EOL>outp = [ESC + b"<STR_LIT:3>" + six.int2byte(<NUM_LIT:16>)]  <EOL>for blob in im.to_column_format(high_density_vertical):<EOL><INDENT>outp.append(header + blob + b"<STR_LIT:\n>")<EOL><DEDENT>outp.append(ESC + b"<STR_LIT:2>")  <EOL>self._raw(b'<STR_LIT>'.join(outp))<EOL><DEDENT>
Print an image

        You can select whether the printer should print in high density or not. The default value is high density.
        When printing in low density, the image will be stretched.

        Esc/Pos supplies several commands for printing. This function supports three of them. Please try to vary the
        implementations if you have any problems. For example the printer `IT80-002` will have trouble aligning
        images that are not printed in Column-mode.

        The available printing implementations are:

            * `bitImageRaster`: prints with the `GS v 0`-command
            * `graphics`: prints with the `GS ( L`-command
            * `bitImageColumn`: prints with the `ESC *`-command

        :param img_source: PIL image or filename to load: `jpg`, `gif`, `png` or `bmp`
        :param high_density_vertical: print in high density in vertical direction *default:* True
        :param high_density_horizontal: print in high density in horizontal direction *default:* True
        :param impl: choose image printing mode between `bitImageRaster`, `graphics` or `bitImageColumn`
        :param fragment_height: Images larger than this will be split into multiple fragments *default:* 960
        :param center: Center image horizontally *default:* False