To avoid compressing the image several times, you can simply compare the resized file size with the original.
- If the file size is noticeably larger, you have increased speed, so do not use it.
- If it is noticeably lower than compressed, use it.
In addition, when you recompress the file at the same speed, it only saves a small amount from the file size, if you use round numbers for your bids (60%, 70%, 80%, etc.), you can set the speed if the size file size is very similar to the original.
For example, a file compression of 1,844 KB
at:
- 90%
= 2,115 KB
. The size has increased, so I will not use it.
- 80%
= 1,843 KB
. This is almost identical to the original file size, so I can assume that the original has a speed of 80%
.
- 70%
= 1,567 KB
. It has shrunk, so I will use it.
Finally, if you are only interested in image compression speeds, you can use PHP to save the speed that you use in the file metadata.
source share