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


PHP html2rgb函数代码示例

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


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

示例1: apply

 public function apply($resource)
 {
     // Extract arguments
     @(list(, $x1, $y1, $x2, $y2, $thickness, $color) = func_get_args());
     $x1 = (int) $x1;
     $y1 = (int) $y1;
     $x2 = (int) $x2;
     $y2 = (int) $y2;
     $thickness = (int) $thickness;
     if (!$color) {
         $color = '#000000';
     }
     $rgb = html2rgb($color);
     if ($thickness < 1) {
         $thickness = 1;
     }
     // Draw line
     if (!imagesetthickness($resource, $thickness)) {
         throw new Exception("Thickness line changing failed");
     }
     if (!imageline($resource, $x1, $y1, $x2, $y2, imagecolorallocate($resource, $rgb[0], $rgb[1], $rgb[2]))) {
         throw new Exception("Line drawing failed");
     }
     return $resource;
 }
开发者ID:pyrsmk,项目名称:imagix,代码行数:25,代码来源:Line.php

示例2: apply

 public function apply($resource)
 {
     // Verify support
     if (!function_exists('imagerotate')) {
         throw new Exception("It seems your PHP version is not compiled with the bundled version of the GD library");
     }
     // Get arguments
     @(list(, $angle, $color) = func_get_args());
     $angle = (double) $angle;
     if (!$color) {
         $color = '#FFFFFF';
     }
     $rgb = html2rgb($color);
     // Apply effect
     $resource = imagerotate($resource, $angle, imagecolorallocate($resource, $rgb[0], $rgb[1], $rgb[2]));
     if (!$resource) {
         throw new Exception("Image rotation failed");
     }
     return $resource;
 }
开发者ID:pyrsmk,项目名称:imagix,代码行数:20,代码来源:Rotate.php

示例3: apply

 public function apply($resource)
 {
     // Verify support
     if (!function_exists('imagefilter')) {
         throw new Exception("It seems your PHP version is not compiled with the bundled version of the GD library");
     }
     // Extract arguments
     @(list(, $color, $opacity) = func_get_args());
     $rgb = html2rgb($color);
     // Normalize
     if ($opacity === null) {
         $opacity = 100;
     } elseif ($opacity < 0) {
         $opacity = 0;
     } elseif ($opacity > 100) {
         $opacity = 100;
     }
     $a = (100 - $opacity) * 1.27;
     // Apply effect
     if (!imagefilter($resource, IMG_FILTER_COLORIZE, $rgb[0], $rgb[1], $rgb[2], $a)) {
         throw new Exception("COLORIZE filter failed");
     }
     return $resource;
 }
开发者ID:pyrsmk,项目名称:imagix,代码行数:24,代码来源:Addition.php

示例4: hexdec

    }
    $r = hexdec($r);
    $g = hexdec($g);
    $b = hexdec($b);
    return array($r, $g, $b);
}
function rgb2html($r, $g = -1, $b = -1)
{
    if (is_array($r) && sizeof($r) == 3) {
        list($r, $g, $b) = $r;
    }
    $r = intval($r);
    $g = intval($g);
    $b = intval($b);
    $r = dechex($r < 0 ? 0 : ($r > 255 ? 255 : $r));
    $g = dechex($g < 0 ? 0 : ($g > 255 ? 255 : $g));
    $b = dechex($b < 0 ? 0 : ($b > 255 ? 255 : $b));
    $color = (strlen($r) < 2 ? '0' : '') . $r;
    $color .= (strlen($g) < 2 ? '0' : '') . $g;
    $color .= (strlen($b) < 2 ? '0' : '') . $b;
    return '<div style="background:#' . $color . ';"><a href="#">#' . $color . '</a></div>';
}
$a = html2rgb('ffffe0');
$b = html2rgb('ff9480');
$size = 9;
echo '<link rel="stylesheet" href="css/style.css" />';
echo '<div class="contenttable">';
for ($i = 0; $i <= 100; $i += 100 / ($size - 1)) {
    echo rgb2html(array($a[0] + ($b[0] - $a[0]) * $i / 100, $a[1] + ($b[1] - $a[1]) * $i / 100, $a[2] + ($b[2] - $a[2]) * $i / 100)) . "\n";
}
echo '</div>';
开发者ID:pombredanne,项目名称:tuleap,代码行数:31,代码来源:gradient_generator.php

示例5: header

    if (preg_match("/[^A-Za-z0-9_-]/", $hex)) {
        header("location: error.php?eType=invalidQuery");
        exit;
    }
    //unset($_SESSION['searchForm']['resultsArray']); // Clear any previous results array
    $_SESSION['searchForm']['hex'] = $hex;
    if ($_REQUEST['red']) {
        if (preg_match("/[^A-Za-z0-9_-]/", $red) or preg_match("/[^A-Za-z0-9_-]/", $green) or preg_match("/[^A-Za-z0-9_-]/", $blue)) {
            header("location: error.php?eType=invalidQuery");
            exit;
        }
        $_SESSION['searchForm']['red'] = $red;
        $_SESSION['searchForm']['green'] = $green;
        $_SESSION['searchForm']['blue'] = $blue;
    } else {
        $rgbColor = html2rgb($hex);
        // Convert hex to rgb
        $_SESSION['searchForm']['red'] = $rgbColor['red'];
        $_SESSION['searchForm']['green'] = $rgbColor['green'];
        $_SESSION['searchForm']['blue'] = $rgbColor['blue'];
    }
    $_SESSION['searchForm']['inSearch'] = true;
}
// Orientation search passed
if ($_REQUEST['orientations']) {
    //unset($_SESSION['searchForm']['resultsArray']); // Clear any previous results array
    unset($_SESSION['searchForm']['orientations']);
    // Clear ori first
    foreach ($_REQUEST['orientations'] as $key => $value) {
        $_SESSION['searchForm']['orientations'][$key] = $value;
    }
开发者ID:spencerlambert,项目名称:willie-php,代码行数:31,代码来源:search.448.php

示例6: generateSoundWave

function generateSoundWave($input, $output, $width, $height, $foreground, $background)
{
    /**
     * PROCESS THE FILE
     */
    // temporary file name
    $tmpname = substr(md5(time()), 0, 10);
    $draw_flat = false;
    // copy from temp upload directory to current
    copy($input, "{$tmpname}_o.mp3");
    // array of wavs that need to be processed
    $wavs_to_process = array();
    /**
     * convert mp3 to wav using lame decoder
     * First, resample the original mp3 using as mono (-m m), 16 bit (-b 16), and 8 KHz (--resample 8)
     * Secondly, convert that resampled mp3 into a wav
     * We don't necessarily need high quality audio to produce a waveform, doing this process reduces the WAV
     * to it's simplest form and makes processing significantly faster
     */
    exec("lame {$tmpname}_o.mp3 -m m -S -f -b 16 --resample 8 {$tmpname}.mp3 && lame -S --decode {$tmpname}.mp3 {$tmpname}.wav");
    $wavs_to_process[] = "{$tmpname}.wav";
    // delete temporary files
    unlink("{$tmpname}_o.mp3");
    unlink("{$tmpname}.mp3");
    $img = false;
    // generate foreground color
    list($r, $g, $b) = html2rgb($foreground);
    // process each wav individually
    for ($wav = 1; $wav <= sizeof($wavs_to_process); $wav++) {
        $filename = $wavs_to_process[$wav - 1];
        /**
         * Below as posted by "zvoneM" on
         * http://forums.devshed.com/php-development-5/reading-16-bit-wav-file-318740.html
         * as findValues() defined above
         * Translated from Croation to English - July 11, 2011
         */
        $handle = fopen($filename, "r");
        // wav file header retrieval
        $heading[] = fread($handle, 4);
        $heading[] = bin2hex(fread($handle, 4));
        $heading[] = fread($handle, 4);
        $heading[] = fread($handle, 4);
        $heading[] = bin2hex(fread($handle, 4));
        $heading[] = bin2hex(fread($handle, 2));
        $heading[] = bin2hex(fread($handle, 2));
        $heading[] = bin2hex(fread($handle, 4));
        $heading[] = bin2hex(fread($handle, 4));
        $heading[] = bin2hex(fread($handle, 2));
        $heading[] = bin2hex(fread($handle, 2));
        $heading[] = fread($handle, 4);
        $heading[] = bin2hex(fread($handle, 4));
        // wav bitrate
        $peek = hexdec(substr($heading[10], 0, 2));
        $byte = $peek / 8;
        // checking whether a mono or stereo wav
        $channel = hexdec(substr($heading[6], 0, 2));
        $ratio = $channel == 2 ? 40 : 80;
        // start putting together the initial canvas
        // $data_size = (size_of_file - header_bytes_read) / skipped_bytes + 1
        $data_size = floor((filesize($filename) - 44) / ($ratio + $byte) + 1);
        $data_point = 0;
        // now that we have the data_size for a single channel (they both will be the same)
        // we can initialize our image canvas
        if (!$img) {
            // create original image width based on amount of detail
            // each waveform to be processed with be $height high, but will be condensed
            // and resized later (if specified)
            $img = imagecreatetruecolor($data_size / DETAIL, $height * sizeof($wavs_to_process));
            // fill background of image
            if ($background == "") {
                // transparent background specified
                imagesavealpha($img, true);
                $transparentColor = imagecolorallocatealpha($img, 0, 0, 0, 127);
                imagefill($img, 0, 0, $transparentColor);
            } else {
                list($br, $bg, $bb) = html2rgb($background);
                imagefilledrectangle($img, 0, 0, (int) ($data_size / DETAIL), $height * sizeof($wavs_to_process), imagecolorallocate($img, $br, $bg, $bb));
            }
        }
        while (!feof($handle) && $data_point < $data_size) {
            if ($data_point++ % DETAIL == 0) {
                $bytes = array();
                // get number of bytes depending on bitrate
                for ($i = 0; $i < $byte; $i++) {
                    $bytes[$i] = fgetc($handle);
                }
                switch ($byte) {
                    // get value for 8-bit wav
                    case 1:
                        $data = findValues($bytes[0], $bytes[1]);
                        break;
                        // get value for 16-bit wav
                    // get value for 16-bit wav
                    case 2:
                        if (ord($bytes[1]) & 128) {
                            $temp = 0;
                        } else {
                            $temp = 128;
                        }
                        $temp = chr((ord($bytes[1]) & 127) + $temp);
//.........这里部分代码省略.........
开发者ID:pezzabros,项目名称:Loki,代码行数:101,代码来源:waveform-png.php

示例7: pch_slicebar_graph

function pch_slicebar_graph($graph_type, $data, $period, $width, $height, $colors, $font, $round_corner, $font_size, $antialiasing = true)
{
    /* CAT:Slicebar charts */
    set_time_limit(0);
    // Dataset definition
    $myPicture = new pImage($width, $height);
    /* Turn of Antialiasing */
    $myPicture->Antialias = $antialiasing;
    $myPicture->setFontProperties(array("FontName" => $font, "FontSize" => $font_size, "R" => 80, "G" => 80, "B" => 80));
    // Round corners defined in global setup
    if ($round_corner != 0) {
        $radius = $height > 18 ? 8 : 0;
    } else {
        $radius = 0;
    }
    $thinest_slice = $width / $period;
    /* Color stuff */
    $colorsrgb = array();
    foreach ($colors as $key => $col) {
        $rgb = html2rgb($col);
        $colorsrgb[$key]['R'] = $rgb[0];
        $colorsrgb[$key]['G'] = $rgb[1];
        $colorsrgb[$key]['B'] = $rgb[2];
    }
    $i = 0;
    foreach ($data as $d) {
        $color = $d['data'];
        $color = $colorsrgb[$color];
        $ratio = $thinest_slice * $d['utimestamp'];
        $myPicture->drawRoundedFilledRectangle($i, 0, $ratio + $i, $height, $radius, array('R' => $color['R'], 'G' => $color['G'], 'B' => $color['B']));
        $i += $ratio;
    }
    if ($round_corner) {
        /* Under this value, the rounded rectangle is painted great */
        if ($thinest_slice <= 16) {
            /* Clean a bit of pixels */
            for ($i = 0; $i < 7; $i++) {
                $myPicture->drawLine(0, $i, 6 - $i, $i, array('R' => 255, 'G' => 255, 'B' => 255));
            }
            $end = $height - 1;
            for ($i = 0; $i < 7; $i++) {
                $myPicture->drawLine(0, $end - $i, 5 - $i, $end - $i, array('R' => 255, 'G' => 255, 'B' => 255));
            }
        }
    }
    $myPicture->drawRoundedRectangle(0, 0, $width, $height - 1, $radius, array('R' => 157, 'G' => 157, 'B' => 157));
    $myPicture->Stroke();
}
开发者ID:articaST,项目名称:integriaims,代码行数:48,代码来源:functions_pchart.php

示例8: RenderFrames

/**
* Render the actual video frames
* 
* @param mixed $tests
* @param mixed $frameCount
* @param mixed $im
*/
function RenderFrames(&$tests, $frameCount, $im)
{
    global $width, $height, $backgroundColor, $videoPath, $image_bytes, $textColor, $encodeFormat, $encoderSpeed, $fps, $labelHeight, $forceBackgroundColor, $forceTextColor, $combineTimeLabel, $evenTextBackground, $oddTextBackground, $bgEvenText, $bgOddText;
    // allocate the background and foreground colors
    $bgcolor = isset($tests[0]['bg']) ? html2rgb($tests[0]['bg']) : html2rgb('000000');
    $color = isset($tests[0]['text']) ? html2rgb($tests[0]['text']) : html2rgb('ffffff');
    if (isset($forceBackgroundColor)) {
        $bgcolor = html2rgb($forceBackgroundColor);
    }
    if (isset($forceTextColor)) {
        $color = html2rgb($forceTextColor);
    }
    $bgEvenTextColor = isset($evenTextBackground) ? html2rgb($evenTextBackground) : $bgcolor;
    $bgOddTextColor = isset($oddTextBackground) ? html2rgb($oddTextBackground) : $bgcolor;
    // prepare the image
    $backgroundColor = imagecolorallocate($im, $bgcolor[0], $bgcolor[1], $bgcolor[2]);
    $textColor = imagecolorallocate($im, $color[0], $color[1], $color[2]);
    $bgEvenText = imagecolorallocate($im, $bgEvenTextColor[0], $bgEvenTextColor[1], $bgEvenTextColor[2]);
    $bgOddText = imagecolorallocate($im, $bgOddTextColor[0], $bgOddTextColor[1], $bgOddTextColor[2]);
    imagefilledrectangle($im, 0, 0, $width - 1, $height - 1, $backgroundColor);
    // figure out what a good interval for keyframes would be based on the video length
    $keyInt = min(max(6, $frameCount / 30), 240);
    // set up ffmpeg
    $descriptors = array(0 => array("pipe", "r"));
    $videoFile = realpath($videoPath) . '/render.mp4';
    if (is_file($videoFile)) {
        unlink($videoFile);
    }
    $codec = $encodeFormat == 'jpg' ? 'mjpeg' : $encodeFormat;
    $command = "ffmpeg -f image2pipe -vcodec {$codec} -r {$fps} -i - " . "-vcodec libx264 -r {$fps} -crf 24 -g {$keyInt} " . "-preset {$encoderSpeed} -y \"{$videoFile}\"";
    $ffmpeg = proc_open($command, $descriptors, $pipes);
    if (is_resource($ffmpeg)) {
        if ($labelHeight > 0 || $combineTimeLabel) {
            DrawLabels($tests, $im);
        }
        for ($frame = 0; $frame < $frameCount; $frame++) {
            RenderFrame($tests, $frame, $im);
            if (isset($image_bytes)) {
                fwrite($pipes[0], $image_bytes);
            }
        }
        fclose($pipes[0]);
        proc_close($ffmpeg);
    }
}
开发者ID:renajohn,项目名称:webpagetest,代码行数:52,代码来源:render.php

示例9: makeHistogram

function makeHistogram($filepath, $filename, $pid)
{
    // set_time_limit(500);
    //HISTOGRAM VARIABLES
    global $CONFIG;
    $coppermineid = $pid;
    $source_file = $filepath . $filename;
    switch ($CONFIG['plugin_flf_histotag_imagesource']) {
        case '2':
            if (file_exists($filepath . $CONFIG['normal_pfx'] . $filename)) {
                // Intermediate file exists
                // use this one for faster calculations
                $source_file = $filepath . $CONFIG['normal_pfx'] . $filename;
            }
            break;
        case '3':
            if (file_exists($filepath . $CONFIG['thumb_pfx'] . $filename)) {
                // Thumbnail file exists
                // use this one for fastest calculations
                $source_file = $filepath . $CONFIG['thumb_pfx'] . $filename;
            }
            break;
        default:
            // Do nothing --> regular filename already used
            // Same as option '1'
            break;
    }
    $maxheight = 100;
    $barwidth = 1;
    $iscolor = false;
    $im = ImageCreateFromJpeg($source_file);
    $color = $CONFIG['plugin_flf_histotag_histocolor'];
    $imgw = imagesx($im);
    $imgh = imagesy($im);
    $n = $imgw * $imgh;
    $histo = array();
    $histoR = array();
    $histoG = array();
    $histoB = array();
    // ZERO HISTOGRAM VALUES
    for ($i = 0; $i < 256; $i++) {
        $histo[$i] = 0;
        $histoR[$i] = 0;
        $histoG[$i] = 0;
        $histoB[$i] = 0;
    }
    // CALCULATE PIXELS
    for ($i = 0; $i < $imgw; $i++) {
        for ($j = 0; $j < $imgh; $j++) {
            $rgb = ImageColorAt($im, $i, $j);
            $r = $rgb >> 16 & 0xff;
            $g = $rgb >> 8 & 0xff;
            $b = $rgb & 0xff;
            $V = round(($r + $g + $b) / 3);
            $histo[$V] += 1;
            $V = round($r * 1);
            $histoR[$V] += 1;
            $V = round($g * 1);
            $histoG[$V] += 1;
            $V = round($b * 1);
            $histoB[$V] += 1;
        }
    }
    imagedestroy($im);
    // COLOR OR GRAYSCALE
    for ($a = 0; $a < count($histoR); $a++) {
        if ($histoR[$a] != $histoG[$a] || $histoG[$a] != $histoB[$a]) {
            $iscolor = true;
            break;
        }
    }
    //CREATE HISTOGRAM IMAGE
    // TODO: internationalize!
    if ($CONFIG['plugin_flf_histotag_histotype'] == '1' or $iscolor == false) {
        $imR = imagecreatetruecolor(256, 100) or die("Cannot Initialize new GD image stream");
    } else {
        $imR = imagecreatetruecolor(256, 300) or die("Cannot Initialize new GD image stream");
    }
    // CONVERT BACKGROUND COLOR TO RGB
    $rgbcolor = html2rgb($color);
    //RGB
    if ($iscolor) {
        // MAKE BACKGROUND
        $back = imagecolorallocate($imR, $rgbcolor[0], $rgbcolor[1], $rgbcolor[2]);
        //$back = imagecolorallocate($imR, 37, 37, 37);
        // compute bounds of vertical axis
        // sort the histograms to find tallest bins
        $sHistoR = $histoR;
        $sHistoG = $histoG;
        $sHistoB = $histoB;
        sort($sHistoR);
        sort($sHistoG);
        sort($sHistoB);
        // we allow clipping of at most the 5 tallest histogram bins, but clipping
        // also needs to be useful. i.e. if clipping does not change the vertical
        // range much, then don't do it. The following heuristic code enforces this.
        $lerpR = min(max(($sHistoR[255] / $sHistoR[250] - 1.15) / 2.0, 0.0), 1.0);
        $lerpG = min(max(($sHistoG[255] / $sHistoG[250] - 1.15) / 2.0, 0.0), 1.0);
        $lerpB = min(max(($sHistoB[255] / $sHistoB[250] - 1.15) / 2.0, 0.0), 1.0);
        $histoClipR = (1.0 - $lerpR) * $sHistoR[255] + $lerpR * $sHistoR[250];
//.........这里部分代码省略.........
开发者ID:phill104,项目名称:branches,代码行数:101,代码来源:histotag_histogram_support.php

示例10: WA_DFP_ResizeImage


//.........这里部分代码省略.........
            // Fit height: image resize down to $maxHeight and width modified to keep the aspect ratio
            if ($height > $maxHeight) {
                // need to resize down
                $newHeight = $maxHeight;
                $newWidth = round($newHeight * $aspect_ratio);
                $tmp = imagecreatetruecolor($newWidth, $maxHeight);
                $src = resetTransparency($src, $options);
                $tmp = WA_DFP_RetainTransparent($src, $tmp, $imageInfo);
                $tmp = resetTransparency($tmp, $options);
                imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newWidth, $maxHeight, $width, $height);
            } else {
                $tmp = imagecreatetruecolor($width, $height);
                $src = resetTransparency($src, $options);
                $tmp = WA_DFP_RetainTransparent($src, $tmp, $imageInfo);
                $tmp = resetTransparency($tmp, $options);
                imagecopyresampled($tmp, $src, 0, 0, 0, 0, $width, $height, $width, $height);
            }
            break;
        case WADFP_FIXED_SIZE:
            // Fixed width and height: image resize to exact width and height and filled with fill color
            $newWidth = $width;
            $newHeight = $height;
            if ($maxWidth / $maxHeight > $aspect_ratio) {
                $newWidth = round($maxHeight * $aspect_ratio);
                $newHeight = $maxHeight;
            } else {
                $newWidth = $maxWidth;
                $newHeight = round($maxWidth / $aspect_ratio);
            }
            $tmp = imagecreatetruecolor($maxWidth, $maxHeight);
            if ($fillColor == '') {
                $fillColor = '#FFFFFF';
            }
            $fillColors = html2rgb($fillColor);
            $allocatedColor = imagecolorallocate($tmp, $fillColors[0], $fillColors[1], $fillColors[2]);
            imagefilledrectangle($tmp, 0, 0, $maxWidth, $maxHeight, $allocatedColor);
            $src = resetTransparency($src, $options);
            $tmp = WA_DFP_RetainTransparent($src, $tmp, $imageInfo);
            $tmp = resetTransparency($tmp, $options);
            imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
            $newWidth = $maxWidth;
            $newHeight = $maxHeight;
            break;
        default:
            $tmp = $src;
            $tmpIsSrc = true;
            break;
    }
    $path_parts = pathinfo($imageFilePath);
    $extension = isset($path_parts["extension"]) ? $path_parts["extension"] : '';
    $startExtension = strtolower($extension);
    $endExtension = $startExtension;
    // Adding new extension to end in case there isn't a file extension isn't present in file path
    $fileExtensionRegExp = '/' . $path_parts["basename"] . '$/';
    if ($options['imageFormat'] && $options['imageFormat'] !== '') {
        // convert to a specific format
        $imageOptions = explode(':', $options['imageFormat']);
        switch ($imageOptions[0]) {
            case WADFP_PNG:
                if ($startExtension != 'png') {
                    $newFilePath = preg_replace($fileExtensionRegExp, $uniqueFileNamePart, $imageFilePath) . '.png';
                } else {
                    $newFilePath = $imageFilePath;
                }
                $endExtension = 'png';
                $imageQuality = intval($imageOptions[1]);
开发者ID:esquarenews,项目名称:MortgageBlog,代码行数:67,代码来源:helperphp.php

示例11: substr

    if ($color[0] == '#') {
        $color = substr($color, 1);
    }
    if (strlen($color) == 6) {
        list($r, $g, $b) = array($color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5]);
    } elseif (strlen($color) == 3) {
        list($r, $g, $b) = array($color[0], $color[1], $color[2]);
    } else {
        return false;
    }
    $r = hexdec($r);
    $g = hexdec($g);
    $b = hexdec($b);
    return array($r, $g, $b);
}
$rgb = html2rgb($_REQUEST['var_captcha_color']);
$text = randomString(5);
// how many figures will be display
$abspath = getcwd();
$abspath = str_replace("\\", "/", $abspath);
//header('Content-type: image/png');
//error_reporting(E_ALL);
$img = ImageCreateFromPNG('captcha.png');
// background image
$color = ImageColorAllocate($img, $rgb[0], $rgb[1], $rgb[2]);
// color
$ttf = "{$abspath}/xfiles.ttf";
//font type
$ttfsize = 24;
// font size
$angle = rand(0, 5);
开发者ID:rcuyegkeng,项目名称:FnD_a,代码行数:31,代码来源:captcha.php

示例12: convert_html_color

function convert_html_color($html)
{
    global $hue, $sat;
    $RGB = html2rgb($html);
    //convert html to rgb
    $HSV = RGB_TO_HSV($RGB[0], $RGB[1], $RGB[2]);
    // convert rgb to hsv, which are percentages
    $huechange = ($hue + 100) / 200;
    //find the percentage change from the imagemagick command
    $newH = $HSV['H'] + $huechange;
    if ($newH > 1) {
        $newH = $newH - 1;
    }
    $newS = $HSV['S'] * ($sat / 100);
    $newRGB = HSV_TO_RGB($newH, $newS, $HSV['V']);
    $newHTML = rgb2html($newRGB['R'], $newRGB['G'], $newRGB['B']);
    return $newHTML;
}
开发者ID:chandradrupal,项目名称:resourcespace,代码行数:18,代码来源:colorfunctions.php

示例13: create_captcha

/**
|==========================================================
| Create Captcha
|==========================================================
|
*/
function create_captcha($data = '', $img_path = '', $img_url = '', $font_path = '')
{
    $defaults = array('word' => '', 'max_char' => '6', 'img_path' => '', 'img_url' => '', 'img_width' => '150', 'img_height' => '30', 'font_path' => '', 'expiration' => 0, 'background' => '#FFFFFF', 'border' => '#CCCCCC', 'text' => '#330099', 'grid' => '#0033CC', 'shadow' => '#330099', 'pool' => '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
    foreach ($defaults as $key => $val) {
        if (!is_array($data)) {
            if (!isset(${$key}) or ${$key} == '') {
                ${$key} = $val;
            }
        } else {
            ${$key} = !isset($data[$key]) ? $val : $data[$key];
        }
    }
    if ($img_path == '' or $img_url == '') {
        return FALSE;
    }
    if (!@is_dir($img_path)) {
        throw new Exception('Captcha path seems is not a directory !');
    }
    if (!common::is_really_writable($img_path)) {
        throw new Exception($img_path . ' Captcha directory is not writeable !');
    }
    if (!extension_loaded('gd')) {
        throw new Exception('Gd extension not found for captcha !');
    }
    // -----------------------------------
    // Remove old images
    // -----------------------------------
    list($usec, $sec) = explode(" ", microtime());
    $now = (double) $usec + (double) $sec;
    $current_dir = @opendir($img_path);
    while ($filename = @readdir($current_dir)) {
        //echo 'file name '.$filename;
        if ($filename != "." and $filename != ".." and $filename != "index.html") {
            $name = str_replace(".jpg", "", $filename);
            if ($name + $expiration < $now) {
                @unlink($img_path . $filename);
            }
        }
    }
    @closedir($current_dir);
    // -----------------------------------
    // Do we have a "word" yet?
    // -----------------------------------
    if ($word == '') {
        $str = '';
        for ($i = 0; $i < $max_char; $i++) {
            $str .= substr($pool, mt_rand(0, strlen($pool) - 1), 1);
        }
        $word = $str;
    }
    // -----------------------------------
    // Determine angle and position
    // -----------------------------------
    $length = strlen($word);
    $angle = $length >= 6 ? rand(-($length - 6), $length - 6) : 0;
    $x_axis = rand(6, 360 / $length - 16);
    $y_axis = $angle >= 0 ? rand($img_height, $img_width) : rand(6, $img_height);
    // -----------------------------------
    // Create image
    // -----------------------------------
    // PHP.net recommends imagecreatetruecolor(), but it isn't always available
    if (function_exists('imagecreatetruecolor')) {
        $im = imagecreatetruecolor($img_width, $img_height);
    } else {
        $im = imagecreate($img_width, $img_height);
    }
    // -----------------------------------
    //  Assign colors
    // -----------------------------------
    $bg = html2rgb($background);
    $bg_color = imagecolorallocate($im, $bg[0], $bg[1], $bg[2]);
    $brd = html2rgb($border);
    $border_color = imagecolorallocate($im, $brd[0], $brd[1], $brd[2]);
    $txt = html2rgb($text);
    $text_color = imagecolorallocate($im, $txt[0], $txt[1], $txt[2]);
    $grd = html2rgb($grid);
    $grid_color = imagecolorallocate($im, $grd[0], $grd[1], $grd[2]);
    $shd = html2rgb($shadow);
    $shadow_color = imagecolorallocate($im, $shd[0], $shd[1], $shd[2]);
    // -----------------------------------
    //  Create the rectangle
    // -----------------------------------
    ImageFilledRectangle($im, 0, 0, $img_width, $img_height, $bg_color);
    // -----------------------------------
    //  Create the spiral pattern
    // -----------------------------------
    $theta = 1;
    $thetac = 7;
    $radius = 16;
    $circles = 8;
    $points = 8;
    for ($i = 0; $i < $circles * $points - 1; $i++) {
        $theta = $theta + $thetac;
        $rad = $radius * ($i / $points);
//.........这里部分代码省略.........
开发者ID:anugrahbsoe,项目名称:Becak-HMVC-Framework,代码行数:101,代码来源:captcha_helper.php

示例14: processColorSwatch

function processColorSwatch($hex, $ratio = 200)
{
    $tc = html2rgb($hex);
    $diff = coldiff($tc[0], $tc[1], $tc[2], 255, 255, 255);
    if ($diff < $ratio) {
        //use border
        return true;
    } else {
        return false;
    }
}
开发者ID:householdsteve,项目名称:lotus-drupal,代码行数:11,代码来源:template.php

示例15: imagecreatefromjpeg

         $im = imagecreatefromjpeg($filepath);
     } elseif ($filetype == 3) {
         $im = imagecreatefrompng($filepath);
     }
 } else {
     die("FFUUUUUUU");
 }
 $text1 = isset($_GET['text1']) && $_GET['text1'] != '' ? trim(stripinput($_GET['text1'])) : '';
 $text2 = isset($_GET['text2']) && $_GET['text2'] != '' ? trim(stripinput($_GET['text2'])) : '';
 $size1 = isset($_GET['size1']) && isnum($_GET['size1']) && in_array(intval($_GET['size1']), array(12, 16, 24, 32, 48)) ? intval($_GET['size1']) : 32;
 $size2 = isset($_GET['size2']) && isnum($_GET['size2']) && in_array(intval($_GET['size2']), array(12, 16, 24, 32, 48)) ? intval($_GET['size2']) : 32;
 $font1 = isset($_GET['font1']) && isnum($_GET['font1']) && in_array(intval($_GET['font1']), array(1, 2, 3, 4, 5)) ? intval($_GET['font1']) : 1;
 $font2 = isset($_GET['font2']) && isnum($_GET['font2']) && in_array(intval($_GET['font2']), array(1, 2, 3, 4, 5)) ? intval($_GET['font2']) : 1;
 $color1_array = html2rgb($_GET['color1']);
 $color1 = imagecolorallocate($im, $color1_array[0], $color1_array[1], $color1_array[2]);
 $color2_array = html2rgb($_GET['color2']);
 $color2 = imagecolorallocate($im, $color2_array[0], $color2_array[1], $color2_array[2]);
 if ($text1 != '') {
     CenterImageString($im, $gen_type, $image_res[0], $image_res[1], $text1, $size1, $color1, $font1, 1);
 }
 if ($text2 != '') {
     CenterImageString($im, $gen_type, $image_res[0], $image_res[1], $text2, $size2, $color2, $font2, 2);
 }
 if (isset($_GET['action']) && $_GET['action'] == "save") {
     $get_id = dbquery("SELECT mem_id FROM " . DB_GEM_MEMS . " ORDER BY mem_id DESC LIMIT 1");
     if (dbrows($get_id)) {
         $get_id = dbarray($get_id);
         $id = $get_id['mem_id'] + 1;
     } else {
         $id = 1;
     }
开发者ID:SymbolixDEV,项目名称:AL-PHP-Fusion-Addons,代码行数:31,代码来源:gen_image.php


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