المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : [كلاس] image كلاس بسيط للصور



admin
11-01-2013, بتوقيت غرينيتش 10:02 AM
http://www.dzbatna.com/images/icons/iconrote.gif [ظƒظ„ط§ط³] image ظƒظ„ط§ط³ ط¨ط³ظٹط· ظ„ظ„طµظˆط± (http://www.dzbatna.com/t727620/)



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

ازيكم ؟؟
ليكم وحشة و اللهhttp://www.dzbatna.com/images/smilies/shiny01.gif

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

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


رمز PHP:

<code style="white-space:nowrap"> <code> <?php

/*
* @author: Ahmed H AboElnasser <[email protected] (http://www.cloudflare.com/email-protection)>
* @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>







ألعاب الأندرويد مجانا و حصريا (http://www.apotox.info/forum)




https://fbcdn-sphotos-d-a.akamaihd.net/hphotos-ak-ash4/482113_236967293114455_1193518507_n.png (http://www.dzbatna.com)
©المشاركات المنشورة تعبر عن وجهة نظر صاحبها فقط، ولا تُعبّر بأي شكل من الأشكال عن وجهة نظر إدارة المنتدى (http://www.dzbatna.com)©

استعمل مربع البحث في الاسفل لمزيد من المواضيع


سريع للبحث عن مواضيع في المنتدى