本文整理汇总了PHP中ImageDestroy函数的典型用法代码示例。如果您正苦于以下问题:PHP ImageDestroy函数的具体用法?PHP ImageDestroy怎么用?PHP ImageDestroy使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ImageDestroy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Mostrar
public static function Mostrar()
{
// La cantidad de caracteres que va a mostrar el captcha
$longitud = 5;
// Los caracteres que nuestro captcha va a considerar
$caracteres = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
// El catpcha creado
$captcha = "";
for ($i = 0; $i < $longitud; $i++) {
$captcha .= $caracteres[rand(0, strlen($caracteres) - 1)];
}
// Guardamos el catpcha en sesion para validar
$_SESSION['captcha_codigo'] = strtolower($captcha);
// Creamos la imagen
// Creamos una imagen con forma de rectangulo por las medidas definidas a continuación
$ancho = 600;
$alto = 180;
$fuente_tamano = 80;
$fuente = 'lib/captcha/font.ttf';
$img = imagecreatetruecolor($ancho, $alto);
// Agregamos el texto
$blanco = ImageColorAllocate($img, 255, 255, 255);
// BLANCO
// Coordenadas de donde va a ir el texto
$x = $fuente_tamano;
$y = $alto / 2 + 25;
// El texto blanco
imagettftext($img, $fuente_tamano, 0, $x, $y, $blanco, $fuente, $captcha);
// Generamos la imagen
header("Content-Type: image/jpeg");
ImageJpeg($img);
ImageDestroy($img);
}
示例2: Resampling
function Resampling($tmp_name, $directorio, $name)
{
// Indico el destino del directorio de la imagen
$imagen_origen = ImageCreateFromJPEG($tmp_name);
// Calculo el tamaño de la imagen original
$tam_ancho = imagesx($imagen_origen);
$tam_alto = imagesy($imagen_origen);
//Calculo la medida que va a tener
if ($tam_ancho >= $tam_alto) {
$ancho = 38;
$alto = 38 * $tam_alto / $tam_ancho;
} else {
$ancho = 38 * $tam_ancho / $tam_alto;
$alto = 38;
}
//Creo una imagen
$imagen_destino = ImageCreateTrueColor($ancho, $alto);
//Resize
imagecopyresized($imagen_destino, $imagen_origen, 0, 0, 0, 0, $ancho, $alto, $tam_ancho, $tam_alto);
$nombre_destino = $directorio . $name;
//Genero Copia Destino
ImageJPEG($imagen_destino, $nombre_destino, 100);
//Borro imagen virtual
ImageDestroy($imagen_destino);
}
示例3: resize
function resize($img, $wid, $hei = 0, $quality = 100)
{
$hei == 0 && ($hei = $wid);
$this->srcimg = $img;
$this->resize_width = $wid;
$this->resize_height = $hei;
//图片的类型
$this->type = strtolower(substr(strrchr($this->srcimg, "."), 1));
$this->quality = $quality;
//初始化图象
if (!$this->initi_img()) {
return false;
}
if (!$this->im) {
$this->error = '生成资源出错';
return false;
}
//目标图象地址
//$this -> dst_img($dstpath);
$this->dstimg = $this->srcimg . '.thumb.jpg';
$this->width = imagesx($this->im);
$this->height = imagesy($this->im);
//生成图象
$flag = $this->newimg();
ImageDestroy($this->im);
return $flag;
}
示例4: image
private static function image($frame, $pixelPerPoint = 4, $outerFrame = 4, $wh = false)
{
$h = count($frame);
$w = strlen($frame[0]);
$imgW = $w + 2 * $outerFrame;
$imgH = $h + 2 * $outerFrame;
$base_image = ImageCreate($imgW, $imgH);
$col[0] = ImageColorAllocate($base_image, 255, 255, 255);
$col[1] = ImageColorAllocate($base_image, 0, 0, 0);
imagefill($base_image, 0, 0, $col[0]);
for ($y = 0; $y < $h; $y++) {
for ($x = 0; $x < $w; $x++) {
if ($frame[$y][$x] == '1') {
ImageSetPixel($base_image, $x + $outerFrame, $y + $outerFrame, $col[1]);
}
}
}
$www = $imgW * $pixelPerPoint;
$hhh = $imgH * $pixelPerPoint;
if (is_array($wh)) {
$www = $wh[0];
$hhh = $wh[1];
}
$target_image = ImageCreate($www, $hhh);
ImageCopyResized($target_image, $base_image, 0, 0, 0, 0, $www, $hhh, $imgW, $imgH);
ImageDestroy($base_image);
return $target_image;
}
示例5: update_picture
public function update_picture()
{
if (trim($_FILES["myfile"]["tmp_name"]) != "") {
$images = $_FILES["myfile"]["tmp_name"];
$new_images = "thumb_" . $this->session->userdata('std_cardid') . '_' . $_FILES["myfile"]["name"];
copy($_FILES["myfile"]["tmp_name"], "assets/uploads/photo/" . $_FILES["myfile"]["name"]);
$width = 150;
//*** Fix Width & Heigh (Autu caculate) ***//
$size = GetimageSize($images);
$height = round($width * $size[1] / $size[0]);
$images_orig = ImageCreateFromJPEG($images);
$photoX = ImagesX($images_orig);
$photoY = ImagesY($images_orig);
$images_fin = ImageCreateTrueColor($width, $height);
ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width + 1, $height + 1, $photoX, $photoY);
ImageJPEG($images_fin, "assets/uploads/photo/" . $new_images);
ImageDestroy($images_orig);
ImageDestroy($images_fin);
}
$fileName = $_FILES["myfile"]["name"];
$ret[] = $fileName;
$data_picture = array('std_picture' => $new_images);
$this->Students_model->update_student_picture($this->session->userdata('std_cardid'), $data_picture);
//echo base_url()."assets/uploads/photo/".$new_images;
redirect('/front_profiles/student_edit', 'refresh');
//ChromePhp::log($ret);
//exit;
}
示例6: getimagesize_remote
function getimagesize_remote($image_url)
{
if (($handle = @fopen($image_url, "rb")) != true) {
return;
}
$contents = "";
$count = 0;
if ($handle) {
do {
$count += 1;
$data = fread($handle, 8192);
if (strlen($data) == 0) {
break;
}
$contents .= $data;
} while (true);
} else {
return false;
}
fclose($handle);
$im = ImageCreateFromString($contents);
if (!$im) {
return false;
}
$gis[0] = ImageSX($im);
$gis[1] = ImageSY($im);
// array member 3 is used below to keep with current getimagesize standards
$gis[3] = "width={$gis[0]} height={$gis[1]}";
ImageDestroy($im);
return $gis;
}
示例7: fixOrientation
public function fixOrientation()
{
if (exif_imagetype($this->image) == 2) {
$exif = exif_read_data($this->image);
if (array_key_exists('Orientation', $exif)) {
$orientation = $exif['Orientation'];
$images_orig = ImageCreateFromJPEG($this->image);
$rotate = "";
switch ($orientation) {
case 3:
$rotate = imagerotate($images_orig, 180, 0);
break;
case 6:
$rotate = imagerotate($images_orig, -90, 0);
break;
case 8:
$rotate = imagerotate($images_orig, 90, 0);
break;
}
if ($rotate != "") {
ImageJPEG($rotate, $this->image);
ImageDestroy($rotate);
}
ImageDestroy($images_orig);
}
}
}
示例8: init_resultat_election
function init_resultat_election()
{
global $image, $blanc, $noir, $gris, $gris2;
header("Content-type: image/png");
$annee = $_REQUEST[annee];
$genre = $_REQUEST[genre];
$type = $_REQUEST[type];
$lesMiss = selectDbMiss($annee, $genre, $type, "", true);
usort($lesMiss, "callback_sort_nb_votes");
$nb = count($lesMiss);
$hauteur = TAILLE_BARRE * $nb;
$largeur = TAILLE_HAUTEUR;
$image = ImageCreate($hauteur, $largeur);
// On passe en blanc le fond de l'image
$blanc = imagecolorallocate($image, 255, 255, 255);
$noir = imagecolorallocate($image, 0, 0, 0);
$gris = ImageColorAllocate($image, 190, 190, 190);
$gris2 = ImageColorAllocate($image, 140, 140, 140);
imagefilledrectangle($image, 0, 0, $largeur, $hauteur, $blanc);
$total_votes = nombre_votes_db($annee, $genre, $type);
dessine_nom_results_miss($lesMiss, $total_votes);
// Génération de l'image
ImagePng($image);
// Desctruction de l'image
ImageDestroy($image);
}
示例9: show
public function show()
{
$size = min($this->im_y, $this->im_x / $this->text_num);
$size = ceil($size * 0.8);
$im = imagecreatetruecolor($this->im_x, $this->im_y);
$text_c = imagecolorallocate($im, 255, 0, 0);
$bg_c = imagecolorallocate($im, 255, 255, 255);
imagefill($im, 0, 0, $bg_c);
for ($i = 0; $i < $this->text_num; $i++) {
$ypos = $size * 1.2;
if (preg_match('/[ygJup]/', $this->text[$i])) {
$ypos = ceil($ypos * 0.8);
}
//反色
$rnd = rand(1, $this->text_num - 1);
if ($i % $this->text_num == $rnd) {
imagefilledellipse($im, $this->im_x * 0.05 + $i * $size * 1.3 + $size / 2, $ypos / 2, $size * 1.2, $this->im_y * 1.1, $text_c);
imagettftext($im, $size, 0, $this->im_x * 0.05 + $i * $size * 1.3, $ypos, $bg_c, $this->ttf_file, $this->text[$i]);
} else {
imagettftext($im, $size, rand(-20, 20), $this->im_x * 0.05 + $i * $size * 1.3, $ypos, $text_c, $this->ttf_file, $this->text[$i]);
}
}
ob_clean();
header("Content-type: image/png");
ImagePNG($im);
ImageDestroy($im);
echo '= ' . base64_encode('@author:miaokuan<eyou80@gmail.com>');
}
示例10: guvenlik_resmi
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;
}
示例11: getAuthImage
function getAuthImage($text)
{
$this->setpin($text);
$im_x = 160;
$im_y = 40;
$im = imagecreatetruecolor($im_x, $im_y);
$text_c = ImageColorAllocate($im, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
$tmpC0 = mt_rand(100, 255);
$tmpC1 = mt_rand(100, 255);
$tmpC2 = mt_rand(100, 255);
$buttum_c = ImageColorAllocate($im, $tmpC0, $tmpC1, $tmpC2);
imagefill($im, 16, 13, $buttum_c);
$font = PATH_SYS_PUBLIC . 'font-awesome/fonts/verdana.ttf';
for ($i = 0; $i < strlen($text); $i++) {
$tmp = substr($text, $i, 1);
$array = array(-1, 1);
$p = array_rand($array);
$an = $array[$p] * mt_rand(1, 10);
//角度
$size = 28;
imagettftext($im, $size, $an, 15 + $i * $size, 35, $text_c, $font, $tmp);
}
$distortion_im = imagecreatetruecolor($im_x, $im_y);
imagefill($distortion_im, 16, 13, $buttum_c);
for ($i = 0; $i < $im_x; $i++) {
for ($j = 0; $j < $im_y; $j++) {
$rgb = imagecolorat($im, $i, $j);
if ((int) ($i + 20 + sin($j / $im_y * 2 * M_PI) * 10) <= imagesx($distortion_im) && (int) ($i + 20 + sin($j / $im_y * 2 * M_PI) * 10) >= 0) {
imagesetpixel($distortion_im, (int) ($i + 10 + sin($j / $im_y * 2 * M_PI - M_PI * 0.1) * 4), $j, $rgb);
}
}
}
//加入干扰象素;
$count = 160;
//干扰像素的数量
for ($i = 0; $i < $count; $i++) {
$randcolor = ImageColorallocate($distortion_im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
imagesetpixel($distortion_im, mt_rand() % $im_x, mt_rand() % $im_y, $randcolor);
}
$rand = mt_rand(5, 30);
$rand1 = mt_rand(15, 25);
$rand2 = mt_rand(5, 10);
for ($yy = $rand; $yy <= +$rand + 2; $yy++) {
for ($px = -80; $px <= 80; $px = $px + 0.1) {
$x = $px / $rand1;
if ($x != 0) {
$y = sin($x);
}
$py = $y * $rand2;
imagesetpixel($distortion_im, $px + 80, $py + $yy, $text_c);
}
}
//设置文件头;
Header("Content-type: image/JPEG");
//以PNG格式将图像输出到浏览器或文件;
ImagePNG($distortion_im);
//销毁一图像,释放与image关联的内存;
ImageDestroy($distortion_im);
ImageDestroy($im);
}
示例12: create_captcha
function create_captcha($width = 60, $height = 32)
{
session_start();
//生成验证码图片
Header("Content-type: image/PNG");
$im = imagecreate($width, $height);
// width and height of image
$back = ImageColorAllocate($im, 245, 245, 245);
// specify background color
imagefill($im, 0, 0, $back);
// fill the background color into image
$vcodes = "";
srand((double) microtime() * 1000000);
//生成4位数字
for ($i = 0; $i < 4; $i++) {
$font = ImageColorAllocate($im, rand(100, 255), rand(0, 100), rand(100, 255));
// 生成随机颜色
$authnum = rand(1, 9);
$vcodes .= $authnum;
imagestring($im, 5, 2 + $i * 10, 1, $authnum, $font);
}
for ($i = 0; $i < 100; $i++) {
// interuppting
$randcolor = ImageColorallocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
imagesetpixel($im, rand() % 70, rand() % 30, $randcolor);
// 画像素点函数
}
ImagePNG($im);
ImageDestroy($im);
$_SESSION['captcha'] = $vcodes;
}
示例13: JPGText
function JPGText($str, $fontname, $fontsize, $backcol, $txtcol)
{
global $layout;
Header("Last-Modified: " . gmDate("D, d M Y H:i:s", Time()) . " GMT");
Header("Expires: " . gmDate("D, d M Y H:i:s", Time() - 3601) . " GMT");
Header("Pragma: no-cache");
Header("Cache-control: no-cache");
Header("Content-Type: image/jpeg");
$a = ImageTTFBBox($fontsize, 0, $fontname, $str);
$width = $a[2] + 4;
$bla = get_maximum_height($fontname, $fontsize);
$height = $bla[0] + 3;
$bl = $bla[1];
$im = ImageCreate($width, $height);
$bgcol = ImageColorAllocate($im, $backcol['red'], $backcol['green'], $backcol['blue']);
$fgcol = ImageColorAllocate($im, $txtcol['red'], $txtcol['green'], $txtcol['blue']);
if (!function_exists(imagegif)) {
imageTTFText($im, $fontsize, 0, 2, $bl + $fontsize / 6 + 2, $fgcol, $fontname, $str);
imagejpeg($im, "", 80);
} else {
ImageColorTransparent($im, $bgcol);
imageTTFText($im, $fontsize, 0, 2, $bl + $fontsize / 6 + 2, $fgcol, $fontname, $str);
imagegif($im);
}
ImageDestroy($im);
}
示例14: scale
public function scale($dest, $width = null, $height = null, $force = false)
{
$im = $this->getIm();
if (null === $width && null === $height) {
$w = $width = imagesx($im);
$h = $height = imagesy($im);
} else {
if (false === $force) {
$w = imagesx($im);
$h = imagesy($im);
if (null === $width) {
$width = round($w * $height / $h);
} else {
if (null === $height) {
$height = round($h * $width / $w);
} else {
if ($w / $h > $width / $height) {
$height = round($h * $width / $w);
} else {
$width = round($w * $height / $h);
}
}
}
}
}
if (function_exists("imagecreatetruecolor") && ($ni = imagecreatetruecolor($width, $height))) {
imagecopyresampled($ni, $im, 0, 0, 0, 0, $width, $height, $w, $h);
} else {
$ni = imagecreate($width, $height);
imagecopyresized($ni, $im, 0, 0, 0, 0, $width, $height, $w, $h);
}
imagejpeg($ni, $dest);
ImageDestroy($ni);
}
示例15: display
/**
* 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;
}