code: def test_jpg(setup_library, 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)
                  iio.imsave(fname, rim)
                  im = iio.imread(fname)
                  mul = 255 if isfloat else 1
                  assert_close(rim * mul, im, 1.1)  # lossy
  
      # No alpha in JPEG
      raises(Exception, iio.imsave, fname, im4)
  
      # Parameters
      iio.imsave(
          fnamebase + ".jpg",
          im3,
          progressive=True,
          optimize=True,
          baseline=True,
      )
  
      # Parameter fail
      raises(
          TypeError,
          iio.imread,
          fnamebase + ".jpg",
          notavalidkwarg=True,
          format="JPEG-FI",
      )
      raises(
          TypeError,
          iio.imsave,
          fnamebase + ".jpg",
          im,
          notavalidk=True,
          format="JPEG-FI",
      )
  
      # Compression
      iio.imsave(fnamebase + "1.jpg", im3, quality=10)
      iio.imsave(fnamebase + "2.jpg", im3, quality=90)
      s1 = os.stat(fnamebase + "1.jpg").st_size
      s2 = os.stat(fnamebase + "2.jpg").st_size
      assert s2 > s1
      raises(
          ValueError, iio.imsave, fnamebase + ".jpg", im, quality=120
      )
  
imports: import os
  import shutil
  import sys
  import platform
  import warnings
  import fsspec
  import imageio.plugins
  import imageio.v3
  import imageio.v2
  import numpy
  import pytest
  from imageio import core
  from imageio.core import IS_PYPY
  from pytest import raises
  from conftest import deprecated_test
label_desc: Use image node_id 12 for calling a global function with example usage: test_jpg(setup_library, tmp_path) without return types