Simple Java image-scaling library implementing Chris Campbell's incremental scaling algorithm as well as Java2D's "best-practices" image-scaling techniques.
Hi, I'm using imgscalr to downscale large images(4k+) and on certain large images the scaling takes ~8+ seconds. I have tried using METHOD.SPEED but it only took off ~100-200ms. If I scale the image using ImageMagick it takes around 2-2.5 seconds. I know there will be differences in image manipulation software, but is there any way to achieve similar results using imgscalr?
ImageMagick:
time convert -resize 150x 20210927_OHR.Susuki__JA-JP6548971154_UHD.jpg -quality 10 susuki.jpg
real 0m1.649s
user 0m2.312s
sys 0m0.244s
fun generateThumbnailScalr(fullSizeImagePath: File) {
val startTime = System.currentTimeMillis()
val srcImage = ImageIO.read(fullSizeImagePath)
val scaledImage = Scalr.resize(srcImage, Scalr.Method.SPEED , 150)
val thumbFileExt = fullSizeImagePath.extension
val thumbImagePath = "Images/thumbs/scalr_${fullSizeImagePath.nameWithoutExtension}_thumb.$thumbFileExt"
val thumbFile = File(thumbImagePath)
ImageIO.write(scaledImage, "jpg", thumbFile)
println("[${System.currentTimeMillis() - startTime}ms] for $fullSizeImagePath")
}
Which outputs:
[8906ms] for Images\20210927_OHR.SusukiJA-JP6548971154_UHD.jpg
[6694ms] for Images\20210929_OHR.TokyoSkyTreeJA-JP0701062199_UHD.jpg
Hi, I'm using imgscalr to downscale large images(4k+) and on certain large images the scaling takes ~8+ seconds. I have tried using METHOD.SPEED but it only took off ~100-200ms. If I scale the image using ImageMagick it takes around 2-2.5 seconds. I know there will be differences in image manipulation software, but is there any way to achieve similar results using imgscalr?
ImageMagick: time convert -resize 150x 20210927_OHR.Susuki__JA-JP6548971154_UHD.jpg -quality 10 susuki.jpg real 0m1.649s user 0m2.312s sys 0m0.244s
I'm using OpenJDK 16.0.2 on windows 10 x64 with these two images: https://www.bing.com/th?id=OHR.Susuki__JA-JP6548971154_UHD.jpg https://www.bing.com/th?id=OHR.TokyoSkyTree__JA-JP0701062199_UHD.jpg
Here is the relevant code(in kotlin):
fun generateThumbnailScalr(fullSizeImagePath: File) { val startTime = System.currentTimeMillis() val srcImage = ImageIO.read(fullSizeImagePath) val scaledImage = Scalr.resize(srcImage, Scalr.Method.SPEED , 150) val thumbFileExt = fullSizeImagePath.extension val thumbImagePath = "Images/thumbs/scalr_${fullSizeImagePath.nameWithoutExtension}_thumb.$thumbFileExt" val thumbFile = File(thumbImagePath) ImageIO.write(scaledImage, "jpg", thumbFile) println("[${System.currentTimeMillis() - startTime}ms] for $fullSizeImagePath") }
Which outputs: [8906ms] for Images\20210927_OHR.SusukiJA-JP6548971154_UHD.jpg [6694ms] for Images\20210929_OHR.TokyoSkyTreeJA-JP0701062199_UHD.jpg