code: def _pixel_data(image):
      
      # Test for PIL.Image and numpy.ndarray without requiring that cv2 or PIL
      # are installed.
      if 'PIL.' in str(type(image)):
          if 'L' != image.mode:
              image = image.convert('L')
          pixels = image.tobytes()
          width, height = image.size
      elif 'numpy.ndarray' in str(type(image)):
          if 3 == len(image.shape):
              # Take just the first channel
              image = image[:, :, 0]
          if 'uint8' != str(image.dtype):
              image = image.astype('uint8')
          try:
              pixels = image.tobytes()
          except AttributeError:
              # `numpy.ndarray.tobytes()` introduced in `numpy` 1.9.0 - use the
              # older `tostring` method.
              pixels = image.tostring()
          height, width = image.shape[:2]
      else:
          # image should be a tuple (pixels, width, height)
          pixels, width, height = image
  
          # Check dimensions
          if 0 != len(pixels) % (width * height):
              raise PyZbarError(
                  (
                      'Inconsistent dimensions: image data of {0} bytes is not '
                      'divisible by (width x height = {1})'
                  ).format(len(pixels), (width * height))
              )
  
      # Compute bits-per-pixel
      bpp = 8 * len(pixels) // (width * height)
      if 8 != bpp:
          raise PyZbarError(
              'Unsupported bits-per-pixel [{0}]. Only [8] is supported.'.format(
                  bpp
              )
          )
  
      return pixels, width, height
docs: Returns (pixels, width, height)
  
      Returns:
          :obj: `tuple` (pixels, width, height)