当前位置: 首页>>代码示例>>PHP>>正文


PHP imageColorAllocateAlpha函数代码示例

本文整理汇总了PHP中imageColorAllocateAlpha函数的典型用法代码示例。如果您正苦于以下问题:PHP imageColorAllocateAlpha函数的具体用法?PHP imageColorAllocateAlpha怎么用?PHP imageColorAllocateAlpha使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了imageColorAllocateAlpha函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * Method to apply a background color to an image resource.
  *
  * @param   array  $options  An array of options for the filter.
  *                           color  Background matte color
  *
  * @return  void
  *
  * @since   3.4
  * @throws  InvalidArgumentException
  * @deprecated  5.0  Use Joomla\Image\Filter\Backgroundfill::execute() instead
  */
 public function execute(array $options = array())
 {
     // Validate that the color value exists and is an integer.
     if (!isset($options['color'])) {
         throw new InvalidArgumentException('No color value was given. Expected string or array.');
     }
     $colorCode = !empty($options['color']) ? $options['color'] : null;
     // Get resource dimensions
     $width = imagesX($this->handle);
     $height = imagesY($this->handle);
     // Sanitize color
     $rgba = $this->sanitizeColor($colorCode);
     // Enforce alpha on source image
     if (imageIsTrueColor($this->handle)) {
         imageAlphaBlending($this->handle, false);
         imageSaveAlpha($this->handle, true);
     }
     // Create background
     $bg = imageCreateTruecolor($width, $height);
     imageSaveAlpha($bg, empty($rgba['alpha']));
     // Allocate background color.
     $color = imageColorAllocateAlpha($bg, $rgba['red'], $rgba['green'], $rgba['blue'], $rgba['alpha']);
     // Fill background
     imageFill($bg, 0, 0, $color);
     // Apply image over background
     imageCopy($bg, $this->handle, 0, 0, 0, 0, $width, $height);
     // Move flattened result onto curent handle.
     // If handle was palette-based, it'll stay like that.
     imageCopy($this->handle, $bg, 0, 0, 0, 0, $width, $height);
     // Free up memory
     imageDestroy($bg);
     return;
 }
开发者ID:Rai-Ka,项目名称:joomla-cms,代码行数:45,代码来源:backgroundfill.php

示例2: allocateColorAlpha

 function allocateColorAlpha($R, $G = null, $B = null, $A = null)
 {
     if (is_array($R)) {
         return imageColorAllocateAlpha($this->handle, $R['red'], $R['green'], $R['blue'], $R['alpha']);
     } else {
         return imageColorAllocateAlpha($this->handle, $R, $G, $B, $A);
     }
 }
开发者ID:BackupTheBerlios,项目名称:haxoo-svn,代码行数:8,代码来源:TrueColorImage.class.php

示例3: init

 function init()
 {
     session_write_close();
     parent::init();
     $options = $this->options;
     $font_path = $this->getFontPath();
     $options['desired_width'] = round($options['desired_width']);
     // $text = $this->wrap($options['font_size'],$options['rotation_angle'],$font_path,$options['text'],$options['desired_width']);
     // $width_height = $this->getTextBoxWidthHeight($options['text'],$font_path);
     $options['halign'] = $options['alignment_center'] == true ? 'center' : ($options['alignment_right'] == 'right' ? 'right' : 'left');
     /*
     	Calculating height of the of the box 
     */
     $im = imagecreatetruecolor($options['desired_width'], 10);
     imagesavealpha($im, true);
     $backgroundColor = imagecolorallocatealpha($im, 255, 255, 255, 127);
     imagefill($im, 0, 0, $backgroundColor);
     $this->phpimage = $im;
     $box = new \GDText\Box($this->phpimage);
     $box->setFontFace($font_path);
     $rgb_color_array = $this->hex2rgb($options['text_color']);
     $box->setFontColor(new \GDText\Color($rgb_color_array[0], $rgb_color_array[1], $rgb_color_array[2]));
     $box->setFontSize($options['font_size']);
     $box->setBox(0, 0, $options['desired_width'], 0);
     $box->setTextAlign($options['halign'], 'top');
     if ($options['underline']) {
         $box->setUnderline();
     }
     // $h = $box->draw($options['text']);
     $this->new_height = $h = $box->getBoxHeight($options['text']);
     //CREATING DEFAULT IMAGES
     $im = imagecreatetruecolor($options['desired_width'], $h);
     imagesavealpha($im, true);
     $backgroundColor = imagecolorallocatealpha($im, 255, 255, 255, 127);
     imagefill($im, 0, 0, $backgroundColor);
     $this->phpimage = $im;
     $box = new \GDText\Box($this->phpimage);
     $box->setFontFace($font_path);
     $rgb_color_array = $this->hex2rgb($options['text_color']);
     $box->setFontColor(new \GDText\Color($rgb_color_array[0], $rgb_color_array[1], $rgb_color_array[2]));
     // $box->setTextShadow(new \GDText\Color(0, 0, 0, 50), 2, 2);
     $box->setFontSize($options['font_size']);
     // $box->enableDebug();
     $box->setBox(0, 0, $options['desired_width'], $h);
     $box->setTextAlign($options['halign'], 'top');
     if ($options['underline']) {
         $box->setUnderline();
     }
     $box->draw($options['text']);
     if ($options['rotation_angle']) {
         $this->phpimage = imagerotate($this->phpimage, $options['rotation_angle'], imageColorAllocateAlpha($im, 255, 255, 255, 127));
         imagealphablending($this->phpimage, false);
         imagesavealpha($this->phpimage, true);
     }
 }
开发者ID:xepan,项目名称:commerce,代码行数:55,代码来源:RenderText.php

示例4: _getColor

 protected function _getColor(Image_3D_Color $color, $alpha = 1.0)
 {
     $values = $color->getValues();
     $values[0] = (int) round($values[0] * 255);
     $values[1] = (int) round($values[1] * 255);
     $values[2] = (int) round($values[2] * 255);
     $values[3] = (int) round((1 - (1 - $values[3]) * $alpha) * 127);
     if ($values[3] > 0) {
         // Tranzparente Farbe allokieren
         $color = imageColorExactAlpha($this->_image, $values[0], $values[1], $values[2], $values[3]);
         if ($color === -1) {
             // Wenn nicht Farbe neu alloziieren
             $color = imageColorAllocateAlpha($this->_image, $values[0], $values[1], $values[2], $values[3]);
         }
     } else {
         // Deckende Farbe allozieren
         $color = imageColorExact($this->_image, $values[0], $values[1], $values[2]);
         if ($color === -1) {
             // Wenn nicht Farbe neu alloziieren
             $color = imageColorAllocate($this->_image, $values[0], $values[1], $values[2]);
         }
     }
     return $color;
 }
开发者ID:ricberw,项目名称:BotQueue,代码行数:24,代码来源:ZBuffer.php

示例5: resize

 /**
  * Method to resize the current image.
  *
  * @param   mixed    $width        The width of the resized image in pixels or a percentage.
  * @param   mixed    $height       The height of the resized image in pixels or a percentage.
  * @param   boolean  $createNew    If true the current image will be cloned, resized and returned; else
  *                                 the current image will be resized and returned.
  * @param   integer  $scaleMethod  Which method to use for scaling
  *
  * @return  KunenaImage
  *
  * @since   11.3
  * @throws  LogicException
  */
 public function resize($width, $height, $createNew = true, $scaleMethod = self::SCALE_INSIDE)
 {
     $config = KunenaFactory::getConfig();
     switch ($config->avatarresizemethod) {
         case '0':
             $resizemethod = 'imagecopyresized';
             break;
         case '1':
             $resizemethod = 'imagecopyresampled';
             break;
         default:
             $resizemethod = 'self::imageCopyResampledBicubic';
             break;
     }
     // Make sure the resource handle is valid.
     if (!$this->isLoaded()) {
         throw new LogicException('No valid image was loaded.');
     }
     // Sanitize width.
     $width = $this->sanitizeWidth($width, $height);
     // Sanitize height.
     $height = $this->sanitizeHeight($height, $width);
     // Prepare the dimensions for the resize operation.
     $dimensions = $this->prepareDimensions($width, $height, $scaleMethod);
     // Instantiate offset.
     $offset = new stdClass();
     $offset->x = $offset->y = 0;
     // Get truecolor handle
     $handle = imagecreatetruecolor($dimensions->width, $dimensions->height);
     // Center image if needed and create the new truecolor image handle.
     if ($scaleMethod == self::SCALE_FIT) {
         // Get the offsets
         $offset->x = round(($width - $dimensions->width) / 2);
         $offset->y = round(($height - $dimensions->height) / 2);
         // Make image transparent, otherwise cavas outside initial image would default to black
         if (!$this->isTransparent()) {
             $transparency = imagecolorAllocateAlpha($this->handle, 0, 0, 0, 127);
             imagecolorTransparent($this->handle, $transparency);
         }
     }
     $imgProperties = self::getImageFileProperties($this->getPath());
     if ($imgProperties->mime == MIME_GIF) {
         $trnprt_indx = imagecolortransparent($this->handle);
         if ($trnprt_indx >= 0 && $trnprt_indx < imagecolorstotal($this->handle)) {
             $trnprt_color = imagecolorsforindex($this->handle, $trnprt_indx);
             $trnprt_indx = imagecolorallocate($handle, $trnprt_color['red'], $trnprt_color['green'], $trnprt_color['blue']);
             imagefill($handle, 0, 0, $trnprt_indx);
             imagecolortransparent($handle, $trnprt_indx);
         }
     } elseif ($imgProperties->mime == MIME_PNG) {
         imagealphablending($handle, false);
         imagesavealpha($handle, true);
         if ($this->isTransparent()) {
             $transparent = imagecolorallocatealpha($this->handle, 255, 255, 255, 127);
             imagefilledrectangle($this->handle, 0, 0, $width, $height, $transparent);
         }
     }
     if ($this->isTransparent()) {
         $trnprt_indx = imagecolortransparent($this->handle);
         if ($trnprt_indx >= 0 && $trnprt_indx < imagecolorstotal($this->handle)) {
             // Get the transparent color values for the current image.
             $rgba = imageColorsForIndex($this->handle, imagecolortransparent($this->handle));
             $color = imageColorAllocateAlpha($handle, $rgba['red'], $rgba['green'], $rgba['blue'], $rgba['alpha']);
         } else {
             $color = imageColorAllocateAlpha($handle, 255, 255, 255, 127);
         }
         // Set the transparent color values for the new image.
         imagecolortransparent($handle, $color);
         imagefill($handle, 0, 0, $color);
         imagecopyresized($handle, $this->handle, $offset->x, $offset->y, 0, 0, $dimensions->width, $dimensions->height, $this->getWidth(), $this->getHeight());
     } else {
         call_user_func_array($resizemethod, array(&$handle, &$this->handle, $offset->x, $offset->y, 0, 0, $dimensions->width, $dimensions->height, $this->getWidth(), $this->getHeight()));
     }
     // If we are resizing to a new image, create a new KunenaImage object.
     if ($createNew) {
         // @codeCoverageIgnoreStart
         $new = new KunenaImage($handle);
         return $new;
         // @codeCoverageIgnoreEnd
     } else {
         // Free the memory from the current handle
         $this->destroy();
         $this->handle = $handle;
         return $this;
     }
 }
开发者ID:densem-2013,项目名称:exikom,代码行数:100,代码来源:image.php

示例6: imagerotate

            if ($px >= $py) {
                $py /= $px;
                $px = 1.0;
            } else {
                $px /= $py;
                $py = 1.0;
            }
            # Calculating our new positions
            $x += ($width - $width * $py) * 0.5;
            $y += ($height - $height * $px) * 0.5;
            $width = $width * $py;
            $height = $height * $px;
            break;
    }
    # Rotating if we need to rotate
    $tmpimg->image = imagerotate($tmpimg->image, 360 - $rotate, imageColorAllocateAlpha($tmpimg->image, 0, 0, 0, 127));
    # Adding to our main image
    $img->draw($tmpimg->image, $y . ' ' . $x . ' ' . $width . ' ' . $height);
}
# Making sure we have our open directories
$parent_id = 0;
$path = '/';
$dir = explode('/', $_JPOST->dir);
for ($i = 1, $directories = count($dir); $i < $directories; $i++) {
    # Checking to see if our path exists
    $name = $dir[$i];
    $query = "\tSELECT\n\t\t\t\t\t*\n\t\t\t\tFROM \n\t\t\t\t\t" . NQ_DIRECTORY_TABLE . "\n\t\t\t\tWHERE\n\t\t\t\t\t`app_id`\t=" . (int) $G_APP_DATA['id'] . " AND\n\t\t\t\t\t`environment`\t='" . mysqli_escape_string($G_STORAGE_CONTROLLER_DBLINK, $G_APP_ENVIRONMENT) . "' AND\n\t\t\t\t\t`path`\t\t='" . mysqli_escape_string($G_STORAGE_CONTROLLER_DBLINK, $path) . "' AND\n\t\t\t\t\t`name`\t\t='" . mysqli_escape_string($G_STORAGE_CONTROLLER_DBLINK, str_replace(str_split(NQ_INVALID_PATH_CHARS), '', $name)) . "'\n\t\t\t\tLIMIT 1";
    $directory_data = mysqli_single_result_query($G_STORAGE_CONTROLLER_DBLINK, $query);
    # If we aren't allowed we exit
    check_directory_blacklisted($G_CONTROLLER_DBLINK, $G_TOKEN_DATA['id'], $G_TOKEN_SESSION_DATA, $directory_data['path'] . $directory_data['name']);
    # If it doesn't we add it
开发者ID:nuQuery,项目名称:v1m0-api-image,代码行数:31,代码来源:collage.php

示例7: count

$charImageStep = $imageWidth / ($charsNumber + 1);
$charWritePoint = $charImageStep;
// Write captcha characters to the image
for ($i = 0; $i < $charsNumber; $i++) {
    $nextChar = $characters[mt_rand(0, count($characters) - 1)];
    $captchaText .= $nextChar;
    // Font properties
    $randomFontSize = mt_rand(25, 30);
    // Random character size to spice things a little bit :)
    $randomFontAngle = mt_rand(-25, 25);
    // Twist the character a little bit
    $fontType = select_captcha_font();
    // This is the font we are using - we need to point to the ttf file here
    // Pixels
    $pixelX = $charWritePoint;
    // We will write a character at this X point
    $pixelY = 40;
    // We will write a character at this Y point
    // Random character color								  // R			  // G			  // B			  // Alpha
    $randomCharColor = imageColorAllocateAlpha($captchaImage, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 25));
    // Write a character to the image
    imageTtfText($captchaImage, $randomFontSize, $randomFontAngle, $pixelX, $pixelY, $randomCharColor, $fontType, $nextChar);
    // Increase captcha step
    $charWritePoint += $charImageStep;
}
// Add currently generated captcha text to the session
$_SESSION['login_captcha'] = $captchaText;
// Return the image
return imagePng($captchaImage);
// Destroy captcha image
imageDestroy($captchaImage);
开发者ID:Alimir,项目名称:ajax-bootmodal-login,代码行数:31,代码来源:log-captcha.php

示例8: create_images


//.........这里部分代码省略.........
             $max_top = $top;
         }
         $fragments[] = array($w, $width, $height, $left, $top);
     }
     // Create images for each word.
     $count = 1;
     $return = array();
     foreach ($fragments as $f) {
         list($w, $width, $height, $left, $top) = $f;
         $img_width = $width + $padding_left + $padding_right;
         $img_height = $this->image_height ? $this->image_height : $max_height + $padding_top + $padding_bottom;
         $text_left = $left + $padding_left;
         $text_top = $max_top + $padding_top;
         // Adjust image size and text location if there's a shadow.
         if ($this->shadow) {
             if ($this->shadow_offset[0] < 0) {
                 $shadow_space_left = $this->shadow_blur - $this->shadow_offset[0];
                 $shadow_space_right = max(0, $this->shadow_blur + abs($this->shadow_offset[0]));
                 $shadow_left = $text_left + $shadow_space_left;
                 $text_left = $text_left + $shadow_space_left - $this->shadow_offset[0];
             } else {
                 $shadow_space_left = max(0, $this->shadow_blur - $this->shadow_offset[0]);
                 $shadow_space_right = $this->shadow_blur + $this->shadow_offset[0];
                 $shadow_left = $text_left + $shadow_space_left + $this->shadow_offset[0];
                 $text_left = $text_left + $shadow_space_left;
             }
             if ($this->shadow_offset[1] < 0) {
                 $shadow_space_top = $this->shadow_blur - $this->shadow_offset[1];
                 $shadow_space_bottom = max(0, $this->shadow_blur + abs($this->shadow_offset[1]));
                 $shadow_top = $text_top + $shadow_space_top;
                 $text_top = $text_top + $shadow_space_top - $this->shadow_offset[1];
             } else {
                 $shadow_space_top = max(0, $this->shadow_blur - $this->shadow_offset[1]);
                 $shadow_space_bottom = $this->shadow_blur + $this->shadow_offset[1];
                 $shadow_top = $text_top + $shadow_space_top + $this->shadow_offset[1];
                 $text_top = $text_top + $shadow_space_top;
             }
             $img_width += $shadow_space_left + $shadow_space_right;
             $img_height += $shadow_space_top + $shadow_space_bottom;
         }
         // Initialize the image and draw the background.
         $img = imageCreateTrueColor($img_width, $img_height);
         if ($this->background_color === false) {
             imageSaveAlpha($img, true);
             imageAlphaBlending($img, false);
             $img_background_color = imageColorAllocateAlpha($img, 255, 255, 255, 127);
             imageFilledRectangle($img, 0, 0, $img_width, $img_height, $img_background_color);
             imageAlphaBlending($img, true);
         } else {
             $img_background_colors = $this->hex2rgb($this->background_color);
             $img_background_color = imageColorAllocate($img, $img_background_colors[0], $img_background_colors[1], $img_background_colors[2]);
             imageFilledRectangle($img, 0, 0, $img_width, $img_height, $img_background_color);
         }
         // Draw the shadow.
         if ($this->shadow) {
             // Blurred shadow on a transparent background needs special treatment because of GD's limitations.
             if ($this->shadow_blur && $this->background_color === false) {
                 // Create a temporary image for the shadow.
                 $temp = imageCreateTrueColor($img_width, $img_height);
                 imageSaveAlpha($temp, true);
                 imageFilledRectangle($temp, 0, 0, $img_width, $img_height, imageColorAllocate($temp, 127, 127, 127));
                 // Draw the shadow text on the temporary image, and blur it.
                 $temp_text_color = imageColorAllocate($temp, $this->shadow_opacity, $this->shadow_opacity, $this->shadow_opacity);
                 imageTTFText($temp, $font_size, 0, $shadow_left, $shadow_top, $temp_text_color, $font_filename, $w);
                 for ($i = 0; $i < $this->shadow_blur; $i++) {
                     imageFilter($temp, IMG_FILTER_GAUSSIAN_BLUR);
                 }
                 // Use the blurred shadow as an alpha mask on the original image.
                 $shadow_colors = $this->hex2rgb($this->shadow_color);
                 for ($x = 0; $x < $img_width; $x++) {
                     for ($y = 0; $y < $img_height; $y++) {
                         $alpha = imageColorAt($temp, $x, $y) & 0xff;
                         imageSetPixel($img, $x, $y, imageColorAllocateAlpha($img, $shadow_colors[0], $shadow_colors[1], $shadow_colors[2], $alpha));
                     }
                 }
                 imageDestroy($temp);
             } else {
                 $shadow_colors = $this->hex2rgb($this->shadow_color);
                 $shadow_color = imageColorAllocateAlpha($img, $shadow_colors[0], $shadow_colors[1], $shadow_colors[2], $this->shadow_opacity);
                 imageTTFText($img, $font_size, 0, $shadow_left, $shadow_top, $shadow_color, $font_filename, $w);
                 for ($i = 0; $i < $this->shadow_blur; $i++) {
                     imageFilter($img, IMG_FILTER_GAUSSIAN_BLUR);
                 }
             }
         }
         // Draw the word.
         $text_colors = $this->hex2rgb($this->color);
         $text_color = imageColorAllocate($img, $text_colors[0], $text_colors[1], $text_colors[2]);
         imageTTFText($img, $font_size, 0, $text_left, $text_top, $text_color, $font_filename, $w);
         // Save to a PNG file.
         $filename = '/imgtext.' . $hash . '.word-' . str_pad($count, 3, '0', STR_PAD_LEFT) . '.png';
         imagePNG($img, $this->cache_local_dir . $filename);
         imageDestroy($img);
         // Add information about this word to the return array.
         $return[] = array('word' => $w, 'path' => $this->cache_url_prefix . $filename);
         $count++;
     }
     // Returns a list of dictionaries, each containing a word and the corresponding image URL.
     return $return;
 }
开发者ID:kijin,项目名称:imgtext,代码行数:101,代码来源:imgtext.php

示例9: waterMark

 /**
  * 给图片加水印
  * @author		肖飞
  * @param string $sourFile	图片文件名
  * @param string $text		文本数组(包含二个字符串)
  * @return 1 成功 成功时返回生成的图片路径
  */
 function waterMark($sourFile, $text)
 {
     $imageInfo = $this->getInfo($sourFile);
     $sourFile = $this->sourcePath . $sourFile;
     //		$newName = substr($imageInfo["name"], 0, strrpos($imageInfo["name"], ".")) . "_mark.jpg";
     switch ($imageInfo["type"]) {
         case 1:
             //gif
             $img = imagecreatefromgif($sourFile);
             break;
         case 2:
             //jpg
             $img = imagecreatefromjpeg($sourFile);
             break;
         case 3:
             //png
             $img = imagecreatefrompng($sourFile);
             break;
         default:
             return 0;
             break;
     }
     if (!$img) {
         return 0;
     }
     $width = $this->maxWidth > $imageInfo["width"] ? $imageInfo["width"] : $this->maxWidth;
     $height = $this->maxHeight > $imageInfo["height"] ? $imageInfo["height"] : $this->maxHeight;
     $srcW = $imageInfo["width"];
     $srcH = $imageInfo["height"];
     if ($srcW * $width > $srcH * $height) {
         $height = round($srcH * $width / $srcW);
     } else {
         $width = round($srcW * $height / $srcH);
     }
     //*
     if (function_exists("imagecreatetruecolor")) {
         //GD2.0.1
         $new = imagecreatetruecolor($width, $height);
         ImageCopyResampled($new, $img, 0, 0, 0, 0, $width, $height, $imageInfo["width"], $imageInfo["height"]);
     } else {
         $new = imagecreate($width, $height);
         ImageCopyResized($new, $img, 0, 0, 0, 0, $width, $height, $imageInfo["width"], $imageInfo["height"]);
     }
     $white = imageColorAllocate($new, 255, 255, 255);
     $black = imageColorAllocate($new, 0, 0, 0);
     $alpha = imageColorAllocateAlpha($new, 230, 230, 230, 40);
     //$rectW = max(strlen($text[0]),strlen($text[1]))*7;
     ImageFilledRectangle($new, 0, $height - 26, $width, $height, $alpha);
     ImageFilledRectangle($new, 13, $height - 20, 15, $height - 7, $black);
     ImageTTFText($new, 4.9, 0, 20, $height - 14, $black, $this->fontName, $text[0]);
     ImageTTFText($new, 4.9, 0, 20, $height - 6, $black, $this->fontName, $text[1]);
     //*/
     if ($this->toFile) {
         if (file_exists($this->galleryPath . $newName)) {
             unlink($this->galleryPath . $newName);
         }
         ImageJPEG($new, $this->galleryPath . $newName);
         return $this->galleryPath . $newName;
     } else {
         ImageJPEG($new);
     }
     ImageDestroy($new);
     ImageDestroy($img);
 }
开发者ID:TiMoChao,项目名称:lc_ad_first,代码行数:71,代码来源:gdimage.class.php

示例10: recover_image

 public function recover_image($id, $thumb_width, $thumb_height)
 {
     global $WD_BWG_UPLOAD_DIR;
     global $wpdb;
     $image_data = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'bwg_image WHERE id="%d"', $id));
     $filename = htmlspecialchars_decode(ABSPATH . $WD_BWG_UPLOAD_DIR . $image_data->image_url, ENT_COMPAT | ENT_QUOTES);
     $thumb_filename = htmlspecialchars_decode(ABSPATH . $WD_BWG_UPLOAD_DIR . $image_data->thumb_url, ENT_COMPAT | ENT_QUOTES);
     if (file_exists($filename) && file_exists($thumb_filename)) {
         copy(str_replace('/thumb/', '/.original/', $thumb_filename), $filename);
         list($width_orig, $height_orig, $type_orig) = getimagesize($filename);
         $percent = $width_orig / $thumb_width;
         $thumb_height = $height_orig / $percent;
         @ini_set('memory_limit', '-1');
         if ($type_orig == 2) {
             $img_r = imagecreatefromjpeg($filename);
             $dst_r = ImageCreateTrueColor($thumb_width, $thumb_height);
             imagecopyresampled($dst_r, $img_r, 0, 0, 0, 0, $thumb_width, $thumb_height, $width_orig, $height_orig);
             imagejpeg($dst_r, $thumb_filename, 100);
             imagedestroy($img_r);
             imagedestroy($dst_r);
         } elseif ($type_orig == 3) {
             $img_r = imagecreatefrompng($filename);
             $dst_r = ImageCreateTrueColor($thumb_width, $thumb_height);
             imageColorAllocateAlpha($dst_r, 0, 0, 0, 127);
             imagealphablending($dst_r, FALSE);
             imagesavealpha($dst_r, TRUE);
             imagecopyresampled($dst_r, $img_r, 0, 0, 0, 0, $thumb_width, $thumb_height, $width_orig, $height_orig);
             imagealphablending($dst_r, FALSE);
             imagesavealpha($dst_r, TRUE);
             imagepng($dst_r, $thumb_filename, 9);
             imagedestroy($img_r);
             imagedestroy($dst_r);
         } elseif ($type_orig == 1) {
             $img_r = imagecreatefromgif($filename);
             $dst_r = ImageCreateTrueColor($thumb_width, $thumb_height);
             imageColorAllocateAlpha($dst_r, 0, 0, 0, 127);
             imagealphablending($dst_r, FALSE);
             imagesavealpha($dst_r, TRUE);
             imagecopyresampled($dst_r, $img_r, 0, 0, 0, 0, $thumb_width, $thumb_height, $width_orig, $height_orig);
             imagealphablending($dst_r, FALSE);
             imagesavealpha($dst_r, TRUE);
             imagegif($dst_r, $thumb_filename);
             imagedestroy($img_r);
             imagedestroy($dst_r);
         }
         @ini_restore('memory_limit');
     }
 }
开发者ID:benshez,项目名称:DreamWeddingCeremonies,代码行数:48,代码来源:BWGControllerOptions_bwg.php

示例11: viewmergeimage

 public function viewmergeimage()
 {
     $gotimages = $this->input->get_post("json");
     // Get images from database
     $gotimages = json_decode($gotimages, TRUE);
     $frontfeatures = array();
     $backfeatures = array();
     //frontend img specifications
     $frontfeatures = $gotimages['custom']['4'];
     $backfeatures = $gotimages['custom']['5'];
     $newImagewidth = $frontfeatures['width'] * 5;
     $newImageheight = $frontfeatures['height'] * 5;
     $demofronttransparent = imagecreatetruecolor($newImagewidth, $newImageheight);
     imagesavealpha($demofronttransparent, true);
     $color = imagecolorallocatealpha($demofronttransparent, 0, 0, 0, 127);
     imagefill($demofronttransparent, 0, 0, $color);
     $phpfrontimg = imagecreatefrompng("./uploads/" . $gotimages['image']['image']);
     imagecopyresized($demofronttransparent, $phpfrontimg, 0, 0, 0, 0, $newImagewidth, $newImageheight, imagesx($phpfrontimg), imagesy($phpfrontimg));
     //             ROTATE IMAGE
     $rotate = imagerotate($demofronttransparent, 180, imageColorAllocateAlpha($demofronttransparent, 0, 0, 0, 127));
     imagesavealpha($rotate, true);
     //                create transparent layout
     $thumbfront = imagecreatetruecolor(194 * 5, 308 * 5);
     imagesavealpha($thumbfront, true);
     $color = imagecolorallocatealpha($thumbfront, 0, 0, 0, 127);
     imagefill($thumbfront, 0, 0, $color);
     //             MERGE IMAGE
     imagecopyresized($thumbfront, $rotate, 10, 10, 0, 0, imagesx($rotate), imagesy($rotate), imagesx($rotate), imagesy($rotate));
     imagesavealpha($thumbfront, true);
     header('Content-Type: image/png');
     imagepng($thumbfront);
 }
开发者ID:WohligTechnology,项目名称:newfynx,代码行数:32,代码来源:json.php

示例12: callCreateAlphaImageForDistorted

 function callCreateAlphaImageForDistorted()
 {
     // Example usage - gif image output
     $alphabet = $this->symbolsToUse;
     $alphabet = implode(" ", str_split($alphabet));
     $text_string = $alphabet;
     $font_ttf = $this->font_ttf;
     $text_angle = 0;
     $text_padding = 20;
     // Img padding - around text
     $font_size = $this->font_size;
     $fontFileMeta = array('alphabet' => $alphabet, 'font_ttf' => basename($font_ttf), 'font_size' => $font_size);
     $fontMetaFile = $this->fontPNGLocation . $this->DS . $this->fontMetaFile;
     if (!file_exists($fontMetaFile)) {
         die("missing meta file : " . $fontMetaFile);
     }
     $savedfontMeta = unserialize(file_get_contents($fontMetaFile));
     if (!is_array($savedfontMeta) || !isset($savedfontMeta['alphabet']) || !isset($savedfontMeta['font_ttf']) || !isset($savedfontMeta['font_size'])) {
         die("corrupted meta file : " . $fontMetaFile . " download the correct one ");
     }
     //die("Saved one <pre>".print_r(unserialize( file_get_contents($fontMetaFile)),true)."</pre><hr />Required one <pre>".print_r($fontFileMeta,true)."</pre>");
     if ($savedfontMeta == $fontFileMeta) {
         return;
     } elseif (!(file_exists($font_ttf) || is_dir($font_ttf))) {
         $alphabet = $this->symbolsToUse = $savedfontMeta['alphabet'];
         $font_ttf = $this->font_ttf = $savedfontMeta['font_ttf'];
         $font_size = $this->font_size = $savedfontMeta['font_size'];
     }
     file_put_contents($fontMetaFile, serialize($fontFileMeta));
     $the_box = $this->calculateTextBox($text_string, $font_ttf, $font_size, $text_angle);
     $imgWidth = $the_box["width"] + $text_padding * 2;
     $imgHeight = $the_box["height"] + $text_padding * 2;
     $img = $image = imagecreatetruecolor($imgWidth, $imgHeight);
     $colorBlack = imagecolorallocate($image, 0, 0, 0);
     imagealphablending($image, false);
     imagesavealpha($image, true);
     $transparent = imageColorAllocateAlpha($img, 0, 0, 0, 127);
     imagefilledrectangle($image, 0, 0, $imgWidth - 1, $imgHeight - 1, $transparent);
     imageAlphaBlending($image, true);
     imageantialias($image, true);
     imagettftext($image, $font_size, $text_angle, $the_box["left"] + $imgWidth / 2 - $the_box["width"] / 2, $the_box["top"] + $imgHeight / 2 - $the_box["height"] / 2, $colorBlack, $font_ttf, $text_string);
     imagealphablending($image, false);
     imagesavealpha($image, true);
     //header("content-type: image/png");imagepng($image);imagepng($image,'test.png');imagedestroy($image); exit;
     $font_file = $this->fontPNGLocation . $this->DS . $this->fontPNGFile;
     imagepng($image, $font_file);
     $image = $this->createAlphaImage();
     imagepng($image, $font_file);
 }
开发者ID:vinayshuklasourcefuse,项目名称:sareez,代码行数:49,代码来源:OutsourceOnline_Captcha_Helper_OSOLmulticaptcha.php

示例13: set_text_watermark

 function set_text_watermark($original_filename, $dest_filename, $watermark_text, $watermark_font, $watermark_font_size, $watermark_color, $watermark_transparency, $watermark_position)
 {
     $original_filename = htmlspecialchars_decode($original_filename, ENT_COMPAT | ENT_QUOTES);
     $dest_filename = htmlspecialchars_decode($dest_filename, ENT_COMPAT | ENT_QUOTES);
     $watermark_transparency = 127 - (100 - $watermark_transparency) * 1.27;
     list($width, $height, $type) = getimagesize($original_filename);
     $watermark_image = imagecreatetruecolor($width, $height);
     $watermark_color = $this->bwg_hex2rgb($watermark_color);
     $watermark_color = imagecolorallocatealpha($watermark_image, $watermark_color[0], $watermark_color[1], $watermark_color[2], $watermark_transparency);
     $watermark_font = WD_S_DIR . '/fonts/' . $watermark_font;
     $watermark_font_size = $height * $watermark_font_size / 500;
     $watermark_position = explode('-', $watermark_position);
     $watermark_sizes = $this->bwg_imagettfbboxdimensions($watermark_font_size, 0, $watermark_font, $watermark_text);
     $top = $height - 5;
     $left = $width - $watermark_sizes['width'] - 5;
     switch ($watermark_position[0]) {
         case 'top':
             $top = $watermark_sizes['height'] + 5;
             break;
         case 'middle':
             $top = ($height + $watermark_sizes['height']) / 2;
             break;
     }
     switch ($watermark_position[1]) {
         case 'left':
             $left = 5;
             break;
         case 'center':
             $left = ($width - $watermark_sizes['width']) / 2;
             break;
     }
     ini_set('memory_limit', '-1');
     if ($type == 2) {
         $image = imagecreatefromjpeg($original_filename);
         imagettftext($image, $watermark_font_size, 0, $left, $top, $watermark_color, $watermark_font, $watermark_text);
         imagejpeg($image, $dest_filename, 100);
         imagedestroy($image);
     } elseif ($type == 3) {
         $image = imagecreatefrompng($original_filename);
         imagettftext($image, $watermark_font_size, 0, $left, $top, $watermark_color, $watermark_font, $watermark_text);
         imageColorAllocateAlpha($image, 0, 0, 0, 127);
         imagealphablending($image, FALSE);
         imagesavealpha($image, TRUE);
         imagepng($image, $dest_filename, 9);
         imagedestroy($image);
     } elseif ($type == 1) {
         $image = imagecreatefromgif($original_filename);
         imageColorAllocateAlpha($watermark_image, 0, 0, 0, 127);
         imagecopy($watermark_image, $image, 0, 0, 0, 0, $width, $height);
         imagettftext($watermark_image, $watermark_font_size, 0, $left, $top, $watermark_color, $watermark_font, $watermark_text);
         imagealphablending($watermark_image, FALSE);
         imagesavealpha($watermark_image, TRUE);
         imagegif($watermark_image, $dest_filename);
         imagedestroy($image);
     }
     imagedestroy($watermark_image);
     ini_restore('memory_limit');
 }
开发者ID:shieldsdesignstudio,项目名称:trilogic,代码行数:58,代码来源:WDSControllerSliders_wds.php

示例14: rotate

 /**
  * @param $angle
  * @return $this|self
  */
 public function rotate($angle)
 {
     $this->preModify();
     $angle = 360 - $angle;
     $this->resource = imagerotate($this->resource, $angle, imageColorAllocateAlpha($this->resource, 0, 0, 0, 127));
     $this->setWidth(imagesx($this->resource));
     $this->setHeight(imagesy($this->resource));
     $this->postModify();
     $this->setIsAlphaPossible(true);
     return $this;
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:15,代码来源:GD.php

示例15: imageCreateTrueColor

<?php

$im = imageCreateTrueColor(110, 30);
$color = imageColorAllocate($im, 255, 198, 0);
imageAntiAlias($im, true);
imageFill($im, 10, 10, $color);
//добавлеяем фоновые точки на картинке
$color = imageColorAllocateAlpha($im, 116, 187, 15, 50);
for ($i = 0; $i < 800; $i++) {
    $randW = mt_rand(0, imageSX($im));
    $randH = mt_rand(0, imageSY($im));
    imageSetPixel($im, $randW, $randH, $color);
}
//создаем массив значений букв и цыфр для капчи
$color = imageColorAllocate($im, 255, 255, 255);
$letters = array_merge(range('A', 'Z'), range(0, 9));
//составляем и удаляем лишние символы, которые приводят к путанице
$delLetters = ['O', 'I', 'J', 7, '0', 'Q', '5', 'S'];
for ($i = 0; $i < count($delLetters); $i++) {
    unset($letters[array_search($delLetters[$i], $letters)]);
}
//перемешиваем массив и выбираем срез
shuffle($letters);
$sliceLetters = array_slice($letters, 0, 5);
//устанавливаем настройки для отображения символов и выводим текст
$deg = [10, -10, 15, 0, -20];
$rands = [mt_rand(0, 7), mt_rand(0, 9), mt_rand(8, 15), mt_rand(0, 9), mt_rand(16, 23)];
$opts = [mt_rand(2, 8), mt_rand(22, 26), mt_rand(46, 50), mt_rand(70, 72), mt_rand(86, 88)];
for ($i = 0; $i < count($sliceLetters); $i++) {
    $letter = $sliceLetters[$i];
    $str .= $letter;
开发者ID:echmaster,项目名称:bit,代码行数:31,代码来源:captcha.php


注:本文中的imageColorAllocateAlpha函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。