[ظƒظ„ط§ط³] image ظƒظ„ط§ط³ ط¨ط³ظٹط· ظ„ظ„طµظˆط±



بسم الله الرحمن الرحيم

ازيكم ؟؟
ليكم وحشة و الله

من زمان مش دخلت علي النت <- 4 ايام
المهم انا لسه مخلص كلاس الimage الكلاس ده جزء من Framework احتمال اطرحها مجانا هنا <- ده احتمال مش اكيد بس الاول اجهز الموقع الخاص بيها

الكلاس اهه يا ريت لو حد عنده اي اقتراحات يقولها


رمز PHP:
<code style="white-space:nowrap"> <code> <?php

/*
* @author: Ahmed H AboElnasser <[email protected]>
* @license MIT
* @since: Class available since EgySolutions Framework 0.1 Beta
* @link: http://www.egysolutions.net
* Requires: PHP 5.1.4+
* @package: EgySolutions Framework
* @category: core
* @subpackage image
*/
class image
{
private
$image = '';
private
$temp = '';

/**
* Constructor
*
* @return
*/
function __construct($sourceFile)
{
if(
is_file($sourceFile))
{
$this->image = ImageCreateFromJPEG($sourceFile);
}
else
{
$this->errorHandler();
}
return;
}

/**
* Resize an image
*
* @return
*/
function resize($width = 100, $height = 100, $aspectradio = true)
{
$o_wd = imagesx($this->image);
$o_ht = imagesy($this->image);
if(isset(
$aspectradio)&&$aspectradio)
{
$w = round($o_wd * $height / $o_ht);
$h = round($o_ht * $width / $o_wd);
if((
$height-$h)<($width-$w))
{
$width =& $w;
}
else
{
$height =& $h;
}
}
$this->temp = imageCreateTrueColor($width,$height);
imageCopyResampled($this->temp, $this->image,
0, 0, 0, 0, $width, $height, $o_wd, $o_ht);
$this->sync();
return;
}

/**
* Clean up - syncing
*
* @return
*/
function sync()



{
$this->image =& $this->temp;
unset(
$this->temp);
$this->temp = '';
return;
}

/**
* Show the image
*
* @return
*/
function show()
{
$this->_sendHeader();
ImageJPEG($this->image);
return;
}

/**
* Throw error
*
* @global $error
*/
function errorHandler()
{
global
$error;

$error->show('Image failure', 'The image you have requested cannot be shown', 1, 'index.php');
}

/**
* Store the image
*
* @return
*/
function store($file)
{
ImageJPEG($this->image,$file);
return;
}

/**
* Give a watermark upon the image
*/
function watermark($pngImage, $left = 0, $top = 0)
{
ImageAlphaBlending($this->image, true);
$layer = ImageCreateFromPNG($pngImage);
$logoW = ImageSX($layer);
$logoH = ImageSY($layer);
ImageCopy($this->image, $layer, $left, $top, 0, 0, $logoW, $logoH);
}

/**
* Parse header
*/
private function _sendHeader()
{
header('Content-Type: image/jpeg');
}
}
?>
</code> </code>










©المشاركات المنشورة تعبر عن وجهة نظر صاحبها فقط، ولا تُعبّر بأي شكل من الأشكال عن وجهة نظر إدارة المنتدى©