-
Generated using Java native or using a third-party jar.
Problems that exist:
-
Native efficiency is slow, and the code coupling is too high, support format is few, other not much try
-
Use Thumbnailator.jar third party. Not high efficiency, compressed picture quality is too low. The support format is small, if the original image suffix is. jpg changed to. png, the operation cannot be supported. When a PNG picture is saved as transparent, the compressed image will appear with a serious color imbalance. Too high a coupling with the code
The above two and the code is too high coupling, so how to exist when the program, the image processing will become and weak.
2. Therefore I recommend using the following solution: Nginx to handle.
A. Using Nginx's own image generation strategy, only support JPEG, GIF, or PNG images (not supported in other formats such as BMP), return 415 On error, need to import Ngx_http_image_filter_module module
B.graphicsmagick+im4java+nginx+lua+nginx_lua module uses the advantages of graphicsmagick, processing pictures fast, high quality, dynamic and code decoupling, support more formats, more types of operation, basic no down machine, high scalability
Java Picture compression Policy description