static function transform_image($spath, $dpath, $data) { $datas = explode(':', $data); $srcWidth = $datas[0]; $srcHeight = $datas[1]; $srcX = $datas[2]; $srcY = $datas[3]; $dstWidth = $datas[4]; $dstHeight = $datas[5]; img::load($spath); $origWidth = img::getWidth(); $origHeight = img::getHeight(); $xRatio = $origWidth / $srcWidth; $yRatio = $origHeight / $srcHeight; $srcWidth = $dstWidth * $xRatio; $srcHeight = $dstHeight * $yRatio; $srcX = $srcX * $xRatio; $srcY = $srcY * $yRatio; img::transform($srcX, $srcY, $srcWidth, $srcHeight, $dstWidth, $dstHeight); img::save($dpath); img::unload(); }