code: def test_cross_coding():
      """Encode using PIL and decode using opencv. Previously had an error with channel ordering. This test
      covers this issue for the future"""
      for size in [(300, 200), (300, 200, 3)]:
          dtype = np.uint8
          expected_image = np.random.randint(
              0, np.iinfo(dtype).max, size=size, dtype=np.uint8
          )
          codec = CompressedImageCodec("png")
          field = UnischemaField(
              name="field_image",
              numpy_dtype=dtype,
              shape=size,
              codec=codec,
              nullable=False,
          )
  
          encoded = Image.fromarray(expected_image)
          encoded_bytes = io.BytesIO()
          encoded.save(encoded_bytes, format="PNG")
  
          actual_image = codec.decode(field, encoded_bytes.getvalue())
          np.testing.assert_array_equal(expected_image, actual_image)
          assert expected_image.dtype == actual_image.dtype
  
file_path: petastorm/petastorm/tests/test_codec_compressed_image.py
imports: import io
  import numpy
  import pytest
  from PIL import Image
  from petastorm.codecs import CompressedImageCodec
  from petastorm.unischema import UnischemaField
label_desc: Use image node_id 6 for calling a global function with example usage: test_cross_coding() without return types