function MyImageBlur($im, $pct) { // w00t. my very own blur function // in GD2, there's a gaussian blur function. smarmy bastards. ;-) $width = imagesx($im); $height = imagesy($im); $temp_im = ImageCreate($width, $height); $bg = ImageColorAllocate($temp_im, 255, 255, 255); // preserves transparency if in orig image ImageColorTransparent($temp_im, $bg); // fill bg ImageFill($temp_im, 0, 0, $bg); $distance = 1; // emboss: ImageCopyMerge($temp_im, $im, 0, 0, $distance, $distance, $width, $height, $pct); ImageCopyMerge($im, $temp_im, -$distance, -$distance, 0, 0, $width, $height, $pct); ImageFill($temp_im, 0, 0, $bg); ImageCopyMerge($temp_im, $im, 0, $distance, $distance, 0, $width, $height, $pct); ImageCopyMerge($im, $temp_im, $distance, 0, 0, $distance, $width, $height, $pct); // blur: ImageCopyMerge($temp_im, $im, 0, $distance, 0, 0, $width, $height, $pct); ImageCopyMerge($im, $temp_im, $distance, 0, 0, 0, $width, $height, $pct); ImageCopyMerge($temp_im, $im, 0, 0, 0, $distance, $width, $height, $pct); ImageCopyMerge($im, $temp_im, 0, 0, $distance, 0, $width, $height, $pct); // remove temp image ImageDestroy($temp_im); return $im; }
function capcha($salt) { srand(time()); $md5_hash = md5(rand(0, 9999)); $security_code = substr($md5_hash, 25, 5); $enc = md5($security_code . $salt); $_SESSION['count'] = $enc; $secure = $_SESSION['count']; // echo "--------------------------$secure<br>"; $width = 50; $height = 24; $image = ImageCreate($width, $height); $white = ImageColorAllocate($image, 255, 255, 255); $black = ImageColorAllocate($image, 0, 100, 0); $grey = ImageColorAllocate($image, 204, 204, 204); ImageFill($image, 0, 0, $white); //Add randomly generated string in white to the image ImageString($image, 10, 4, 4, $security_code, $black); // ImageRectangle($image,0,16,$width-1,$height-1,$grey); imageline($image, 0, $height / 2, $width, $height / 2, $grey); imageline($image, $width / 2, 0, $width / 2, $height, $grey); header("Content-Type: image/jpeg"); header("Cache-Control: no-cache, must-revalidate"); ImageJpeg($image); ImageDestroy($image); }
function guvenlik_resmi() { $sifre = substr(md5(rand(0, 999999999999)), -5); if ($sifre) { $this->session->set_userdata('koruma', $sifre); $yukseklik = 62; $genislik = 200; $resim = ImageCreate($genislik, $yukseklik); $siyah = ImageColorAllocate($resim, 0, 0, 0); $kirmizi = ImageColorAllocate($resim, 182, 16, 99); $beyaz = ImageColorAllocate($resim, 255, 255, 255); ImageFill($resim, 0, 0, $beyaz); $font = 'css/comic.ttf'; $font_boyut = 24; $sM = 30; $uM = 45; //kullanımı //resim adı, font boyutu, yazının açısı, yazının soldan margini, üstten margin, renk, font adı, şifrenin hangi digitinin yazılacağı bellirtiliyor imagettftext($resim, $font_boyut, rand(-45, 45), $sMa = $sM, $uM, rand(0, 255), $font, $sifre[0]); imagettftext($resim, $font_boyut, rand(-45, 45), $sM = $sMa + $sM, $uM, rand(0, 255), $font, $sifre[1]); imagettftext($resim, $font_boyut, rand(-45, 45), $sM = $sMa + $sM, $uM, rand(0, 255), $font, $sifre[2]); imagettftext($resim, $font_boyut, rand(-45, 45), $sM = $sMa + $sM, $uM, rand(0, 255), $font, $sifre[3]); imagettftext($resim, $font_boyut, rand(-45, 45), $sM = $sMa + $sM, $uM, rand(0, 255), $font, $sifre[4]); //ImageRectangle($resim, 0, 0, $genislik-1, $yukseklik-1, $kirmizi); imageline($resim, 0, $yukseklik / 2, $genislik, $yukseklik / 2, $kirmizi); imageline($resim, $genislik / 2, 0, $genislik / 2, $yukseklik, $kirmizi); header("Content-Type: image/png"); ImagePng($resim); ImageDestroy($resim); } exit; }
/** * Generates a random captcha image * **/ function display($cachable = false, $urlparams = false) { // @TODO: Run some cleaning query here to clear the database. JTable::addIncludePath(DISCUSS_TABLES); $id = JRequest::getInt('captcha-id', ''); $captcha = DiscussHelper::getTable('Captcha'); // clearing the oudated keys. $captcha->clear(); // load the captcha records. $captcha->load($id); if (!$captcha->id) { return false; } // @task: Generate a very random integer and take only 5 chars max. $hash = JString::substr(md5(rand(0, 9999)), 0, 5); $captcha->response = $hash; $captcha->store(); // Captcha width and height $width = 100; $height = 20; $image = ImageCreate($width, $height); $white = ImageColorAllocate($image, 255, 255, 255); $black = ImageColorAllocate($image, 0, 0, 0); $gray = ImageColorAllocate($image, 204, 204, 204); ImageFill($image, 0, 0, $white); ImageString($image, 5, 30, 3, $hash, $black); ImageRectangle($image, 0, 0, $width - 1, $height - 1, $gray); imageline($image, 0, $height / 2, $width, $height / 2, $gray); imageline($image, $width / 2, 0, $width / 2, $height, $gray); header('Content-type: image/jpeg'); ImageJpeg($image); ImageDestroy($image); exit; }
function create_image($string_captcha, $width = 130, $height = 35) { //Let's generate a totally random string using md5 // $md5_hash = md5(rand(0,999)); //We don't need a 32 character long string so we trim it down to 5 // $security_code = substr($md5_hash, 15, 5); $security_code = $string_captcha; /* ******************************************** Use this part if you need to Set the session to store the security code */ $_SESSION['security_code'] = $security_code; $CodeInd = 0; $arrSecCode = array(); $chars = preg_split('//', $security_code); $security_code = implode(" ", $chars); //Set the image width and height //$width = 130; //$height = 35; //Create the image resource $image = ImageCreate($width, $height); //We are making three colors, white, black and gray $arrB = array(0, 255, 129, 10, 48, 200, 186); $arrR = array(0, 255, 129, 111, 48, 210, 126); $arrG = array(0, 205, 139, 110, 48, 5, 186); $black = ImageColorAllocate($image, $arrR[rand(0, 6)], $arrG[rand(0, 6)], $arrB[rand(0, 6)]); $white = ImageColorAllocate($image, 255, 255, 255); $grey = ImageColorAllocate($image, 175, 253, 253); //Make the background black ImageFill($image, 0, 0, $black); $font = 5; $arrSel = array(1, 2, 3, 4); $selectedNum = $arrSel[rand(0, 3)]; ImageString($image, $font, 10, 10, $security_code, $white); //Throw in some lines to make it a little bit harder for any bots to break ImageRectangle($image, 0, 0, $width - 1, $height - 1, $grey); if ($selectedNum == 1) { imageline($image, 0, $height / 2, $width, $height / 5, $grey); imageline($image, $width / 2, 0, $width / 3, $height / 5, $grey); imageline($image, $width / 2, 0, $width / 10, $height, $grey); imageline($image, $width / 2, 0, $width / 10, $height / 6, $grey); } if ($selectedNum == 2) { imageline($image, $width / 1, 0, $width / 6, $height, $grey); imageline($image, 0, $height / 5, $width, $height / 8, $grey); imageline($image, 0, $height / 5, $width / 5, $height / 8, $grey); imageline($image, 0, $height / 3, $width, $height, $grey); } if ($selectedNum == 3) { imageline($image, 0, $height, $width, 0, $grey); imageline($image, 0, 0, $height, $height, $grey); imageline($image, $width / 5, 0, $width / 6, $height, $grey); imageline($image, $width / 4, 0, $width / 4, $height, $grey); } //Tell the browser what kind of file is come in header("Content-Type: image/jpeg"); //Output the newly created image in jpeg format ImageJpeg($image); //Free up resources ImageDestroy($image); }
function DrawCanvas() { // Define canvas, so we don't go crazy $ca = $this->ca; ImageFill($this->graph, 0, 0, $this->canvas_size[0] - 1, $this->canvas_size[1] - 1, $this->color['background']); ImageFilledRectangle($this->graph, $ca[0], $ca[1], $ca[2], $ca[3], $this->color['canvas']); // Border lines ImageLine($this->graph, $ca[0], $ca[1], $ca[0], $ca[3], $this->color['border']); ImageLine($this->graph, $ca[2], $ca[1], $ca[2], $ca[3], $this->color['border']); ImageLine($this->graph, $ca[0], $ca[1], $ca[2], $ca[1], $this->color['border']); ImageLine($this->graph, $ca[0], $ca[3], $ca[2], $ca[3], $this->color['border']); // Draw 10ths horizonal and vertical $step = array(($ca[2] - $ca[0]) / $this->interval, ($ca[3] - $ca[1]) / $this->interval); for ($i = $ca[0] + $step[0]; $i <= $ca[2] - $step[0]; $i += $step[0]) { if ($this->options['dashed_grid']) { $this->_DashedLine($i, $ca[1] + 1, $i, $ca[3] - 1, $this->color['grid'], $this->color['background']); } else { ImageLine($this->graph, $i, $ca[1] + 1, $i, $ca[3] - 1, $this->color['grid']); } } for ($i = $ca[1] + $step[1]; $i <= $ca[3] - $step[1]; $i += $step[1]) { if ($this->options['dashed_grid']) { $this->_DashedLine($ca[0] + 1, $i, $ca[2] - 1, $i, $this->color['grid'], $this->color['background']); } else { ImageLine($this->graph, $ca[0] + 1, $i, $ca[2] - 1, $i, $this->color['grid']); } } }
function draw_captcha($security_code) { //Set the image width and height $width = 100; $height = 25; //Create the image resource $image = ImageCreate($width, $height); if (function_exists('imageantialias')) { imageantialias($image, true); } //We are making three colors, white, black and gray $white = ImageColorAllocate($image, 255, 255, 255); $black = ImageColorAllocate($image, 15, 50, 15); $grey = ImageColorAllocate($image, 204, 204, 204); $ellipsec = ImageColorAllocate($image, 0, 100, 60); //Make the background black ImageFill($image, 0, 0, $black); imagefilledellipse($image, 56, 15, 30, 17, $ellipsec); //Add randomly generated string in white to the image ImageString($image, 5, 30, 4, $security_code, $white); //Throw in some lines to make it a little bit harder for any bots to break ImageRectangle($image, 0, 0, $width - 1, $height - 1, $grey); imageline($image, 0, $height / 2 + 3, $width, $height / 2 + 5, $grey); imageline($image, $width / 2 - 14, 0, $width / 2 + 7, $height, $grey); //Tell the browser what kind of file is come in header("Content-Type: image/jpeg"); //Output the newly created image in jpeg format ImageJpeg($image); //Free up resources ImageDestroy($image); }
function create_image() { //Let's generate a totally random string using md5 $md5_hash = md5(rand(0, 999)); //We don't need a 32 character long string so we trim it down to 5 $security_code = substr($md5_hash, 15, 5); //Set the session to store the security code $_SESSION["captchaCode"] = $security_code; //Set the image width and height $width = 100; $height = 20; //Create the image resource $image = ImageCreate($width, $height); //We are making three colors, white, black and gray $white = ImageColorAllocate($image, 255, 255, 255); $black = ImageColorAllocate($image, 0, 0, 0); $grey = ImageColorAllocate($image, 204, 204, 204); //Make the background black ImageFill($image, 0, 0, $black); //Add randomly generated string in white to the image ImageString($image, 3, 30, 3, $security_code, $white); //Throw in some lines to make it a little bit harder for any bots to break ImageRectangle($image, 0, 0, $width - 1, $height - 1, $grey); imageline($image, 0, $height / 2, $width, $height / 2, $grey); imageline($image, $width / 2, 0, $width / 2, $height, $grey); //Tell the browser what kind of file is come in header("Content-Type: image/jpeg"); //Output the newly created image in jpeg format ImageJpeg($image); //Free up resources ImageDestroy($image); }
/** * Generates the captcha image * * @since 4.0 * @access public * @param string * @return */ public function generate() { $id = $this->input->get('id', '', 'int'); // Load up the captcha object $captcha = EB::table('Captcha'); // Clear outdated keys $captcha->clear(); // load the captcha records. $captcha->load($id); if (!$captcha->id) { return false; } // @task: Generate a very random integer and take only 5 chars max. $hash = JString::substr(md5(rand(0, 9999)), 0, 5); $captcha->response = $hash; $captcha->store(); // Captcha width and height $width = 100; $height = 20; $image = ImageCreate($width, $height); $white = ImageColorAllocate($image, 255, 255, 255); $black = ImageColorAllocate($image, 0, 0, 0); $gray = ImageColorAllocate($image, 204, 204, 204); ImageFill($image, 0, 0, $white); ImageString($image, 5, 30, 3, $hash, $black); ImageRectangle($image, 0, 0, $width - 1, $height - 1, $gray); imageline($image, 0, $height / 2, $width, $height / 2, $gray); imageline($image, $width / 2, 0, $width / 2, $height, $gray); header('Content-type: image/jpeg'); ImageJpeg($image); ImageDestroy($image); exit; }
function create($varDesc, $varValues) { Header("Content-type: image/png"); $image = ImageCreate($this->imageWidth, $this->imageHeight); $bgcolor = ImageColorAllocate($image, $this->bgR, $this->bgG, $this->bgB); $white = ImageColorAllocate($image, 255, 255, 255); $black = ImageColorAllocate($image, 0, 0, 0); ImageFill($image, 0, 0, $bgcolor); $num = 0; foreach ($varDesc as $v) { $r = rand(0, 255); $g = rand(0, 255); $b = rand(0, 255); $sliceColors[$num] = ImageColorAllocate($image, $r, $g, $b); $num++; } // now $num has the number of elements // draw the box ImageLine($image, 0, 0, $this->imageWidth - 1, 0, $black); ImageLine($image, $this->imageWidth - 1, 0, $this->imageWidth - 1, $this->imageHeight - 1, $black); ImageLine($image, $this->imageWidth - 1, $this->imageHeight - 1, 0, $this->imageHeight - 1, $black); ImageLine($image, 0, $this->imageHeight - 1, 0, 0, $black); $total = 0; for ($x = 0; $x < $num; $x++) { $total += $varValues[$x]; } // convert each slice into corresponding percentage of 360-degree circle for ($x = 0; $x < $num; $x++) { $angles[$x] = $varValues[$x] / $total * 360; } for ($x = 0; $x < $num; $x++) { // calculate and draw arc corresponding to each slice ImageArc($image, $this->imageWidth / 4, $this->imageHeight / 2, $this->imageWidth / 3, $this->imageHeight / 3, $angle, $angle + $angles[$x], $sliceColors[$x]); $angle = $angle + $angles[$x]; $x1 = round($this->imageWidth / 4 + $this->imageWidth / 3 * cos($angle * pi() / 180) / 2); $y1 = round($this->imageHeight / 2 + $this->imageHeight / 3 * sin($angle * pi() / 180) / 2); // demarcate slice with another line ImageLine($image, $this->imageWidth / 4, $this->imageHeight / 2, $x1, $y1, $sliceColors[$x]); } // fill in the arcs $angle = 0; for ($x = 0; $x < $num; $x++) { $x1 = round($this->imageWidth / 4 + $this->imageWidth / 3 * cos(($angle + $angles[$x] / 2) * pi() / 180) / 4); $y1 = round($this->imageHeight / 2 + $this->imageHeight / 3 * sin(($angle + $angles[$x] / 2) * pi() / 180) / 4); ImageFill($image, $x1, $y1, $sliceColors[$x]); $angle = $angle + $angles[$x]; } // put the desc strings ImageString($image, 5, $this->imageWidth / 2, 60, "Legend", $black); for ($x = 0; $x < $num; $x++) { $fl = sprintf("%.2f", $varValues[$x] * 100 / $total); $str = $varDesc[$x] . " (" . $fl . "%)"; ImageString($image, 3, $this->imageWidth / 2, ($x + 5) * 20, $str, $sliceColors[$x]); } // put the title ImageString($image, 5, 20, 20, $this->title, $black); ImagePng($image); ImageDestroy($image); }
/** * This function is used to create captcha * @access public * @param int $width : Capach image width * @param int $height : Captcha image height * @param int $length : Captcha string length * @param hex $fontColor : Captcha image font color code * @param hex $bgColor : Captcha image background color code * @param bool $pattern : Captcha image pattern * @return image : return captcha image **/ public function createCaptcha($width = 150, $height = 50, $lenght = 5, $fontcolor = 0, $bgcolor = 4, $pattern = false) { /** * Set type to each variable to avoid any vulnarables * */ $flag = settype($width, "int"); $width = $flag === false ? 140 : $width; $flag = settype($height, 'integer'); $height = $flag === false ? 50 : $height; $flag = settype($pattern, 'boolean'); $pattern = $flag === false ? false : $pattern; /* * To create security code which is placed over the captcha image */ $security_code = $this->createSecurityCode($lenght); /* * Store the generated security code to the session for the comaprion which the end user enter the code. * It also removing white spaces in the security code. */ $_SESSION["security_code"] = md5(str_replace(" ", "", $security_code)); /* * create the image in specified width and height */ $image = ImageCreate($width, $height); /* * set font color */ $this->font_color = $this->setColor($image, $fontcolor); /* * set background color */ $this->bg_color = $this->setColor($image, $bgcolor); /* * Create background */ ImageFill($image, 0, 0, $this->bg_color); /* * Generate noice */ if ($pattern) { $this->generateNoice($image, 100, $width, $height, 10); } /* * Write security code on the image */ $width = ($width - strlen($security_code) * 7) / 2; ImageString($image, 4, (int) $width, $height / 4, $security_code, $this->font_color); //ImageRectangle($image,0,0,$width-1,$height-1,$grey); /* * Rendering to image */ header("Content-Type: image/jpeg"); ImageJpeg($image); ImageDestroy($image); }
function __construct() { header('Pragma: public'); header('Cache-Control: max-age=86400'); header('Expires: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', time() + 86400)); header('Content-Type: image/png'); $this->image = ImageCreateTrueColor(96, 96); ImageSaveAlpha($this->image, true); ImageFill($this->image, 0, 0, ImageColorAllocateAlpha($this->image, 0, 0, 0, 127)); }
public static function image($id, $number) { $cheatForm = SecureFormModel::where('_id', $id)->get(); if ($cheatForm->isEmpty()) { return false; } else { $image = ImageCreate(1, 1); $color = $cheatForm->first()->solution == $number ? ImageColorAllocate($image, 52, 152, 219) : ImageColorAllocate($image, 44, 62, 80); ImageFill($image, 0, 0, $color); return $image; } }
function linealfa ($alfa, $alfaold, $numcolor) { global $xsize, $ysize, $im, $black, $color; $gradus = ($alfa + $alfaold)/2; $alfa = ($alfa * pi())/180; $x = $xsize/2 + ($xsize/2) * sin($alfa); $y = $ysize/2 - ($xsize/2) * cos($alfa); ImageLine($im, $xsize/2, $ysize/2, $x, $y, $black); $gradus = ($gradus * pi())/180; $x = $xsize/2 + ($xsize/3) * sin($gradus); $y = $ysize/2 - ($ysize/3) * cos($gradus); if ($gradus!=0) ImageFill($im, $x, $y, $color[$numcolor]); }
/** * Generates a random captcha image * **/ function display($cachable = false, $urlparams = false) { $id = JRequest::getInt( 'captcha-id' , '' ); $captcha = Komento::getTable( 'Captcha' , 'KomentoTable' ); if( ob_get_length() !== false ) { while (@ ob_end_clean()); if( function_exists( 'ob_clean' ) ) { @ob_clean(); } } // clearing the oudated keys. $captcha->clear(); // load the captcha records. $captcha->load( $id ); if( !$captcha->id ) { return false; } // @task: Generate a very random integer and take only 5 chars max. $hash = JString::substr( md5( rand( 0, 9999 ) ) , 0 , 5 ); $captcha->response = $hash; $captcha->store(); // Captcha width and height $width = 100; $height = 20; $image = ImageCreate( $width , $height ); $white = ImageColorAllocate($image, 255, 255, 255); $black = ImageColorAllocate($image, 0, 0, 0); $gray = ImageColorAllocate($image, 204, 204, 204); ImageFill( $image , 0 , 0 , $white ); ImageString( $image , 5 , 30 , 3 , $hash , $black ); ImageRectangle( $image , 0 , 0 , $width - 1 , $height - 1 , $gray ); imageline( $image , 0 , $height / 2 , $width , $height / 2 , $gray ); imageline( $image , $width / 2 , 0 , $width / 2 , $height , $gray ); header( 'Content-type: image/jpeg' ); ImageJpeg( $image ); ImageDestroy($image); exit; }
function Gpf_BarCode_Type_BarCode($Width = BCD_DEFAULT_Width, $Height = BCD_DEFAULT_HEIGHT, $Style = BCD_DEFAULT_STYLE) { $this->mWidth = $Width; $this->mHeight = $Height; $this->mStyle = $Style; $this->mFont = BCD_DEFAULT_FONT; $this->mImg = ImageCreate($this->mWidth, $this->mHeight); $dbColor = $this->mStyle & BCS_REVERSE_COLOR ? BCD_DEFAULT_FOREGROUND_COLOR : BCD_DEFAULT_BACKGROUND_COLOR; $dfColor = $this->mStyle & BCS_REVERSE_COLOR ? BCD_DEFAULT_BACKGROUND_COLOR : BCD_DEFAULT_FOREGROUND_COLOR; $this->mBgcolor = ImageColorAllocate($this->mImg, ($dbColor & 0xff0000) >> 16, ($dbColor & 0xff00) >> 8, $dbColor & 0xff); $this->mBrush = ImageColorAllocate($this->mImg, ($dfColor & 0xff0000) >> 16, ($dfColor & 0xff00) >> 8, $dfColor & 0xff); if (!($this->mStyle & BCS_TRANSPARENT)) { ImageFill($this->mImg, $this->mWidth, $this->mHeight, $this->mBgcolor); } }
function generate_karte() { $name = "Michel Giehl"; $uuid = "ffffff"; $image = ImageCreate(600, 300); $white = ImageColorAllocate($image, 255, 255, 255); $black = ImageColorAllocate($image, 0, 0, 0); ImageFill($image, 0, 0, $black); ImageString($image, 10, 0, 250, $name, $white); ImageString($image, 10, 500, 250, $uuid, $white); header("Content-Type: image/png"); imagepng($image); ImageDestroy($image); echo "<img src=\"http://boocking.ereboss.net/card_generating/barcode.php?text=" . $uuid . " alt=\" . {$uuid} . \">"; }
public function show_image($width = 88, $height = 31) { if (isSet($this->tt_font)) { if (!file_exists($this->tt_font)) exit('The path to the true type font is incorrect.'); } if ($this->chars_number < 3) exit('The captcha code must have at least 3 characters'); $string = $this->generate_string(); $im = ImageCreate($width, $height); /* Set a White & Transparent Background Color */ $bg = ImageColorAllocateAlpha($im, 255, 255, 255, 127); // (PHP 4 >= 4.3.2, PHP 5) ImageFill($im, 0, 0, $bg); /* Border Color */ if ($this->border_color) { list($red, $green, $blue) = explode(',', $this->border_color); $border = ImageColorAllocate($im, $red, $green, $blue); ImageRectangle($im, 0, 0, $width - 1, $height - 1, $border); } $textcolor = ImageColorAllocate($im, 191, 120, 120); $y = 24; for ($i = 0; $i < $this->chars_number; $i++) { $char = $string[$i]; $factor = 15; $x = ($factor * ($i + 1)) - 6; $angle = rand(1, 15); imagettftext($im, $this->font_size, $angle, $x, $y, $textcolor, $this->tt_font, $char); } $_SESSION['security_code'] = md5($string); /* Output the verification image */ header("Content-type: image/png"); ImagePNG($im); exit; }
function kleeja_cpatcha_image() { //Let's generate a totally random string using md5 $md5_hash = md5(rand(0, 999)); //I think the bad things in captcha is two things, O and 0 , so let's remove zero. $security_code = str_replace('0', '', $md5_hash); //We don't need a 32 character long string so we trim it down to 5 $security_code = substr($security_code, 15, 4); //Set the session to store the security code $_SESSION["klj_sec_code"] = $security_code; //Set the image width and height $width = 150; $height = 25; //Create the image resource $image = ImageCreate($width, $height); //We are making three colors, white, black and gray $white = ImageColorAllocate($image, 255, 255, 255); $black = ImageColorAllocate($image, rand(0, 100), 0, rand(0, 50)); $grey = ImageColorAllocate($image, 204, 204, 204); //Make the background black ImageFill($image, 0, 0, $black); //options $x = 10; $y = 14; $angle = rand(-7, -10); //Add randomly generated string in white to the image if (function_exists('imagettftext')) { // // We figure a bug that happens when you add font name without './' before it .. // he search in the Linux fonts cache , but when you add './' he will know it's our font. // imagettftext($image, 16, $angle, rand(50, $x), $y + rand(1, 3), $white, dirname(__FILE__) . '/arial.ttf', $security_code); #imagettftext ($image, 7, 0, $width-30, $height-4, $white,'./arial.ttf', 'Kleeja'); } else { imagestring($image, imageloadfont(dirname(__FILE__) . '/arial.gdf'), $x + rand(10, 15), $y - rand(10, 15), $security_code, $white); #imagestring ($image, 1, $width-35, $height-10, 'Kleeja', ImageColorAllocate($image, 200, 200, 200)); } //Throw in some lines to make it a little bit harder for any bots to break ImageRectangle($image, 0, 0, $width - 1, $height - 1, $grey); imageline($image, 0, $height / 2, $width, $height / 2, $grey); imageline($image, $width / 2, 0, $width / 2, $height, $grey); //Tell the browser what kind of file is come in header("Content-Type: image/png"); //Output the newly created image in jpeg format ImagePng($image); //Free up resources ImageDestroy($image); }
function create_image() { $md5_hash = md5(rand(0, 999)); $security_code = substr($md5_hash, 15, 5); $_SESSION["security_code"] = $security_code; $width = 60; $height = 20; $image = ImageCreate($width, $height); $string = ImageColorAllocate($image, 0, 0, 0); $back = ImageColorAllocate($image, 255, 255, 255); ImageFill($image, 0, 0, $back); ImageString($image, 9, 9, 7, $security_code, $string); header("Content-Type: image/png"); ImageJpeg($image); ImageDestroy($image); }
public function create_image() { $md5_hash = md5(rand(0, 999)); $security_code = substr($md5_hash, 15, 5); $_SESSION['security_code'] = $security_code; $width = 80; $height = 25; $image = ImageCreate($width, $height); $white = ImageColorAllocate($image, 255, 255, 255); $black = ImageColorAllocate($image, 0, 0, 0); ImageFill($image, 0, 0, $black); ImageString($image, 5, 20, 5, $security_code, $white); header("Content-Type: image/jpeg"); ImageJpeg($image); ImageDestroy($image); }
function BarcodeObject($Width = BCD_DEFAULT_Width, $Height = BCD_DEFAULT_HEIGHT, $Style = BCD_DEFAULT_STYLE) { $this->mWidth = $Width; $this->mHeight = $Height; $this->mStyle = $Style; $this->mFont = BCD_DEFAULT_FONT; $this->mImg = ImageCreate($this->mWidth, $this->mHeight); $dbColor = $this->mStyle & BCS_REVERSE_COLOR ? BCD_DEFAULT_FOREGROUND_COLOR : BCD_DEFAULT_BACKGROUND_COLOR; $dfColor = $this->mStyle & BCS_REVERSE_COLOR ? BCD_DEFAULT_BACKGROUND_COLOR : BCD_DEFAULT_FOREGROUND_COLOR; $this->mBgcolor = ImageColorAllocate($this->mImg, ($dbColor & 0xff0000) >> 16, ($dbColor & 0xff00) >> 8, $dbColor & 0xff); $this->mBrush = ImageColorAllocate($this->mImg, ($dfColor & 0xff0000) >> 16, ($dfColor & 0xff00) >> 8, $dfColor & 0xff); if (!($this->mStyle & BCS_TRANSPARENT)) { ImageFill($this->mImg, $this->mWidth, $this->mHeight, $this->mBgcolor); } __TRACE__("OBJECT CONSTRUCTION: " . $this->mWidth . " " . $this->mHeight . " " . $this->mStyle); }
function create_image() { $md5_hash = md5(rand(0, 999)); $code = substr($md5_hash, 15, 5); $_SESSION["code"] = $code; $width = 100; $height = 30; $image = ImageCreate($width, $height); $white = ImageColorAllocate($image, 255, 255, 255); $black = ImageColorAllocate($image, 0, 0, 0); ImageFill($image, 0, 0, $black); ImageString($image, 5, 30, 6, $code, $white); header("Content-Type: image/jpeg"); ImageJpeg($image); ImageDestroy($image); }
function scale ($width,$height,$fit='all',$alpha=false,$fill=false,$dx=false,$dy=false,$cropscale=false) { $this->aspect = $width/$height; // Allocate a new true color image $this->canvas($width,$height,$alpha); // Determine the dimensions to use for resizing $this->dimensions($width,$height,$fit,$dx,$dy,$cropscale); // Fill image with matte color if ($fit == "matte") { $rgb = false; if (is_int($fill)) $rgb = $this->hexrgb($fill); // Default to white if (!is_array($rgb)) $rgb = array('red'=>255,'green'=>255,'blue'=>255); // Allocate the color in the image palette $matte = ImageColorAllocate($this->processed, $rgb['red'], $rgb['green'], $rgb['blue']); // Fill the canvas ImageFill($this->processed,0,0,$matte); } if (!$this->src->image) { // Determine the mock dimensions from the resample operation if ($fit == "crop") { $this->width = min($width,$this->width); $this->height = min($height,$this->height); } elseif ($fill !== false) { $this->width = $width; $this->height = $height; } return; } // Resample the image ImageCopyResampled( $this->processed,$this->src->image, $this->dx, $this->dy, // dest_x, dest_y 0, 0, // src_x, src_y $this->width, $this->height, // dest_width, dest_height $this->src->width, $this->src->height // src_width, src_height ); $this->width = imagesx($this->processed); $this->height = imagesy($this->processed); if (function_exists('apply_filters')) return apply_filters('ecart_image_scale',$this); }
function ImageEditor($filename, $path, $col = NULL) { $this->font = false; $this->error = false; $this->size = 25; if (is_numeric($filename) && is_numeric($path)) { $this->x = $filename; $this->y = $path; $this->type = "jpg"; $this->img = imagecreatetruecolor($this->x, $this->y); if (is_array($col)) { $colour = ImageColorAllocate($this->img, $col[0], $col[1], $col[2]); ImageFill($this->img, 0, 0, $colour); } } else { ## FIRST SEE IF WE CAN FIND IMAGE if (file_exists($path . $filename)) { $file = $path . $filename; } else { if (file_exists($path . "/" . $filename)) { $file = $path . "/" . $filename; } else { $this->errorImage("File Could Not Be Loaded"); } } if (!$this->error) { ## LOAD OUR IMAGE WITH CORRECT FUNCTION $arrImage = explode('.', $filename); $this->type = strtolower(end($arrImage)); if ($this->type == 'jpg' || $this->type == 'jpeg') { $this->img = @imagecreatefromjpeg($file); } else { if ($this->type == 'png') { $this->img = @imagecreatefrompng($file); } else { if ($this->type == 'gif') { $this->img = @imagecreatefromgif($file); } } } ## SET OUR IMAGE VARIABLES $this->x = imagesx($this->img); $this->y = imagesy($this->img); } } }
public static function createImage($width, $height, $lenght) { // First generate the code $code = Captcha::createCode($lenght); // Create the images $img = imagecreatetruecolor($width, $height); $bgColor = imagecolorallocate($img, 245, 245, 245); ImageFill($img, 0, 0, $bgColor); $security_number = empty($_SESSION['security_number']) ? 'error' : $_SESSION['security_number']; $image_text = $security_number; $red = rand(100, 255); $green = rand(100, 255); $blue = rand(100, 255); $text_color = imagecolorallocate($img, 255 - $red, 255 - $green, 255 - $blue); $text = imagettftext($img, 15, rand(-10, 10), rand(10, 40), rand(25, 30), $text_color, "assets/fonts/courbd.ttf", $image_text); imagejpeg($img); }
public function executeSecurityImage(sfWebRequest $request) { $font = 'monofont.ttf'; $characters = 6; $width = 120; $height = 40; // code /* list all possible characters, similar looking characters and vowels have been removed */ $possible = '23456789bcdfghjkmnpqrstvwxyz'; $code = ''; $i = 0; while ($i < $characters) { $code .= substr($possible, mt_rand(0, strlen($possible) - 1), 1); $i++; } $_SESSION['securityImage'] = $code; //$this->getUser()->setAttribute("securityImage", $code); //Set the image width and height $width = 100; $height = 20; //Create the image resource $image = ImageCreate($width, $height); //We are making three colors, white, black and gray $white = ImageColorAllocate($image, 255, 255, 255); $black = ImageColorAllocate($image, 0, 0, 0); $grey = ImageColorAllocate($image, 204, 204, 204); //Make the background black ImageFill($image, 0, 0, $black); //Add randomly generated string in white to the image ImageString($image, 5, 20, 2, $code, $white); //Throw in some lines to make it a little bit harder for any bots to break ImageRectangle($image, 0, 0, $width - 1, $height - 1, $grey); //imageline($image, 0, $height/2, $width, $height/5, $grey); imageline($image, $width / 3, 0, $width / 6, $height, $grey); imageline($image, $width / 3, $height / 2, $width / 2, $height, $grey); imageline($image, $width / 2, $height / 2, $width, $height, $grey); //Tell the browser what kind of file is come in header("Content-Type: image/jpeg"); //Output the newly created image in jpeg format ImageJpeg($image); //Free up resources ImageDestroy($image); exit; }
function graph($name, $w, $h, $bgc, $fgc, $title, $xtitle, $ytitle, $numX, $xTitles, $xValues, $bc) { $top = 15; $right = 5; $left = 35; $bottom = 25; $image = ImageCreate($w, $h); $cols = colours($image); ImageFill($image, 0, 0, $cols[$bgc]); drawAxis($image, $w, $h, $cols[$fgc], $top, $right, $left, $bottom); drawLines($image, $w, $h, $cols[$fgc], $top, $right, $left, $bottom); drawTitles($image, $w, $h, $cols[$fgc], $title, $xtitle, $ytitle); drawXLables($image, $w, $h, $right, $left, $cols[$fgc], $numX, $xTitles); $max = calcMaxDataItem($xValues, $numX); drawYLables($image, $w, $h, $cols[$fgc], $top, $right, $left, $bottom, $max); drawData($image, $w, $h, $cols[$bc], $top, $right, $left, $bottom, $numX, $xValues, $max); ImageJPEG($image, $name); ImageDestroy($image); }
public function ReportImage($params) { $this->imgFile = isset($params['imgFile']) ? (string) $params['imgFile'] : $this->{$imgFile}; $this->displayTrue = isset($params['displayTrue']) ? (bool) $params['displayTrue'] : $this->displayTrue; $this->imgWidth = isset($params['imgWidth']) ? (int) $params['imgWidth'] : $this->imgWidth; $this->imgHeight = isset($params['imgHeight']) ? (int) $params['imgHeight'] : $this->imgHeight; $this->shadowDrop = isset($params['shadowDrop']) ? (int) $params['shadowDrop'] : $this->shadowDrop; $this->shadowDark = isset($params['shadowDark']) ? (bool) $params['shadowDark'] : $this->shadowDark; $this->borderColor = isset($params['borderColor']) ? (string) $params['borderColor'] : $this->borderColor; $this->outlineColor = isset($params['outlineColor']) ? (string) $params['outlineColor'] : $this->outlineColor; $this->gridlineColor = isset($params['gridlineColor']) ? (string) $params['gridlineColor'] : $this->gridlineColor; $this->baselineColor = isset($params['baselineColor']) ? (string) $params['baselineColor'] : $this->baselineColor; $this->barColor = isset($params['barColor']) ? (string) $params['barColor'] : $this->barColor; $this->backgroundColor = isset($params['backgroundColor']) ? (string) $params['backgroundColor'] : $this->backgroundColor; // Create the report image $this->img = ImageCreateTrueColor($this->imgWidth, $this->imgHeight); // -- Put the border on it ImageFill($this->img, 0, 0, chartColorHex($this->img, $this->borderColor)); }
function mkimage($data) { $data_array = explode("\n", $data); $c = count($data_array) - 1; $image_size = $c; $output_size = ($c + $this->quiet_zone * 2) * $this->module_size; $img = ImageCreate($image_size, $image_size); $white = ImageColorAllocate($img, 255, 255, 255); $black = ImageColorAllocate($img, 0, 0, 0); $im = ImageCreate($output_size, $output_size); $white2 = ImageColorAllocate($im, 255, 255, 255); ImageFill($im, 0, 0, $white2); $y = 0; foreach ($data_array as $row) { $x = 0; while ($x < $image_size) { if (substr($row, $x, 1) == "1") { ImageSetPixel($img, $x, $y, $black); } $x++; } $y++; } $quiet_zone_offset = $this->quiet_zone * $this->module_size; $image_width = $image_size * $this->module_size; ImageCopyResized($im, $img, $quiet_zone_offset, $quiet_zone_offset, 0, 0, $image_width, $image_width, $image_size, $image_size); return $im; }