日曜日, 2月 15, 2009

PHP: Resizing image files

The way to resize image files in PHP is straight foward yet not as simple as it should be. Nevertheless, the PHP image library is equipped with image manipulation functions. Here is a function that does the job -- resizing factor should be edited to suit your needs.



function resizePhoto($fileName,$dest)
{
header('Content-type: image/jpeg');

list($width, $height) = getimagesize($fileName);
$ratio=((float)$height)/$width;
$newWidth=90;
$newHeight=(int)($newWidth*$ratio);

$thumb = imagecreatetruecolor($newWidth, $newHeight);
$source = imagecreatefromjpeg($fileName);

imagecopyresized($thumb, $source, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);

imagejpeg($thumb,$dest);
}

I2S プロトコル

I²S(Inter-IC Sound)は、マイコンやオーディオ機器間で音声データをやり取りするために設計された、シリアル通信プロトコルです。I²CやSPIと名前は似ていますが、I²Sは音声専用のプロトコルです。 I²Sは、以下の3つの主要な信号線を使って通信します。 BCLK (...