I got some requests by e-mail about this small tool I wrote around epeg library.
So here is my package source (there is the source code inside). http://aorlinsk2.free.fr/openwrt/kamika … src.tar.gz
Just see that this binary is specific to my needs and then not very useful for the community in this form.
However the nicer algorithms I implemented for resizing are in the epeglite.c/.h files so you will take advantage of them if you just modify the main() of resizer.c to write your own resizer.
To see how I use this tool, here is my old PHP and new PHP code extracted from my self-written photo gallery:
function make_thumb($img, $out_file, $thumbsize)
{
exec("fastthumb ".$thumbsize." ".escapeshellarg($img)." ".escapeshellarg($out_file));
}
function make_thumb_old($img, $out_file, $thumbsize)
{
$img_in=ImageCreateFromJPEG($img);
$ix=imagesx($img_in);
$iy=imagesy($img_in);
//create output image
$img_out=ImageCreateTrueColor($thumbsize,$thumbsize);
//size of square of selection
$sqs=abs(min($ix,$iy));
//random choose x and y position of extracting square
srand((double)microtime()*1000000);
$px=rand(0,$ix-$sqs);
$py=rand(0,$iy-$sqs);
ImageCopyResampled($img_out,$img_in,0,0,$px,$py,$thumbsize,$thumbsize,$sqs,$sqs);
Imagejpeg($img_out,$out_file,90 /* jpeg quality */);
ImageDestroy($img_in);
ImageDestroy($img_out);
}
Anael