            if (val < smallestPixelValue) {
                  smallestPixelValue = val
                }
              }
            }
          }

          let src = jpegOutputData.getComponent(0).data
          let srcIdx = 0
          let dstIdx = 0
          let valRange = largestPixelValue - smallestPixelValue

          for (let y = 0; y < jpegOutputData.height; y++) {
            for (let x = 0; x < jpegOutputData.width; x++) {
              let val = src[srcIdx++]
              val = 255 * (val - s