Thursday, April 05
Why
Don't browsers do at least bilinear scaling these days? It can't be that CPU intensive.
Update: Turns out, it is pretty CPU intensive.
Resizing a 750x1200 image to 500x800 to suit my blog takes 2ms using nearest-neighbour scaling (which is what browsers use), 49ms using bilinear filtering, and 117ms using bicubic filtering.
The time is proportional to the number of pixels in the target image; starting with a 1500x2400 image took only 1 or 2% longer.
So not great for automated image sizing - not without a healthy cache, anyway - but pretty good for generating thumbnails on the fly. A 150x240 thumbnail takes 4.5ms to generate; at 200x320, about 8ms.
One thing I will likely use this for is avatars. I don't want to enforce a fixed size for avatars across mu.nu/mee.nu, because the idea has always been that it's your [blog|forum|wiki|whatever] and you control the way it looks. But having avatars of all different sizes looks like crap, and having a range of sizes (which is what I was considering) is fiddly.
But if I make it so that you upload one image at say 240x240, and that automatically gets resized according to the template tag, that could work well. Some timings on that: 50x50 0.3ms; 60x60 0.4ms; 75x75 0.7ms; 100x100 1.2ms. It takes a minimum of 3-5ms to serve a file in the first place, so that's not a huge imposition on the server.
[comment.avatar size=60] here we come!
Comments are disabled.
Post is locked.
Don't browsers do at least bilinear scaling these days? It can't be that CPU intensive.
Update: Turns out, it is pretty CPU intensive.
Resizing a 750x1200 image to 500x800 to suit my blog takes 2ms using nearest-neighbour scaling (which is what browsers use), 49ms using bilinear filtering, and 117ms using bicubic filtering.
The time is proportional to the number of pixels in the target image; starting with a 1500x2400 image took only 1 or 2% longer.
So not great for automated image sizing - not without a healthy cache, anyway - but pretty good for generating thumbnails on the fly. A 150x240 thumbnail takes 4.5ms to generate; at 200x320, about 8ms.
One thing I will likely use this for is avatars. I don't want to enforce a fixed size for avatars across mu.nu/mee.nu, because the idea has always been that it's your [blog|forum|wiki|whatever] and you control the way it looks. But having avatars of all different sizes looks like crap, and having a range of sizes (which is what I was considering) is fiddly.
But if I make it so that you upload one image at say 240x240, and that automatically gets resized according to the template tag, that could work well. Some timings on that: 50x50 0.3ms; 60x60 0.4ms; 75x75 0.7ms; 100x100 1.2ms. It takes a minimum of 3-5ms to serve a file in the first place, so that's not a huge imposition on the server.
[comment.avatar size=60] here we come!
Posted by: Pixy Misa at
08:03 PM
| Comments (4)
| Add Comment
| Trackbacks (Suck)
Post contains 240 words, total size 2 kb.
1
Um... because most scales are layered? And the gills get in the way.
Posted by: Wonderduck at Friday, April 06 2007 04:15 AM (svIB9)
2
Hi, the main page seems to have crashed? http://mee.nu/ - just comes up with an error.
Posted by: skeptica at Friday, April 06 2007 09:26 PM (z6gAP)
3
Eep! Fixed!
Posted by: Pixy Misa at Friday, April 06 2007 10:13 PM (PiXy!)
4
Two things to fix: First, the byte counter went bang when the byte count exceeded 231; second, the gigabyte counter was counting in hundreds of megabytes. I was wondering how we'd reached 20GB so fast...
Posted by: Pixy Misa at Friday, April 06 2007 10:19 PM (PiXy!)
47kb generated in CPU 0.0133, elapsed 0.1035 seconds.
56 queries taking 0.0944 seconds, 349 records returned.
Powered by Minx 1.1.6c-pink.
56 queries taking 0.0944 seconds, 349 records returned.
Powered by Minx 1.1.6c-pink.