code: def to_zpl_line(self, compression=3, **kwargs):
          
          if compression == 3:
              data = base64.b64encode(zlib.compress(self.data.bytes))
              data = ':Z64:%s:%s' % (data.decode('ascii'), self._calc_crc(data))
          elif compression == 1:
              data = base64.b64encode(self.data.bytes)
              data = ':B64:%s:%s' % (data.decode('ascii'), self._calc_crc(data))
          else:
              lines = []
              last_unique_line = None
  
              for line in self.data.hex_rows:
                  if line.endswith('00'):
                      line = line.rstrip('0')
                      if len(line) % 2:
                          line += '0'
                      line += ','
                  if line == last_unique_line:
                      line = ':'
                  else:
                      last_unique_line = line
                  lines.append(line)
  
              data = '\n'.join(lines)
              to_compress = set(RE_UNCOMPRESSED.findall(data))
              to_compress = sorted(to_compress, reverse=True)
              for uncompressed in to_compress:
                  uncompressed = uncompressed[0]
                  repeat = len(uncompressed)
                  compressed = ''
                  while repeat >= 400:
                      compressed += 'z'
                      repeat -= 400
                  if repeat >= 20:
                      value = repeat // 20
                      repeat -= value * 20
                      compressed += chr(value + 70).lower()
                  if repeat > 0:
                      compressed += chr(repeat + 70)
                  data = data.replace(uncompressed, compressed + uncompressed[0])
  
              data = data.replace('\n', '')
  
          zpl = '~DGR:%s.GRF,%s,%s,%s' % (
              self.filename,
              self.data.filesize,
              self.data.width // 8,
              data
          )
  
          return zpl
docs: Compression:
              3 = ZB64/Z64, base64 encoded DEFLATE compressed - best compression
              2 = ASCII hex encoded run length compressed - most compatible
              1 = B64, base64 encoded - pointless?