Example #1
1
 public function generate(array $array)
 {
     $frames = array();
     $frame_delay = array();
     foreach ($array['frames'] as $frame) {
         $image = $this->_createImage($frame['image']);
         if (array_key_exists('text', $frame)) {
             foreach ($frame['text'] as $text) {
                 // Set defaults
                 $defaults = array("angle" => $this->_defaultAngle, "fonts" => $this->_defaultFont, "fonts-color" => $this->_defaultFontColor, "fonts-size" => $this->_defaultFontSize, "y-position" => $this->_defaultYPosition, "x-position" => $this->_defaultXPosition, "text" => null, "letter-spacing" => 0);
                 // Overwrite all the defaults with the arguments
                 $args = array_merge($defaults, $text);
                 $fontColor = is_array($args['fonts-color']) ? $args['fonts-color'] : $this->_hex2rgb($args['fonts-color']);
                 $text_color = imagecolorallocate($image, $fontColor[0], $fontColor[1], $fontColor[2]);
                 $this->imagettftextSp($image, $args['fonts-size'], $args['angle'], $args['x-position'], $args['y-position'], $text_color, $args['fonts'], $args['text'], $args['letter-spacing']);
             }
         }
         $delay = array_key_exists('delay', $frame) ? $frame['delay'] : $this->_defaultDelay;
         ob_start();
         imagegif($image);
         $frames[] = ob_get_contents();
         $frame_delay[] = $delay;
         // Delay in the animation.
         ob_end_clean();
     }
     $repeat = array_key_exists('repeat', $array) ? $array['repeat'] : $this->_defaultRepeat;
     $gif = new GIFEncoder($frames, $frame_delay, $repeat, 2, 0, 0, 0, 0, 'bin');
     return $gif->GetAnimation();
 }
Example #2
0
 function GetImage()
 {
     eval(sprintf('$_SESSION["answer"] = (%d %s %d);', self::$num['rand1'], self::$math[self::$num['op']], self::$num['rand2']));
     if ($_SESSION['answer'] < 0) {
         self::AnimCaptcha(self::$gifs, self::$pause);
     }
     $gif = new GIFEncoder(self::$frames, self::$time, 0, 2, 0, 0, 0, "url");
     if (!headers_sent()) {
         header('Content-type:image/gif');
         echo $gif->GetAnimation();
     }
 }
Example #3
0
 function AnimatedOut()
 {
     for ($i = 0; $i < ANIM_FRAMES; $i++) {
         $image = imageCreateTrueColor(imageSX($this->image), imageSY($this->image));
         if (imageCopy($image, $this->image, 0, 0, 0, 0, imageSX($this->image), imageSY($this->image))) {
             Captcha::DoNoise($image, 200, 0);
             Ob_Start();
             imageGif($image);
             imageDestroy($image);
             $f_arr[] = Ob_Get_Contents();
             $d_arr[] = ANIM_DELAYS;
             Ob_End_Clean();
         }
     }
     $GIF = new GIFEncoder($f_arr, $d_arr, 0, 2, -1, -1, -1, 'C_MEMORY');
     return $GIF->GetAnimation();
 }
Example #4
0
 /**
  * Анимация
  */
 public function getAnimation()
 {
     if (isset($this->animation)) {
         return $this->animation;
     }
     check_condition($this->IMAGES, 'No images for gif');
     PsLibs::inst()->GifEncoder();
     $frames = array();
     $framed = array();
     foreach ($this->IMAGES as $path => $delay) {
         ob_start();
         SimpleImage::inst()->load($path)->output(IMAGETYPE_GIF)->close();
         $frames[] = ob_get_contents();
         $framed[] = $delay;
         // Delay in the animation.
         ob_end_clean();
     }
     // Generate the animated gif and output to screen.
     $gif = new GIFEncoder($frames, $framed, 0, 2, 0, 0, 0, 'bin');
     $this->animation = $gif->GetAnimation();
     return $this->animation;
 }
	function GIFAddFrames ( $i, $d ) {

		$Locals_str = 13 + 3 * ( 2 << ( ord ( $this->BUF [ $i ] { 10 } ) & 0x07 ) );

		$Locals_end = strlen ( $this->BUF [ $i ] ) - $Locals_str - 1;
		$Locals_tmp = substr ( $this->BUF [ $i ], $Locals_str, $Locals_end );

		$Global_len = 2 << ( ord ( $this->BUF [ 0  ] { 10 } ) & 0x07 );
		$Locals_len = 2 << ( ord ( $this->BUF [ $i ] { 10 } ) & 0x07 );

		$Global_rgb = substr ( $this->BUF [ 0  ], 13,
							3 * ( 2 << ( ord ( $this->BUF [ 0  ] { 10 } ) & 0x07 ) ) );
		$Locals_rgb = substr ( $this->BUF [ $i ], 13,
							3 * ( 2 << ( ord ( $this->BUF [ $i ] { 10 } ) & 0x07 ) ) );

		$Locals_ext = "!\xF9\x04" . chr ( ( $this->DIS << 2 ) + 0 ) .
						chr ( ( $d >> 0 ) & 0xFF ) . chr ( ( $d >> 8 ) & 0xFF ) . "\x0\x0";

		if ( $this->COL > -1 && ord ( $this->BUF [ $i ] { 10 } ) & 0x80 ) {
			for ( $j = 0; $j < ( 2 << ( ord ( $this->BUF [ $i ] { 10 } ) & 0x07 ) ); $j++ ) {
				if	(
						ord ( $Locals_rgb { 3 * $j + 0 } ) == ( ( $this->COL >> 16 ) & 0xFF ) &&
						ord ( $Locals_rgb { 3 * $j + 1 } ) == ( ( $this->COL >>  8 ) & 0xFF ) &&
						ord ( $Locals_rgb { 3 * $j + 2 } ) == ( ( $this->COL >>  0 ) & 0xFF )
					) {
					$Locals_ext = "!\xF9\x04" . chr ( ( $this->DIS << 2 ) + 1 ) .
									chr ( ( $d >> 0 ) & 0xFF ) . chr ( ( $d >> 8 ) & 0xFF ) . chr ( $j ) . "\x0";
					break;
				}
			}
		}
		switch ( $Locals_tmp { 0 } ) {
			case "!":
				$Locals_img = substr ( $Locals_tmp, 8, 10 );
				$Locals_tmp = substr ( $Locals_tmp, 18, strlen ( $Locals_tmp ) - 18 );
				break;
			case ",":
				$Locals_img = substr ( $Locals_tmp, 0, 10 );
				$Locals_tmp = substr ( $Locals_tmp, 10, strlen ( $Locals_tmp ) - 10 );
				break;
		}
		if ( ord ( $this->BUF [ $i ] { 10 } ) & 0x80 && $this->IMG > -1 ) {
			if ( $Global_len == $Locals_len ) {
				if ( GIFEncoder::GIFBlockCompare ( $Global_rgb, $Locals_rgb, $Global_len ) ) {
					$this->GIF .= ( $Locals_ext . $Locals_img . $Locals_tmp );
				}
				else {
					/*
					 *
					 * XY Padding...
					 *
					 */
					if ( $this->SIG == 1 ) {
						$Locals_img { 1 } = chr ( $this->OFS [ $i ] [ 0 ] & 0xFF );
						$Locals_img { 2 } = chr ( ( $$this->OFS [ $i ] [ 0 ] & 0xFF00 ) >> 8 );
						$Locals_img { 3 } = chr ( $this->OFS [ $i ] [ 1 ] & 0xFF );
						$Locals_img { 4 } = chr ( ( $this->OFS [ $i ] [ 1 ] & 0xFF00 ) >> 8 );
					}
					$byte  = ord ( $Locals_img { 9 } );
					$byte |= 0x80;
					$byte &= 0xF8;
					$byte |= ( ord ( $this->BUF [ 0 ] { 10 } ) & 0x07 );
					$Locals_img { 9 } = chr ( $byte );
					$this->GIF .= ( $Locals_ext . $Locals_img . $Locals_rgb . $Locals_tmp );
				}
			}
			else {
				/*
				 *
				 * XY Padding...
				 *
				 */
				if ( $this->SIG == 1 ) {
					$Locals_img { 1 } = chr ( $this->OFS [ $i ] [ 0 ] & 0xFF );
					$Locals_img { 2 } = chr ( ( $$this->OFS [ $i ] [ 0 ] & 0xFF00 ) >> 8 );
					$Locals_img { 3 } = chr ( $this->OFS [ $i ] [ 1 ] & 0xFF );
					$Locals_img { 4 } = chr ( ( $this->OFS [ $i ] [ 1 ] & 0xFF00 ) >> 8 );
				}
				$byte  = ord ( $Locals_img { 9 } );
				$byte |= 0x80;
				$byte &= 0xF8;
				$byte |= ( ord ( $this->BUF [ $i ] { 10 } ) & 0x07 );
				$Locals_img { 9 } = chr ( $byte );
				$this->GIF .= ( $Locals_ext . $Locals_img . $Locals_rgb . $Locals_tmp );
			}
		}
		else {
			$this->GIF .= ( $Locals_ext . $Locals_img . $Locals_tmp );
		}
		$this->IMG  = 1;
	}
Example #6
0
 public function water($source, $water, $alpha = 80, $position = "0")
 {
     //检查文件是否存在
     if (!file_exists($source) || !file_exists($water)) {
         return false;
     }
     //图片信息
     $sInfo = es_imagecls::getImageInfo($source);
     $wInfo = es_imagecls::getImageInfo($water);
     //如果图片小于水印图片,不生成图片
     if ($sInfo["0"] < $wInfo["0"] || $sInfo['1'] < $wInfo['1']) {
         return false;
     }
     if (is_animated_gif($source)) {
         require_once APP_ROOT_PATH . "system/utils/gif_encoder.php";
         require_once APP_ROOT_PATH . "system/utils/gif_reader.php";
         $gif = new GIFReader();
         $gif->load($source);
         foreach ($gif->IMGS['frames'] as $k => $img) {
             $im = imagecreatefromstring($gif->getgif($k));
             //为im加水印
             $sImage = $im;
             $wCreateFun = "imagecreatefrom" . $wInfo['type'];
             if (!function_exists($wCreateFun)) {
                 $wCreateFun = 'imagecreatefromjpeg';
             }
             $wImage = $wCreateFun($water);
             //设定图像的混色模式
             imagealphablending($wImage, true);
             switch (intval($position)) {
                 case 0:
                     break;
                     //左上
                 //左上
                 case 1:
                     $posY = 0;
                     $posX = 0;
                     //生成混合图像
                     imagecopymerge($sImage, $wImage, $posX, $posY, 0, 0, $wInfo[0], $wInfo[1], $alpha);
                     break;
                     //右上
                 //右上
                 case 2:
                     $posY = 0;
                     $posX = $sInfo[0] - $wInfo[0];
                     //生成混合图像
                     imagecopymerge($sImage, $wImage, $posX, $posY, 0, 0, $wInfo[0], $wInfo[1], $alpha);
                     break;
                     //左下
                 //左下
                 case 3:
                     $posY = $sInfo[1] - $wInfo[1];
                     $posX = 0;
                     //生成混合图像
                     imagecopymerge($sImage, $wImage, $posX, $posY, 0, 0, $wInfo[0], $wInfo[1], $alpha);
                     break;
                     //右下
                 //右下
                 case 4:
                     $posY = $sInfo[1] - $wInfo[1];
                     $posX = $sInfo[0] - $wInfo[0];
                     //生成混合图像
                     imagecopymerge($sImage, $wImage, $posX, $posY, 0, 0, $wInfo[0], $wInfo[1], $alpha);
                     break;
                     //居中
                 //居中
                 case 5:
                     $posY = $sInfo[1] / 2 - $wInfo[1] / 2;
                     $posX = $sInfo[0] / 2 - $wInfo[0] / 2;
                     //生成混合图像
                     imagecopymerge($sImage, $wImage, $posX, $posY, 0, 0, $wInfo[0], $wInfo[1], $alpha);
                     break;
             }
             //end im加水印
             ob_start();
             imagegif($sImage);
             $content = ob_get_contents();
             ob_end_clean();
             $frames[] = $content;
             $framed[] = $img['frameDelay'];
         }
         $gif_maker = new GIFEncoder($frames, $framed, 0, 2, 0, 0, 0, "bin");
         $image_rs = $gif_maker->GetAnimation();
         //如果没有给出保存文件名,默认为原图像名
         @unlink($source);
         //保存图像
         file_put_contents($source, $image_rs);
         return true;
     }
     //建立图像
     $sCreateFun = "imagecreatefrom" . $sInfo['type'];
     if (!function_exists($sCreateFun)) {
         $sCreateFun = 'imagecreatefromjpeg';
     }
     $sImage = $sCreateFun($source);
     $wCreateFun = "imagecreatefrom" . $wInfo['type'];
     if (!function_exists($wCreateFun)) {
         $wCreateFun = 'imagecreatefromjpeg';
     }
     $wImage = $wCreateFun($water);
     //设定图像的混色模式
     imagealphablending($wImage, true);
     switch (intval($position)) {
         case 0:
             break;
             //左上
         //左上
         case 1:
             $posY = 0;
             $posX = 0;
             //生成混合图像
             imagecopymerge($sImage, $wImage, $posX, $posY, 0, 0, $wInfo[0], $wInfo[1], $alpha);
             break;
             //右上
         //右上
         case 2:
             $posY = 0;
             $posX = $sInfo[0] - $wInfo[0];
             //生成混合图像
             imagecopymerge($sImage, $wImage, $posX, $posY, 0, 0, $wInfo[0], $wInfo[1], $alpha);
             break;
             //左下
         //左下
         case 3:
             $posY = $sInfo[1] - $wInfo[1];
             $posX = 0;
             //生成混合图像
             imagecopymerge($sImage, $wImage, $posX, $posY, 0, 0, $wInfo[0], $wInfo[1], $alpha);
             break;
             //右下
         //右下
         case 4:
             $posY = $sInfo[1] - $wInfo[1];
             $posX = $sInfo[0] - $wInfo[0];
             //生成混合图像
             imagecopymerge($sImage, $wImage, $posX, $posY, 0, 0, $wInfo[0], $wInfo[1], $alpha);
             break;
             //居中
         //居中
         case 5:
             $posY = $sInfo[1] / 2 - $wInfo[1] / 2;
             $posX = $sInfo[0] / 2 - $wInfo[0] / 2;
             //生成混合图像
             imagecopymerge($sImage, $wImage, $posX, $posY, 0, 0, $wInfo[0], $wInfo[1], $alpha);
             break;
     }
     //如果没有给出保存文件名,默认为原图像名
     @unlink($source);
     //保存图像
     imagejpeg($sImage, $source, 100);
     imagedestroy($sImage);
 }
Example #7
0
 			Showmsg('undefined_action');
 		}*/
 list($img_w, $img_h) = getimagesize($middleFile);
 $smallFile = PwUpload::savePath($db_ifftp, $filename, $smallDir);
 $s_ifthumb = 0;
 PwUpload::createFolder(dirname($smallFile));
 if ($ext == 'gif') {
     L::loadClass('gifdecoder', 'utility', false);
     L::loadClass('gif', 'utility', false);
     $gifDecoder = new GIFDecoder($data);
     $frames = $gifDecoder->GIFGetFrames();
     if (!empty($frames)) {
         foreach ($frames as $key => $value) {
             $frames[$key] = makeAvatarGifThumb($value, $img_w, $img_h, 48, 48);
         }
         $anime = new GIFEncoder($frames, $gifDecoder->GIFGetDelays(), $gifDecoder->GIFGetLoop(), $gifDecoder->GIFGetDisposal(), $gifDecoder->GIFGetTransparentR(), $gifDecoder->GIFGetTransparentG(), $gifDecoder->GIFGetTransparentB(), 'bin');
         $newGifData = $anime->getAnimation();
         PwUpload::createFolder(dirname($smallFile));
         pwCache::writeover($smallFile, $newGifData);
         $s_ifthumb = 1;
     }
 } elseif (MakeThumb($middleFile, $smallFile, 48, 48)) {
     $s_ifthumb = 1;
 }
 if ($db_ifftp) {
     //PwUpload::movetoftp($normalFile, $normalDir . "{$winduid}.$ext");
     PwUpload::movetoftp($middleFile, $middleDir . $filename);
     $s_ifthumb && PwUpload::movetoftp($smallFile, $smallDir . $filename);
 }
 pwFtpClose($GLOBALS['ftp']);
 $user_a = explode('|', $winddb['icon']);
Example #8
0
 function GIFAddFrames($i, $d, $GIF_dis)
 {
     $this->DIS = $GIF_dis > -1 ? $GIF_dis < 3 ? $GIF_dis : 3 : 2;
     $Locals_str = 13 + 3 * (2 << (ord($this->BUF[$i][10]) & 0x7));
     $Locals_end = strlen($this->BUF[$i]) - $Locals_str - 1;
     $Locals_tmp = substr($this->BUF[$i], $Locals_str, $Locals_end);
     $Global_len = 2 << (ord($this->BUF[0][10]) & 0x7);
     $Locals_len = 2 << (ord($this->BUF[$i][10]) & 0x7);
     $Global_rgb = substr($this->BUF[0], 13, 3 * (2 << (ord($this->BUF[0][10]) & 0x7)));
     $Locals_rgb = substr($this->BUF[$i], 13, 3 * (2 << (ord($this->BUF[$i][10]) & 0x7)));
     $Locals_ext = "!ù" . chr(($this->DIS << 2) + 0) . chr($d >> 0 & 0xff) . chr($d >> 8 & 0xff) . "";
     if ($this->COL > -1 && ord($this->BUF[$i][10]) & 0x80) {
         for ($j = 0; $j < 2 << (ord($this->BUF[$i][10]) & 0x7); $j++) {
             if (ord($Locals_rgb[3 * $j + 0]) == ($this->COL >> 16 & 0xff) && ord($Locals_rgb[3 * $j + 1]) == ($this->COL >> 8 & 0xff) && ord($Locals_rgb[3 * $j + 2]) == ($this->COL >> 0 & 0xff)) {
                 $Locals_ext = "!ù" . chr(($this->DIS << 2) + 1) . chr($d >> 0 & 0xff) . chr($d >> 8 & 0xff) . chr($j) . "";
                 break;
             }
         }
     }
     switch ($Locals_tmp[0]) {
         case "!":
             $Locals_img = substr($Locals_tmp, 8, 10);
             $Locals_tmp = substr($Locals_tmp, 18, strlen($Locals_tmp) - 18);
             break;
         case ",":
             $Locals_img = substr($Locals_tmp, 0, 10);
             $Locals_tmp = substr($Locals_tmp, 10, strlen($Locals_tmp) - 10);
             break;
     }
     if (ord($this->BUF[$i][10]) & 0x80 && $this->IMG > -1) {
         if ($Global_len == $Locals_len) {
             if (GIFEncoder::GIFBlockCompare($Global_rgb, $Locals_rgb, $Global_len)) {
                 $this->GIF .= $Locals_ext . $Locals_img . $Locals_tmp;
             } else {
                 //XY Padding...
                 if ($this->SIG == 1) {
                     $Locals_img[1] = chr($this->OFS[$i]["offset_left"] * $this->wr & 0xff);
                     $Locals_img[2] = chr(($this->OFS[$i]["offset_left"] * $this->wr & 0xff00) >> 8);
                     $Locals_img[3] = chr($this->OFS[$i]["offset_top"] * $this->hr & 0xff);
                     $Locals_img[4] = chr(($this->OFS[$i]["offset_top"] * $this->hr & 0xff00) >> 8);
                 }
                 $byte = ord($Locals_img[9]);
                 $byte |= 0x80;
                 $byte &= 0xf8;
                 $byte |= ord($this->BUF[0][10]) & 0x7;
                 $Locals_img[9] = chr($byte);
                 $this->GIF .= $Locals_ext . $Locals_img . $Locals_rgb . $Locals_tmp;
             }
         } else {
             //XY Padding...
             if ($this->SIG == 1) {
                 $Locals_img[1] = chr($this->OFS[$i]["offset_left"] * $this->wr & 0xff);
                 $Locals_img[2] = chr(($this->OFS[$i]["offset_left"] * $this->wr & 0xff00) >> 8);
                 $Locals_img[3] = chr($this->OFS[$i]["offset_top"] * $this->hr & 0xff);
                 $Locals_img[4] = chr(($this->OFS[$i]["offset_top"] * $this->hr & 0xff00) >> 8);
             }
             $byte = ord($Locals_img[9]);
             $byte |= 0x80;
             $byte &= 0xf8;
             $byte |= ord($this->BUF[$i][10]) & 0x7;
             $Locals_img[9] = chr($byte);
             $this->GIF .= $Locals_ext . $Locals_img . $Locals_rgb . $Locals_tmp;
         }
     } else {
         $this->GIF .= $Locals_ext . $Locals_img . $Locals_tmp;
     }
     $this->IMG = 1;
 }
Example #9
0
 function GetAnimation($params)
 {
     $GIF_src = $params["GIF_src"];
     $GIF_dly = $params["GIF_dly"];
     $GIF_lop = $params["GIF_lop"];
     $GIF_dis = $params["GIF_dis"];
     $GIF_red = $params["GIF_red"];
     $GIF_grn = $params["GIF_grn"];
     $GIF_blu = $params["GIF_blu"];
     $GIF_mod = $params["GIF_mod"];
     if (!is_array($GIF_src) && !is_array($GIF_dly)) {
         printf("%s: %s", $this->VER, $this->ERR['ERR00']);
         exit(0);
     }
     $this->LOP = $GIF_lop > -1 ? $GIF_lop : 0;
     $this->DIS = $GIF_dis > -1 ? $GIF_dis < 3 ? $GIF_dis : 3 : 2;
     $this->COL = $GIF_red > -1 && $GIF_grn > -1 && $GIF_blu > -1 ? $GIF_red | $GIF_grn << 8 | $GIF_blu << 16 : -1;
     for ($i = 0; $i < count($GIF_src); $i++) {
         if (strToLower($GIF_mod) == "url") {
             $this->BUF[] = fread(fopen($GIF_src[$i], "rb"), filesize($GIF_src[$i]));
         } else {
             if (strToLower($GIF_mod) == "bin") {
                 $this->BUF[] = $GIF_src[$i];
             } else {
                 printf("%s: %s ( %s )!", $this->VER, $this->ERR['ERR02'], $GIF_mod);
                 exit(0);
             }
         }
         if (substr($this->BUF[$i], 0, 6) != "GIF87a" && substr($this->BUF[$i], 0, 6) != "GIF89a") {
             printf("%s: %d %s", $this->VER, $i, $this->ERR['ERR01']);
             exit(0);
         }
         for ($j = 13 + 3 * (2 << (ord($this->BUF[$i][10]) & 0x7)), $k = TRUE; $k; $j++) {
             switch ($this->BUF[$i][$j]) {
                 case "!":
                     if (substr($this->BUF[$i], $j + 3, 8) == "NETSCAPE") {
                         printf("%s: %s ( %s source )!", $this->VER, $this->ERR['ERR03'], $i + 1);
                         exit(0);
                     }
                     break;
                 case ";":
                     $k = FALSE;
                     break;
             }
         }
     }
     GIFEncoder::GIFAddHeader();
     for ($i = 0; $i < count($this->BUF); $i++) {
         GIFEncoder::GIFAddFrames($i, $GIF_dly[$i]);
     }
     GIFEncoder::GIFAddFooter();
     return $this->GIF;
 }
Example #10
0
 public function generateGif()
 {
     include 'libs/GIFEncoder.class.php';
     $gif = new GIFEncoder($this->animation['frames'], $this->animation['frame_delays'], 0, 2, 0, 0, 0, 'bin');
     $animationName = uniqid('pixelCannon') . '.gif';
     $fp = fopen('_generated/animations/' . $animationName, 'w');
     fwrite($fp, $gif->GetAnimation());
     fclose($fp);
     return '_generated/animations/' . $animationName;
     echo '<img width="800" height="400" src="http://mm0030165.mediamonks.local/projects/yoda/_generated/animations/' . $animationName . '">';
     die;
 }
Example #11
0
 /**
  * 编码并保存当前GIF图片
  * @param  string $gifname 图片名称
  */
 public function save($gifname)
 {
     $gif = new GIFEncoder($this->frames, $this->delays, 0, 2, 0, 0, 0, 'bin');
     file_put_contents($gifname, $gif->GetAnimation());
 }
Example #12
0
 function updateIcon($uid)
 {
     global $atc_attachment_name, $db_ifftp;
     $uid = intval($uid);
     if ($uid < 1 || !S::isArray($_FILES)) {
         return $this->buildResponse(USER_INVALID_PARAMS);
     }
     ACloud_Sys_Core_Common::setGlobal('customized_current_uid', $uid);
     $user = $this->getCurrentUser();
     if (!$user->isLogin()) {
         return $this->buildResponse(USER_NOT_LOGIN);
     }
     $ext = strtolower(substr(strrchr($_FILES['icon']['name'], '.'), 1));
     L::loadClass('faceupload', 'upload', false);
     $face = new FaceUpload($user->uid);
     $icondb = PwUpload::upload($face);
     require_once R_P . 'require/showimg.php';
     $udir = str_pad(substr($user->uid, -2), 2, '0', STR_PAD_LEFT);
     if (!in_array(strtolower($ext), array('gif', 'jpg', 'jpeg', 'png', 'bmp'))) {
         return $this->buildResponse(USER_UPLOAD_CONTENT_ERROR);
     }
     $filename = "{$user->uid}.{$ext}";
     $sourceFilename = "{$user->uid}_tmp.{$ext}";
     $sourceDir = "upload/{$udir}/";
     $middleDir = "upload/middle/{$udir}/";
     $smallDir = "upload/small/{$udir}/";
     $img_w = $img_h = 0;
     $sourceFile = PwUpload::savePath($db_ifftp, $sourceFilename, $sourceDir);
     $middleFile = PwUpload::savePath($db_ifftp, $filename, $middleDir);
     PwUpload::createFolder(dirname($middleFile));
     PwUpload::movefile($sourceFile, $middleFile);
     require_once R_P . 'require/imgfunc.php';
     if (!($img_size = GetImgSize($middleFile))) {
         P_unlink($middleFile);
         return $this->buildResponse(USER_UPLOAD_CONTENT_ERROR);
     }
     list($img_w, $img_h) = getimagesize($middleFile);
     $smallFile = PwUpload::savePath($db_ifftp, $filename, $smallDir);
     $s_ifthumb = 0;
     PwUpload::createFolder(dirname($smallFile));
     if ($ext == 'gif') {
         L::loadClass('gifdecoder', 'utility', false);
         L::loadClass('gif', 'utility', false);
         $gifDecoder = new GIFDecoder($data);
         $frames = $gifDecoder->GIFGetFrames();
         if (!empty($frames)) {
             foreach ($frames as $key => $value) {
                 $frames[$key] = makeAvatarGifThumb($value, $img_w, $img_h, 48, 48);
             }
             $anime = new GIFEncoder($frames, $gifDecoder->GIFGetDelays(), $gifDecoder->GIFGetLoop(), $gifDecoder->GIFGetDisposal(), $gifDecoder->GIFGetTransparentR(), $gifDecoder->GIFGetTransparentG(), $gifDecoder->GIFGetTransparentB(), 'bin');
             $newGifData = $anime->getAnimation();
             PwUpload::createFolder(dirname($smallFile));
             writeover($smallFile, $newGifData);
             $s_ifthumb = 1;
         }
     } elseif (MakeThumb($middleFile, $smallFile, 48, 48)) {
         $s_ifthumb = 1;
     }
     if ($db_ifftp) {
         PwUpload::movetoftp($middleFile, $middleDir . $filename);
         $s_ifthumb && PwUpload::movetoftp($smallFile, $smallDir . $filename);
     }
     $user_a = explode('|', $user->icon);
     $user_a[2] = $img_w;
     $user_a[3] = $img_h;
     $usericon = setIcon("{$udir}/{$user->uid}.{$ext}", 3, $user_a);
     $userService = L::loadClass('UserService', 'user');
     /* @var $userService PW_UserService */
     $userService->update($user->uid, array('icon' => $usericon));
     list($iconurl) = showfacedesign($usericon, 1, 's');
     return $this->buildResponse(0, array('icon' => $iconurl));
 }
        ob_start();
        imagegif($image);
        global $frames, $framed;
        $frames[] = ob_get_contents();
        $framed[] = $_POST['speed'];
        ob_end_clean();
    }
    $cnt = count($_FILES);
    for ($key = 1; $key <= $cnt; $key++) {
        $tmp_name = $_FILES["images" . $key]["tmp_name"];
        $im = imagecreatefromstring(file_get_contents($tmp_name));
        $resized = imagecreatetruecolor($_POST['width'], $_POST['height']);
        imagecopyresized($resized, $im, 0, 0, 0, 0, $_POST['width'], $_POST['height'], imagesx($im), imagesy($im));
        frame($resized);
    }
    $gif = new GIFEncoder($frames, $framed, 0, 2, 0, 0, 0, 'bin');
    echo $gif->GetAnimation();
}
?>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name='robots' content='index,follow' />
	<title>Create GIF image using php</title>
	<script src="jquery-latest.js"></script>
	<script src="jquery.MultiFile.js"></script>
	<script src="jquery.placeholder.js"></script>
	<style>
	input{
	margin:10px;
	padding:10px;
 /**
  * Create an animated gif of the image rotating around Z axis
  * @author nchourrout
  * @version 0.1
  * @param time_div integer Duration in ms between two frames (default : 50ms)
  */
 public function createAnimatedGIF($time_div = 50)
 {
     $this->ext = "gif";
     for ($i = 1; $i < 6; $i++) {
         $angle = 0.1 + M_PI / 12 * $i;
         $this->rotate(0, 0, $angle);
         $this->save($i . ".gif");
         $frames[] = $this->output_directory . $i . ".gif";
         $time[] = $time_div;
     }
     $loops = 0;
     //infinite
     $gif = new GIFEncoder($frames, $time, $loops, 2, 0, 0, 0, "url");
     Header('Content-type:image/gif');
     echo $gif->GetAnimation();
     //Modifier cette ligne par quelquechose qui permette juste de stocker l'image dans un fichier
     for ($i = 1; $i < 6; $i++) {
         @unlink($this->output_directory . $i . ".gif");
     }
 }
Example #15
0
 /**
  * 输出图片.
  * 
  * @access public
  * @return boolean 成功返回 TRUE, 否则返回 FALSE.
  */
 public function output()
 {
     $gifEncoder = new GIFEncoder($this->_frames, $this->_delays, 0, 2, 0, 0, 0, 'bin');
     $mime = image_type_to_mime_type(IMAGETYPE_GIF);
     header('Content-type: ' . $mime);
     return imagegif($gifEncoder->GetAnimation());
 }
 function GenerateGIFImages()
 {
     // We want to put the binary GIF data into an array to be used later,
     //  so we use the output buffer.
     ob_start();
     imagegif($this->{$FirstBackgroundImage});
     $frames[] = ob_get_contents();
     $framed[] = 80;
     // Delay in the animation.
     ob_end_clean();
     ///////////////Generate GIF from the $image///////////////////////////////////////////////////////////////////
     // We want to put the binary GIF data into an array to be used later,
     //  so we use the output buffer.
     ob_start();
     $merged_image = "dps/{$this}->{$uid}.gif";
     imagegif($this->{$SecondBackgroundImage});
     $frames[] = ob_get_contents();
     $framed[] = 80;
     // Delay in the animation.
     ob_end_clean();
     ///////////Generate the animated gif and save//////////////////////////////////////////////////////////////
     $gif = new GIFEncoder($frames, $framed, 0, 2, 0, 0, 0, 'bin');
     $fp = fopen($merged_image, 'w');
     fwrite($fp, $gif->GetAnimation());
     fclose($fp);
 }
Example #17
0
 static function buildAnimateVerify($length = 4, $mode = 1, $width = 48, $height = 22, $verifyName = 'verify')
 {
     require 'String.class.php';
     $randval = String::rand_string($length, $mode);
     $_SESSION[$verifyName] = md5($randval);
     $width = $length * 10 + 10 > $width ? $length * 10 + 10 : $width;
     for ($num = 0; $num < 10; $num++) {
         ob_start();
         $im = @imagecreate($width, $height);
         $r = array(225, 255, 255, 223);
         $g = array(225, 236, 237, 255);
         $b = array(225, 236, 166, 125);
         $key = mt_rand(0, 3);
         $backColor = imagecolorallocate($im, $r[$key], $g[$key], $b[$key]);
         //背景色(随机)
         $borderColor = imagecolorallocate($im, 100, 100, 100);
         //边框色
         $pointColor = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
         //点颜色
         @imagefilledrectangle($im, 0, 0, $width - 1, $height - 1, $backColor);
         @imagerectangle($im, 0, 0, $width - 1, $height - 1, $borderColor);
         $stringColor = imagecolorallocate($im, mt_rand(0, 200), mt_rand(0, 120), mt_rand(0, 120));
         // 干扰
         for ($i = 0; $i < 10; $i++) {
             $fontcolor = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
             imagearc($im, mt_rand(-10, $width), mt_rand(-10, $height), mt_rand(30, 300), mt_rand(20, 200), 55, 44, $fontcolor);
         }
         for ($i = 0; $i < 25; $i++) {
             $fontcolor = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
             imagesetpixel($im, mt_rand(0, $width), mt_rand(0, $height), $pointColor);
         }
         for ($i = 0; $i < $length; $i++) {
             imagestring($im, 5, $i * 10 + 5, mt_rand(1, 8), $randval[$i], $stringColor);
         }
         imagegif($im);
         imagedestroy($im);
         $imagedata[] = ob_get_contents();
         ob_clean();
     }
     require 'GIFEncoder.class.php';
     $gif = new \GIFEncoder($imagedata);
     ob_clean();
     header('Content-type:image/gif');
     echo $gif->GetAnimation();
 }
 /**
  * This function IS NOT PROVIDED IN FFMPEG-PHP as it creates the gif as frames are added. to save memory in
  * php and practicality purposes this isn't really possible. It will overwrite any file.
  * @access public
  * @uses GifEncoder
  * 		- @link http://www.phpclasses.org/browse/package/3163.html
  * 		- @link http://phpclasses.gifs.hu/show.php?src=GIFEncoder.class.php
  * 		- @author László Zsidi
  * 		- @license Freeware.
  * @param string $tmp_directory The temp directory to work with. (remember the trailing slash)
  * @return boolean
  */
 public function saveNow($tmp_directory = '/tmp/')
 {
     if ($this->_saved === false) {
         $this->_saved = true;
         // 				check there are frames to make a gif
         if (!count($this->_frames)) {
             return false;
         }
         if (!class_exists('GIFEncoder')) {
             require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'gifencoder' . DIRECTORY_SEPARATOR . 'GIFEncoder.class.phpvideotoolkit.php';
         }
         // 				save all the images from the ffmpeg_frames
         $files = array();
         $delays = array();
         $delay = 1 / $this->_frame_rate * 100;
         foreach ($this->_frames as $key => $frame) {
             $file = $tmp_directory . 'f*g-' . uniqid(time() . '-') . '.gif';
             if (!imagegif($frame->toGDImage(), $file)) {
                 return false;
             }
             // 					add file to array so it out deletes on close
             array_push($this->_unlink_files, $file);
             array_push($files, $file);
             array_push($delays, $delay);
         }
         // 				convert the images
         $gif = new GIFEncoder($files, $delays, $this->_loop_count, 2, 0, 0, 0, 0, 'url');
         $gif_data = $gif->GetAnimation();
         if (!$gif_data) {
             return false;
         }
         // 				write the gif
         if (!($handle = fopen($this->_output_file_path, 'w'))) {
             return false;
         }
         if (fwrite($handle, $gif_data) === false) {
             return false;
         }
         fclose($handle);
         return true;
     }
     return false;
 }
Example #19
0
function getGifCode($paramArr)
{
    $options = array('width' => 80, 'height' => 20, 'numCnt' => 4, 'text' => 'ABCD');
    if (is_array($paramArr)) {
        $options = array_merge($options, $paramArr);
    }
    extract($options);
    $font = LJL_API_ROOT . '/Config/Fonts/Ga.ttf';
    //$len = strlen($phrase);
    //$font_size=18;
    $len = $numCnt;
    $font_size = $width / ($len + 1) - 5;
    $size = $width / $len;
    $box = imagettfbbox($size, 0, $font, $text);
    $textWidth = $box[2] - $box[0];
    $textHeight = $box[1] - $box[7];
    $x = ($width - $textWidth) / 2;
    $y = ($height - $textHeight) / 2 + $size;
    $str = '';
    for ($i = 0; $i < $len; $i++) {
        $str .= substr($text, $i, 1);
    }
    for ($num = 0; $num < 10; $num++) {
        ob_start();
        $image = imagecreatetruecolor($width, $height);
        //创建图片
        $bg_color = imagecolorallocate($image, 255, 255, 255);
        //设置背景颜色
        $border_color = imagecolorallocate($image, 100, 100, 100);
        //设置边框颜色
        $text_color = imagecolorallocate($image, 0, 0, 0);
        //设置验证码颜色
        imagefilledrectangle($image, 0, 0, $width - 1, $height - 1, $bg_color);
        //填充图片背景色
        imagerectangle($image, 0, 0, $width - 1, $height - 1, $border_color);
        //填充图片边框颜色
        for ($i = 0; $i < 5; $i++) {
            $line_color = imagecolorallocate($image, rand(0, 255), rand(0, 255), rand(0, 255));
            //干扰线颜色
            imageline($image, rand(0, $width), 0, $width, $height, $line_color);
            //画一条线段
        }
        // 设定文字颜色数组
        $colorList[] = ImageColorAllocate($image, 15, 73, 210);
        $colorList[] = ImageColorAllocate($image, 0, 64, 0);
        $colorList[] = ImageColorAllocate($image, 0, 0, 64);
        $colorList[] = ImageColorAllocate($image, 0, 128, 128);
        $colorList[] = ImageColorAllocate($image, 27, 52, 47);
        $colorList[] = ImageColorAllocate($image, 51, 0, 102);
        $colorList[] = ImageColorAllocate($image, 0, 0, 145);
        $colorList[] = ImageColorAllocate($image, 0, 0, 113);
        $colorList[] = ImageColorAllocate($image, 0, 51, 51);
        $colorList[] = ImageColorAllocate($image, 158, 180, 35);
        $colorList[] = ImageColorAllocate($image, 59, 59, 59);
        $colorList[] = ImageColorAllocate($image, 0, 0, 0);
        $colorList[] = ImageColorAllocate($image, 1, 128, 180);
        $colorList[] = ImageColorAllocate($image, 0, 153, 51);
        $colorList[] = ImageColorAllocate($image, 60, 131, 1);
        $colorList[] = ImageColorAllocate($image, 0, 0, 0);
        // 添加干扰线
        for ($i = 0; $i < 500; $i++) {
            $dot_color = imagecolorallocate($image, rand(0, 255), rand(0, 255), rand(0, 255));
            //干扰点颜色
            imagesetpixel($image, rand() % $width, rand() % $height, $dot_color);
            //画一个像素点
        }
        for ($k = 0; $k < 3; $k++) {
            $colorRandom = mt_rand(0, sizeof($colorList) - 1);
            // $todrawline = rand(0,1);
            $todrawline = 1;
            if ($todrawline) {
                imageline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $colorList[$colorRandom]);
            } else {
                $w = mt_rand(0, $width);
                $h = mt_rand(0, $width);
                $num1 = rand(90, 180);
                $num2 = rand(180, 270);
                imagearc($image, $width - floor($w / 2), floor($h / 2), $w, $h, $num1, $num2, $colorList[$colorRandom]);
            }
        }
        for ($i = 0; $i < $len; $i++) {
            // imagettftext($image, $font_size, rand(-3, 3), $font_size / 2 + ($font_size + 5) * $i, $height / 1.25 - rand(2, 3), $text_color, $font, $str[$i]); //用规定字体向图像写入文本
            imagettftext($image, $font_size, rand(-5, 5), $x + $font_size / 2 + ($font_size + 3) * $i, $y, $text_color, $font, $str[$i]);
            //用规定字体向图像写入文本
        }
        imagegif($image);
        imagedestroy($image);
        $imagedata[] = ob_get_contents();
        ob_clean();
    }
    require_once 'GIFEncoder.class.php';
    $gif = new GIFEncoder($imagedata);
    ob_clean();
    //防止出现'图像因其本身有错无法显示'的问题
    header('Content-type:image/gif');
    echo $gif->GetAnimation();
}
Example #20
0
// Generate GIF from the $image
// We want to put the binary GIF data into an array to be used later,
//  so we use the output buffer.
ob_start();
imagegif($FirstBackgroundImage);
$frames[] = ob_get_contents();
$framed[] = 80;
// Delay in the animation.
ob_end_clean();
// And again..
// Generate GIF from the $image
// We want to put the binary GIF data into an array to be used later,
//  so we use the output buffer.
ob_start();
$merged_image = "dps/{$uid}.gif";
imagegif($SecondBackgroundImage);
$frames[] = ob_get_contents();
$framed[] = 80;
// Delay in the animation.
ob_end_clean();
// Generate the animated gif and save.
$gif = new GIFEncoder($frames, $framed, 0, 2, 0, 0, 0, 'bin');
$fp = fopen($merged_image, 'w');
fwrite($fp, $gif->GetAnimation());
fclose($fp);
$insert = mysql_query("insert into friendzone (`uid`, `name`, `path`,`email`,`fromName`,`fromPath`) values('" . $uid . "','" . $name . "','" . $merged_image . "','" . $email . "','" . $userName . "','" . $userDp . "')");
if ($insert) {
    echo $name . "|" . $merged_image;
} else {
    echo "fail";
}
Example #21
0
 private function image_gif($savePath)
 {
     if ($this->ani_gif && is_array($this->ani_imageResized) && count($this->ani_imageResized) > 1) {
         $newa = array();
         foreach ($this->ani_imageResized as $i) {
             ob_start();
             imagegif($i);
             $gifdata = ob_get_clean();
             $newa[] = $gifdata;
         }
         if ($gifmerge = new GIFEncoder($newa, $this->ani_delays, 9999, $this->ani_disposal, $this->ani_transparent['r'], $this->ani_transparent['g'], $this->ani_transparent['b'], "bin")) {
             FWrite(FOpen($savePath, "wb"), $gifmerge->GetAnimation());
         } else {
             imagegif($this->ani_imageResized[0], $savePath);
         }
     } else {
         imagegif($this->imageResized, $savePath);
     }
 }
Example #22
0
 /**
  * 生成GIF动画格式验证码
  * @param string $cookiePre cookie前缀
  * @param int $num 验证码显示位数
  * @param int $cookieMinute cookie存活时间(单位:分)
  * @param int $h 验证高度
  * @param int $onlyDigit 是否只包含数字,否则将包含字母
  */
 public static function gifAuthcode($cookiePre = '', $num = 5, $cookieMinute = 3, $h = 20, $onlyDigit = false)
 {
     $params = self::getParams($cookiePre, $num, $cookieMinute, $h, $onlyDigit);
     $imagedata = array();
     // 生成一个32帧的GIF动画
     for ($i = 0; $i < 12; $i++) {
         ob_start();
         $image = imagecreate($params['width'], $params['height']);
         imagecolorallocate($image, 0, 0, 0);
         // 设定文字颜色数组
         $colorList[] = ImageColorAllocate($image, 15, 73, 210);
         $colorList[] = ImageColorAllocate($image, 0, 64, 0);
         $colorList[] = ImageColorAllocate($image, 0, 0, 64);
         $colorList[] = ImageColorAllocate($image, 0, 128, 128);
         $colorList[] = ImageColorAllocate($image, 27, 52, 47);
         $colorList[] = ImageColorAllocate($image, 51, 0, 102);
         $colorList[] = ImageColorAllocate($image, 0, 0, 145);
         $colorList[] = ImageColorAllocate($image, 0, 0, 113);
         $colorList[] = ImageColorAllocate($image, 0, 51, 51);
         $colorList[] = ImageColorAllocate($image, 158, 180, 35);
         $colorList[] = ImageColorAllocate($image, 59, 59, 59);
         $colorList[] = ImageColorAllocate($image, 0, 0, 0);
         $colorList[] = ImageColorAllocate($image, 1, 128, 180);
         $colorList[] = ImageColorAllocate($image, 0, 153, 51);
         $colorList[] = ImageColorAllocate($image, 60, 131, 1);
         $colorList[] = ImageColorAllocate($image, 0, 0, 0);
         $fontcolor = ImageColorAllocate($image, 0, 0, 0);
         $gray = ImageColorAllocate($image, 245, 245, 245);
         $color = imagecolorallocate($image, 255, 255, 255);
         $color2 = imagecolorallocate($image, 255, 0, 0);
         imagefill($image, 0, 0, $gray);
         $space = 12;
         // 字符间距
         if ($i > 0) {
             $len = strlen($params['string']);
             for ($k = 0; $k < $len; $k++) {
                 $colorRandom = mt_rand(0, sizeof($colorList) - 1);
                 $float_top = rand(0, 4);
                 $float_left = rand(0, 3);
                 imagestring($image, 5, $space * $k + $float_left, $float_top, $params['string'][$k], $colorList[$colorRandom]);
             }
         }
         for ($k = 0; $k < 20; $k++) {
             $colorRandom = mt_rand(0, sizeof($colorList) - 1);
             imagesetpixel($image, rand() % 70, rand() % 15, $colorList[$colorRandom]);
         }
         // 添加干扰线
         for ($k = 0; $k < 3; $k++) {
             $colorRandom = mt_rand(0, sizeof($colorList) - 1);
             // $todrawline = rand(0,1);
             $todrawline = 1;
             if ($todrawline) {
                 imageline($image, mt_rand(0, $params['width']), mt_rand(0, $params['height']), mt_rand(0, $params['width']), mt_rand(0, $params['height']), $colorList[$colorRandom]);
             } else {
                 $w = mt_rand(0, $params['width']);
                 $h = mt_rand(0, $params['width']);
                 imagearc($image, $params['width'] - floor($w / 2), floor($h / 2), $w, $h, rand(90, 180), rand(180, 270), $colorList[$colorRandom]);
             }
         }
         imagegif($image);
         imagedestroy($image);
         $imagedata[] = ob_get_contents();
         ob_clean();
         ++$i;
     }
     $gif = new GIFEncoder($imagedata, 5, 0, 2, 0, 0, 0, 'bin');
     Header('Content-type:image/gif');
     echo $gif->GetAnimation();
 }
Example #23
0
 function ckgif()
 {
     L::loadClass('gif', 'utility', false);
     $trueframe = mt_rand(1, 9);
     $im = $this->background();
     imagepng($im);
     imagedestroy($im);
     $bg = ob_get_contents();
     ob_clean();
     for ($i = 0; $i <= 9; $i++) {
         $im = imagecreatefromstring($bg);
         $this->disturbImg && $this->_disturbimg($im);
         $x[$i] = $y[$i] = 0;
         if ($i == $trueframe) {
             if ($this->codes) {
                 $this->fontRandomFamily ? $this->ttffont($im) : $this->imgfont($im);
             }
             $d[$i] = mt_rand(250, 400);
         } else {
             $this->_disturbcode($im);
             $d[$i] = mt_rand(5, 15);
         }
         imagegif($im);
         imagedestroy($im);
         $frame[$i] = ob_get_contents();
         ob_clean();
     }
     $anim = new GIFEncoder($frame, $d, 0, 0, 0, 0, 0, 'bin');
     header('Content-type: image/gif');
     echo $anim->getAnimation();
 }
Example #24
0
 /**
  * Resize the animated gif's by splitting it to frames, and resizing each frame.
  * @param $width
  * @param $height
  * @param $newfile
  * @return array
  */
 function _resizeAnimatedGif($width, $height, $newfile = NULL)
 {
     // jimport('joomla.filesystem.file');
     $libDir = JPATH_ROOT . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'mint' . DIRECTORY_SEPARATOR . 'image_processing';
     require_once $libDir . DIRECTORY_SEPARATOR . 'GIFDecoder.class.php';
     require_once $libDir . DIRECTORY_SEPARATOR . 'GIFEncoder.class.php';
     // Create gif decoder.
     // $gifDecoder = new GIFDecoder(JFile::read($this->imgFile));
     $gifDecoder = new GIFDecoder(file_get_contents($this->imgFile));
     // Write the frames to disk.
     $files = array();
     foreach ($gifDecoder->GIFGetFrames() as $k => $frame) {
         // store the current frame to disk.
         // $filename = JPath::clean($this->tempDir. DIRECTORY_SEPARATOR .uniqid('resize_', true));
         $img = imagecreatefromstring($frame);
         $newimg = @imagecreatetruecolor($width, $height);
         if ($this->transparentGif) {
             $colorcount = imagecolorstotal($img);
             if ($colorcount == 0) {
                 $colorcount = 256;
             }
             imagetruecolortopalette($newimg, true, $colorcount);
             imagepalettecopy($newimg, $img);
             $transparentcolor = imagecolortransparent($img);
             imagefill($newimg, 0, 0, $transparentcolor);
             imagecolortransparent($newimg, $transparentcolor);
         }
         @imagecopyresampled($newimg, $img, 0, 0, 0, 0, $width, $height, $this->imgWidth, $this->imgHeight);
         // take care about border :)
         if (is_resource($this->_border)) {
             @imagecopyresampled($newimg, $this->_border, 0, 0, 0, 0, $width, $height, imagesx($this->_border), imagesy($this->_border));
         }
         ob_start();
         imagegif($newimg);
         $files[] = ob_get_clean();
         // free some memory
         @imagedestroy($newimg);
         @imagedestroy($img);
         unset($frame);
         unset($gifDecoder->GIF_arrays[$k]);
     }
     // Create encoder
     $gifEncoder = new GIFEncoder($files, $gifDecoder->GIFGetDelays(), $gifDecoder->GIFGetLoop(), $gifDecoder->GIFGetDisposal(), $gifDecoder->GIFGetTransparentR(), $gifDecoder->GIFGetTransparentG(), $gifDecoder->GIFGetTransparentB(), 'bin');
     unset($gifDecoder);
     foreach ($files as $f) {
         @unlink($f);
     }
     if (!empty($newfile)) {
         //JFile::write($newfile, $gifEncoder->getAnimation());
         file_put_contents($newfile, $gifEncoder->getAnimation());
     } else {
         @header("Content-type: image/gif");
         echo $gifEncoder->getAnimation();
     }
 }
Example #25
0
 function ckgif()
 {
     require_once R_P . 'lib/gif.class.php';
     $trueframe = mt_rand(1, 9);
     $im = $this->background();
     imagepng($im);
     imagedestroy($im);
     $bg = ob_get_contents();
     ob_clean();
     for ($i = 0; $i <= 9; $i++) {
         $im = imagecreatefromstring($bg);
         $this->style & 32 && $this->disturbimg($im);
         $x[$i] = $y[$i] = 0;
         if ($i == $trueframe) {
             $this->style & 1 || $this->gdtype == 2 ? $this->ttffont($im) : $this->imgfont($im);
             $d[$i] = mt_rand(250, 400);
         } else {
             $this->disturbcode($im);
             $d[$i] = mt_rand(5, 15);
         }
         imagegif($im);
         imagedestroy($im);
         $frame[$i] = ob_get_contents();
         ob_clean();
     }
     $anim = new GIFEncoder($frame, $d, 0, 0, 0, 0, 0, 'bin');
     header('Content-type: image/gif');
     echo $anim->getAnimation();
 }
    /**
     * CONVERT VIDEOS TO FLV FORMAT
     * @param database A database connector object
     */
	function draw($path_base, $path_new, $filename_noext, $filename_ext, $thumb_position, $full_position = "0:00:00") {

		defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR);
		defined('CONVERTPATH') ? null : define('CONVERTPATH', dirname(__FILE__));
		$cmd_sinput = '';
		$cmd_soutput = '';
		$cmd_linput = '';
		$cmd_loutput = '';
		$cmd_dinput = '';
		$cmd_doutput = '';

		if(substr(PHP_OS, 0, 3) == "WIN") {

			defined('JPATH_SITE') ? null : define('JPATH_SITE', str_replace("\components\com_hwdvideoshare\converters", "", CONVERTPATH) );

		} else {

			defined('JPATH_SITE') ? null : define('JPATH_SITE', str_replace("/components/com_hwdvideoshare/converters", "", CONVERTPATH) );

		}

		// get joomla configuration
		include_once(JPATH_SITE.DS.'configuration.php');

		// get hwdVideoShare general settings
		include_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'config.hwdvideoshare.php');
		$c = hwd_vs_Config::get_instance();

		// get hwdVideoShare server settings
		include_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'serverconfig.hwdvideoshare.php');
		$s = hwd_vs_SConfig::get_instance();

		// shared library
		$sharedlib = null;
		if ($c->sharedlibrarypath !== "") {
			$sharedlib = "export LD_LIBRARY_PATH=$c->sharedlibrarypath;";
		}

		$path_sthumb = $path_base.DS.'thumbs'.DS.'temp_'.$filename_noext.'.jpg';
		$path_lthumb = $path_base.DS.'thumbs'.DS.'temp_l_'.$filename_noext.'.jpg';
		$path_dthumb = $path_base.DS.'thumbs'.DS.'temp_'.$filename_noext.'.gif';

		$path_sthumb_orig = $path_base.DS.'thumbs'.DS.$filename_noext.'.jpg';
		$path_lthumb_orig = $path_base.DS.'thumbs'.DS.'l_'.$filename_noext.'.jpg';
		$path_dthumb_orig = $path_base.DS.'thumbs'.DS.$filename_noext.'.gif';
		$path_seqthumb_orig = $path_base.DS.'thumbs'.DS.$filename_noext;

		$nthumbwidth = intval($c->con_thumb_n);
		$nwtype = gettype($nthumbwidth/2);
		if($nwtype !== "integer"){
			$nthumbwidth = intval($nthumbwidth+1);
		}
		$nthumbheight = intval($c->con_thumb_n*$c->tar_fb);
		$nhtype = gettype($nthumbheight/2);
		if($nhtype !== "integer"){
			$nthumbheight = intval($nthumbheight+1);
		}
		$lthumbwidth = intval($c->con_thumb_l);
		$lwtype = gettype($lthumbwidth/2);
		if($lwtype !== "integer"){
			$lthumbwidth = intval($lthumbwidth+1);
		}
		$lthumbheight = intval($c->con_thumb_l*$c->var_fb);
		$lttype = gettype($lthumbheight/2);
		if($lttype !== "integer"){
			$lthumbheight = intval($lthumbheight+1);
		}

		if(substr(PHP_OS, 0, 3) == "WIN") {

			$path_cmd_new      = '"'.$path_new.'"';
			$path_cmd_sthumb   = '"'.$path_sthumb.'"';
			$path_cmd_lthumb   = '"'.$path_lthumb.'"';
			$path_cmd_dthumb   = '"'.$path_dthumb.'"';
			$path_cmd_seqthumb = '"'.$path_seqthumb_orig.'"';

		} else {

			$path_cmd_new      = $path_new;
			$path_cmd_sthumb   = $path_sthumb;
			$path_cmd_lthumb   = $path_lthumb;
			$path_cmd_dthumb   = $path_dthumb;
			$path_cmd_seqthumb = $path_seqthumb_orig;

		}

		//Static
		clearstatcache();
		if ( @!file_exists($path_sthumb) || (@filesize($path_sthumb) == 0) ) {
			$cmd_sinput = "$s->ffmpegpath -y -i $path_cmd_new -ss $thumb_position -t 00:00:01 -s ".$nthumbwidth."x".$nthumbheight." -r 1 -f mjpeg $path_cmd_sthumb";
			@exec("$sharedlib $cmd_sinput 2>&1", $cmd_soutput);
		}
		clearstatcache();
		if ( @!file_exists($path_sthumb) || (@filesize($path_sthumb) == 0) ) {
			$cmd_sinput = "$s->ffmpegpath -y -i $path_cmd_new -ss $thumb_position -t 00:00:01 -s ".$nthumbwidth."x".$nthumbheight." -r 1 -f image2 $path_cmd_sthumb";
			@exec("$sharedlib $cmd_sinput 2>&1", $cmd_soutput);
		}
		clearstatcache();
		if ( !file_exists($path_sthumb) || (filesize($path_sthumb) == 0) ) {
			$cmd_sinput = "$s->ffmpegpath -ss $thumb_position -t 00:00:01 -i $path_cmd_new -an -r 1 -y -s ".$nthumbwidth."x".$nthumbheight." ".$path_cmd_sthumb."";
			@exec("$sharedlib $cmd_sinput 2>&1", $cmd_soutput);
		}
		clearstatcache();
		if ( !file_exists($path_sthumb) || (filesize($path_sthumb) == 0) ) {
			$thumb_position = "0:00:01";
			$cmd_sinput = "$s->ffmpegpath -y -i $path_cmd_new -ss $thumb_position -t 00:00:01 -s ".$nthumbwidth."x".$nthumbheight." -r 1 -f mjpeg $path_cmd_sthumb";
		    @exec("$sharedlib $cmd_sinput 2>&1", $cmd_soutput);
		}
		clearstatcache();
		if ( @!file_exists($path_sthumb) || (@filesize($path_sthumb) == 0) ) {
			$thumb_position = "0:00:01";
			$cmd_sinput = "$s->ffmpegpath -y -i $path_cmd_new -ss $thumb_position -t 00:00:01 -s ".$nthumbwidth."x".$nthumbheight." -r 1 -f image2 $path_cmd_sthumb";
			@exec("$sharedlib $cmd_sinput 2>&1", $cmd_soutput);
		}
		clearstatcache();
		if ( @!file_exists($path_sthumb) || (@filesize($path_sthumb) == 0) ) {
			$thumb_position = "0:00:01";
			$cmd_sinput = "$s->ffmpegpath -y -ss $thumb_position -t 00:00:01 -i $path_cmd_new -an -r 1 -y -s ".$nthumbwidth."x".$nthumbheight." ".$path_cmd_sthumb."";
			@exec("$sharedlib $cmd_sinput 2>&1", $cmd_soutput);
		}

		//Large
		clearstatcache();
		if ( @!file_exists($path_lthumb) || (@filesize($path_lthumb) == 0) ) {
			$cmd_linput = "$s->ffmpegpath -y -i $path_cmd_new -ss $thumb_position -t 00:00:01 -s ".$lthumbwidth."x".$lthumbheight." -r 1 -f mjpeg $path_cmd_lthumb";
			@exec("$sharedlib $cmd_linput 2>&1", $cmd_soutput);
		}
		clearstatcache();
		if ( @!file_exists($path_lthumb) || (@filesize($path_lthumb) == 0) ) {
			$cmd_linput = "$s->ffmpegpath -y -i $path_cmd_new -ss $thumb_position -t 00:00:01 -s ".$lthumbwidth."x".$lthumbheight." -r 1 -f image2 $path_cmd_lthumb";
			@exec("$sharedlib $cmd_linput 2>&1", $cmd_soutput);
		}
		clearstatcache();
		if ( !file_exists($path_lthumb) || (filesize($path_lthumb) == 0) ) {
			$cmd_linput = "$s->ffmpegpath -ss $thumb_position -t 00:00:01 -i $path_cmd_new -an -r 1 -y -s ".$lthumbwidth."x".$lthumbheight." ".$path_cmd_lthumb."";
			@exec("$sharedlib $cmd_linput 2>&1", $cmd_soutput);
		}
		clearstatcache();
		if ( !file_exists($path_lthumb) || (filesize($path_lthumb) == 0) ) {
			$thumb_position = "0:00:01";
			$cmd_linput = "$s->ffmpegpath -y -i $path_cmd_new -ss $thumb_position -t 00:00:01 -s ".$lthumbwidth."x".$lthumbheight." -r 1 -f mjpeg $path_cmd_lthumb";
		    @exec("$sharedlib $cmd_linput 2>&1", $cmd_soutput);
		}
		clearstatcache();
		if ( @!file_exists($path_lthumb) || (@filesize($path_lthumb) == 0) ) {
			$thumb_position = "0:00:01";
			$cmd_linput = "$s->ffmpegpath -y -i $path_cmd_new -ss $thumb_position -t 00:00:01 -s ".$lthumbwidth."x".$lthumbheight." -r 1 -f image2 $path_cmd_lthumb";
			@exec("$sharedlib $cmd_linput 2>&1", $cmd_soutput);
		}
		clearstatcache();
		if ( @!file_exists($path_lthumb) || (@filesize($path_lthumb) == 0) ) {
			$thumb_position = "0:00:01";
			$cmd_linput = "$s->ffmpegpath -y -ss $thumb_position -t 00:00:01 -i $path_cmd_new -an -r 1 -y -s ".$lthumbwidth."x".$lthumbheight." ".$path_cmd_lthumb."";
			@exec("$sharedlib $cmd_linput 2>&1", $cmd_soutput);
		}

		//Dynamic
		if ( @!file_exists($path_dthumb) || (@filesize($path_dthumb) == 0) )
		{
			if (function_exists('imagecreatefromjpeg'))
			{
				$cmd_dinput = "$s->ffmpegpath -i $path_cmd_new -an -r 0.2 -t 45 -y -s ".$nthumbwidth."x".$nthumbheight." ".$path_cmd_seqthumb."_%d.jpg";
				@exec("$sharedlib $cmd_dinput 2>&1", $cmd_doutput);

				include_once JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'GIFEncoder.class.php';

				$frames = null;
				$time = null;

				for($i=1;$i<9;$i++){

					if (file_exists($path_seqthumb_orig.'_'.$i.'.jpg')) {

						$imgname = $path_seqthumb_orig.'_'.$i.'.jpg';
						$im = @imagecreatefromjpeg($imgname); /* Attempt to open */
						imagegif($im, $path_seqthumb_orig.'_'.$i.'.gif');
						$frames[] = $path_seqthumb_orig.'_'.$i.'.gif';
						$time[] = 100;

					}

				}

				if (is_array($frames)) {

					$gif = new GIFEncoder    (
						$frames, // frames array
						$time, // elapsed time array
						0, // loops (0 = infinite)
						2, // disposal
						0, 0, 0, // rgb of transparency
						"url" // source type
					);

					$fh = fopen($path_dthumb, 'w') or die("can't open file");
					fwrite($fh, $gif->GetAnimation());
					fclose($fh);

					@imagedestroy($im);

				}

				for($i=1;$i<9;$i++){
					@unlink($path_seqthumb_orig.'_'.$i.'.gif');
					@unlink($path_seqthumb_orig.'_'.$i.'.jpg');
				}
			}
			else
			{
				$cmd_dinput = "Could not use image manupulation functions. Check the GD image library has been installed";
				$cmd_doutput = "";
			}
		}

		$result = array();
		$result[0] = 0;
		$result[1] = 0;
		$result[2] = $cmd_sinput;
		$result[3] = $cmd_soutput;
		$result[4] = $cmd_dinput;
		$result[5] = $cmd_doutput;
		$result[6] = 0;
		$result[7] = $cmd_linput;
		$result[8] = $cmd_loutput;

		if(file_exists($path_sthumb) && (filesize($path_sthumb) > 0)) {

			@unlink($path_sthumb_orig);
			if (!@rename($path_sthumb, $path_sthumb_orig)) {
				@copy($path_sthumb, $path_sthumb_orig);
			}

			if(file_exists($path_sthumb_orig) && (filesize($path_sthumb_orig) > 0)) {

				$result[0] = 1;
				@unlink($path_sthumb);

			}
		}
		if(file_exists($path_dthumb) && (filesize($path_dthumb) > 0)) {

			@unlink($path_dthumb_orig);
			if (!@rename($path_dthumb, $path_dthumb_orig)) {
				@copy($path_dthumb, $path_dthumb_orig);
			}

			if(file_exists($path_dthumb_orig) && (filesize($path_dthumb_orig) > 0)) {

				$result[1] = 1;
				@unlink($path_dthumb);

			}
		}
		if(file_exists($path_lthumb) && (filesize($path_lthumb) > 0)) {

			@unlink($path_lthumb_orig);
			if (!@rename($path_lthumb, $path_lthumb_orig)) {
				@copy($path_lthumb, $path_lthumb_orig);
			}

			if(file_exists($path_lthumb_orig) && (filesize($path_lthumb_orig) > 0)) {

				$result[6] = 1;
				@unlink($path_lthumb);

			}
		}

		$result = hwd_vs_GenerateThumbnail::generateOutput($result);
		return $result;

	}
Example #27
0
function get_spec_gif_anmation($url, $width, $height)
{
    require_once APP_ROOT_PATH . "system/utils/gif_encoder.php";
    require_once APP_ROOT_PATH . "system/utils/gif_reader.php";
    require_once APP_ROOT_PATH . "system/utils/es_imagecls.php";
    $gif = new GIFReader();
    $gif->load($url);
    $imagec = new es_imagecls();
    foreach ($gif->IMGS['frames'] as $k => $img) {
        $im = imagecreatefromstring($gif->getgif($k));
        $im = $imagec->make_thumb($im, $img['FrameWidth'], $img['FrameHeight'], "gif", $width, $height, $gen = 1);
        ob_start();
        imagegif($im);
        $content = ob_get_contents();
        ob_end_clean();
        $frames[] = $content;
        $framed[] = $img['frameDelay'];
    }
    $gif_maker = new GIFEncoder($frames, $framed, 0, 2, 0, 0, 0, "bin");
    return $gif_maker->GetAnimation();
}
Example #28
0
	int					'Transparent red, green, blue colors'
	int					'Source type'
);
*/
$gif = new GIFEncoder($frames_preview, $framed_preview, 0, 2, 255, 255, 255, "url");
fwrite(fopen($target3D_preview . '/axZmGifAnimation.gif', "wb"), $gif->GetAnimation());
// Remove preview gif files
if ($dh = opendir($target3D_preview)) {
    $framesArray = array();
    while (false !== ($dat = readdir($dh))) {
        if ($dat != "." && $dat != ".." && $dat != 'axZmGifAnimation.gif') {
            unlink($target3D_preview . '/' . $dat);
        }
    }
}
$gif = new GIFEncoder($frames_thumb, $framed_thumb, 0, 2, 0, 0, 0, "url");
fwrite(fopen($target3D_thumb . '/axZmGifAnimation.gif', "wb"), $gif->GetAnimation());
// Remove preview gif files
if ($dh = opendir($target3D_thumb)) {
    $framesArray = array();
    while (false !== ($dat = readdir($dh))) {
        if ($dat != "." && $dat != ".." && $dat != 'axZmGifAnimation.gif') {
            unlink($target3D_thumb . '/' . $dat);
        }
    }
}
$preview360imagePath = str_replace('//', '/', str_replace('\\', '/', dirname($_SERVER['PHP_SELF']) . '/' . $target3D_preview . '/axZmGifAnimation.gif'));
$thumb360imagePath = str_replace('//', '/', str_replace('\\', '/', dirname($_SERVER['PHP_SELF']) . '/' . $target3D_thumb . '/axZmGifAnimation.gif'));
echo '
jQuery.preview360imagePath = "' . $preview360imagePath . '"; 
jQuery("#thumb360spin").attr("src", "' . $thumb360imagePath . '"); 
Example #29
0
 private function GIFAddFrames($i, $d)
 {
     $Locals_str = 13 + 3 * (2 << (ord($this->BUF[$i][10]) & 0x7));
     $Locals_end = strlen($this->BUF[$i]) - $Locals_str - 1;
     $Locals_tmp = substr($this->BUF[$i], $Locals_str, $Locals_end);
     $Global_len = 2 << (ord($this->BUF[0][10]) & 0x7);
     $Locals_len = 2 << (ord($this->BUF[$i][10]) & 0x7);
     $Global_rgb = substr($this->BUF[0], 13, 3 * (2 << (ord($this->BUF[0][10]) & 0x7)));
     $Locals_rgb = substr($this->BUF[$i], 13, 3 * (2 << (ord($this->BUF[$i][10]) & 0x7)));
     $Locals_ext = "!�" . chr(($this->DIS << 2) + 0) . chr($d >> 0 & 0xff) . chr($d >> 8 & 0xff) . "";
     if ($this->COL > -1 && ord($this->BUF[$i][10]) & 0x80) {
         for ($j = 0; $j < 2 << (ord($this->BUF[$i][10]) & 0x7); $j++) {
             if (ord($Locals_rgb[3 * $j + 0]) == ($this->COL >> 16 & 0xff) && ord($Locals_rgb[3 * $j + 1]) == ($this->COL >> 8 & 0xff) && ord($Locals_rgb[3 * $j + 2]) == ($this->COL >> 0 & 0xff)) {
                 $Locals_ext = "!�" . chr(($this->DIS << 2) + 1) . chr($d >> 0 & 0xff) . chr($d >> 8 & 0xff) . chr($j) . "";
                 break;
             }
         }
     }
     switch ($Locals_tmp[0]) {
         case "!":
             $Locals_img = substr($Locals_tmp, 8, 10);
             $Locals_tmp = substr($Locals_tmp, 18, strlen($Locals_tmp) - 18);
             break;
         case ",":
             $Locals_img = substr($Locals_tmp, 0, 10);
             $Locals_tmp = substr($Locals_tmp, 10, strlen($Locals_tmp) - 10);
             break;
     }
     if (ord($this->BUF[$i][10]) & 0x80 && $this->IMG > -1) {
         if ($Global_len == $Locals_len) {
             if (GIFEncoder::GIFBlockCompare($Global_rgb, $Locals_rgb, $Global_len)) {
                 $this->GIF .= $Locals_ext . $Locals_img . $Locals_tmp;
             } else {
                 $byte = ord($Locals_img[9]);
                 $byte |= 0x80;
                 $byte &= 0xf8;
                 $byte |= ord($this->BUF[0][10]) & 0x7;
                 $Locals_img[9] = chr($byte);
                 $this->GIF .= $Locals_ext . $Locals_img . $Locals_rgb . $Locals_tmp;
             }
         } else {
             $byte = ord($Locals_img[9]);
             $byte |= 0x80;
             $byte &= 0xf8;
             $byte |= ord($this->BUF[$i][10]) & 0x7;
             $Locals_img[9] = chr($byte);
             $this->GIF .= $Locals_ext . $Locals_img . $Locals_rgb . $Locals_tmp;
         }
     } else {
         $this->GIF .= $Locals_ext . $Locals_img . $Locals_tmp;
     }
     $this->IMG = 1;
 }
Example #30
0
                $fill = imagecolorallocate($im, $fillArray[0], $fillArray[1], $fillArray[2]);
                imagettftext($im, $size / 1.3, 0, $x, $y, $fill, "FONT/times.ttf", $text);
                //$font = imageloadfont('./04b.gdf');
                //imagestring($im, $font, $x, $y, $text, $fill);
                break;
            case "path":
                $points = parse_path($shape["points"]);
                //echo count($points).";";
                $fillArray = sscanf($shape['fillColor'], '#%2x%2x%2x');
                $fill = imagecolorallocate($im, $fillArray[0], $fillArray[1], $fillArray[2]);
                imagefilledpolygon($im, $points, count($points) / 2, $fill);
                imagesetthickness($im, $shape["lineWidth"]);
                $strokeArray = sscanf($shape['lineColor'], '#%2x%2x%2x');
                $stroke = imagecolorallocate($im, $strokeArray[0], $strokeArray[1], $strokeArray[2]);
                imagepolygon($im, $points, count($points) / 2, $stroke);
                $points = array();
                break;
        }
    }
    ob_start();
    imagegif($im);
    imagedestroy($im);
    $data = ob_get_contents();
    ob_end_clean();
    array_push($gif_array, $data);
    array_push($framerate_array, 100 / $framerate);
    //echo "<img src='data:image/gif;base64,".base64_encode($data)."'><br><br>";
}
$gif = new GIFEncoder($gif_array, $framerate_array, 0, 2, 0, 0, 0, "bin");
$animation = $gif->GetAnimation();
echo base64_encode($animation);