jpeg:extent=256KB 是这样实现的?
convert in.bmp jpeg:extent=256KB out.jpg
https://stackoverflow.com/questions/19626506/scale-image-according-a-maximum-file-size
其中有段代码:
maximum=101; for (minimum=2; minimum < maximum; ) { jpeg_image->quality=minimum+(maximum-minimum+1)/2; status=WriteJPEGImage(jpeg_info,jpeg_image); if (GetBlobSize(jpeg_image) <= extent) minimum=jpeg_image->quality+1; else maximum=jpeg_image->quality-1; } }
如果是这样实现的,感觉一点技术含量也有没了。