epeg is a super-fast library for resizing JPEGs. It offers an improvement of at least an order of magnitude over other known libraries like ImageMagick. Here are some numbers indicative of its speed:
$ time ./tclepeg test.jpeg test.jpg real 0m0.063s user 0m0.060s sys 0m0.000s $ time convert -resize 426x640 test.jpeg test.jpg real 0m1.158s user 0m1.048s sys 0m0.052s
In the above example the improvement is 18 fold. test.jpeg is a 2592x3888 image that is resized to a 426x640 one using the epeg library. Convert is ImageMagick's convert utility. It took epeg 63 msec to do the conversion against 1158 msec for ImageMagick. These timings include reading/writing to disk. tclepeg takes about 1 msec to do the conversion in memory, on the same system.
tclepeg brings epeg's functionality to TCL by means of a binary Linux library that can be loaded into a TCL program. A package for Linux and the 32bit i386 architecture is provided together with the source code at http://github.com/dzach/tclepeg
Usage (v0.4):
epeg ?options ...? jpegdata Options: -width image_width -height image_height -quality image_quality (1-100, default 50) -max max_dimension (default 64)
Usage example:
load ./tclepeg.so # read in a JPEG image set fd [open test.jpeg] fconfigure $fd -translation binary set img [read $fd] close $fd # write reduced image set fd [open out.jpeg w] fconfigure $fd -translation binary # let tclepeg do the work puts -nonewline $fd [epeg -width 320 -height 240 -quality 50 $img] close $fd
provided the tclepeg.so library is in the present working directory directory.
MHo: Does it compile on windows?
dzach: If the dependency on libjpeg could be satisfied in windows, I think it could compile, but I haven't tried that.