Image Compression Tips

JPEG Quality Definition

JPEG images use a variable quality level to control the amount of compression. A low-quality image results in a smaller JPEG file; a high-quality image generates a relatively large file. The amount of JPEG compression is typically measured as a percentage of the quality level. An image at 100% quality has (almost) no loss, and 1% quality is a very low-quality image. In general, quality levels of 90% or higher are considered "high quality", 80%-90% is "medium quality", and 70%-80% is low quality. Anything below 70% is typically a very low-quality image.
The second and the third image, those show there are pixelated characteristic on low image quality
Low JPEG quality can affect the liveness check performance and the face match performance. To ensure you can get better quality please resize the image based on the resolution without extreme degrading the JPEG quality, the quality suggestion is 80% or above.
JPEG Quality
Image Example
High (Above 90%)
Medium (80%-90%)
Low (70%-80%)
Very Low ( Below 70%)

Best Practice How to Resize or Compress The Image

  1. 1.
    Ensure the image quality is on the medium level between 80% - 90% (Medium JPEG Quality).
  2. 2.
    Use the resolution-ratio-based to resize the image. If the image size is bigger than the requirement, you can adjust the image resolution to be smaller until the image size is below 800 KB. The suggested minimum file size is 100 KB.
  3. 3.
    In our experiment on image height dimension 600 px which the image quality 80% it will give us the file size of 100 KB or above so that it still fulfills our minimum image size requirement.
  4. 4.
    Avoid using the nearest-neighbor interpolation algorithm when scaling images.
  5. 5.
    On iOS, you can use the function jpegData(compressionQuality:) on UIImage library for compressing the JPEG image based on quality range. Please avoid "nearest" for minificationFilter and magnificationFilter setting.
  6. 6.
    On Android, you can use Bitmap.CompressFormat method. Please set filter="true" when using createBitmap() or createScaledBitmap().