When I build hugepic.io one of the biggest challenges was to image resizing of enourmous images. Primarily JPEGs.
The way Hugepic works is that it chops up images into tiles, but before it can crop and chop of the tiles it needs to resize the image to a certain size. Say 1024x1024. Now this is really slow and it's so CPU intensive that if you try to parallelize it you end up causing so much "swappage" that the time it takes to resize to large images in parallel is more than it takes to do them one at a time.
The tool I found that was the best possible was ImageMagick's tool convert
.
Now there's a new tool that is much faster: vipsthumbnail
There are more comprehensive benchmarks abound the net, like this one for example, but here's a quick one to wet your appetite:
$ ls -lh 8/04/84c3e9.jpg -rw-r--r--@ 1 peterbe staff 253M Sep 16 12:00 8/04/84c3e9.jpg $ time convert 8/04/84c3e9.jpg -resize 200 /tmp/converted-200.jpg real 0m9.423s user 0m8.893s sys 0m0.521s $ time vipsthumbnail 8/04/84c3e9.jpg -s 200x200 -o /tmp/vips.jpg real 0m3.209s user 0m3.051s sys 0m0.138s
It supposedly has ports for Python but I'm quite happy to just a subprocess out to the command. You can install it on OSX with brew install vips
.
UPDATE
Boy! Do I wish I knew about vips dzsave when I built hugepic.io.
Comments