Skip to content

Fastest Method for Downscaling Large Image #136

@Ep0chalypse

Description

@Ep0chalypse

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.Susuki__JA-JP6548971154_UHD.jpg
[6694ms] for Images\20210929_OHR.TokyoSkyTree__JA-JP0701062199_UHD.jpg

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions