code: def test_jpg(tmp_path):
      fnamebase = str(tmp_path / "test")
  
      for isfloat in (False, True):
          for crop in (0, 1, 2):
              for colors in (0, 1, 3):
                  fname = fnamebase + "%i.%i.%i.jpg" % (
                      isfloat,
                      crop,
                      colors,
                  )
                  rim = get_ref_im(colors, crop, isfloat)
                  imageio.imsave(fname, rim, format="JPEG-PIL")
                  im = imageio.imread(fname, format="JPEG-PIL")
                  mul = 255 if isfloat else 1
                  assert_close(rim * mul, im, 1.1)  # lossy
  
      # No alpha in JPEG
      fname = fnamebase + ".jpg"
      with pytest.raises(Exception):
          imageio.imsave(fname, im4, format="JPEG-PIL")
  
      # Parameters
      imageio.imsave(
          fnamebase + ".jpg",
          im3,
          progressive=True,
          optimize=True,
          baseline=True,
          format="JPEG-PIL",
      )
  
      # Parameter fail - We let Pillow kwargs thorugh
      # pytest.raises(TypeError, imageio.imread, fnamebase + '.jpg', notavalidkwarg=1)
      # pytest.raises(TypeError, imageio.imsave, fnamebase + '.jpg', im, notavalidk=1)
  
      # Compression
      imageio.imsave(
          fnamebase + "1.jpg", im3, quality=10, format="JPEG-PIL"
      )
      imageio.imsave(
          fnamebase + "2.jpg", im3, quality=90, format="JPEG-PIL"
      )
      s1 = os.stat(fnamebase + "1.jpg").st_size
      s2 = os.stat(fnamebase + "2.jpg").st_size
      assert s2 > s1
      with pytest.raises(ValueError):
          imageio.imsave(
              fnamebase + ".jpg", im, quality=120, format="JPEG-PIL"
          )
  
imports: import os
  import sys
  import io
  from zipfile import ZipFile
  import numpy
  import pytest
  import imageio
  from imageio import core
  from conftest import deprecated_test
label_desc: Use image node_id 7 for calling a global function with example usage: test_jpg(tmp_path) without return types