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


PHP ImageSy函数代码示例

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


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

示例1: resizeImage

function resizeImage($image, $maxHeight)
{
    $width = ImageSx($image);
    $height = ImageSy($image);
    if ($height > $maxHeight) {
        $ratio = $maxHeight / $height;
        $x = $width * $ratio;
        $y = $maxHeight;
    } else {
        $x = $width;
        $y = $height;
    }
    $dst = ImageCreate($x, $y);
    ImageCopyResized($dst, $image, 0, 0, 0, 0, $x, $y, $width, $height);
    return $dst;
}
开发者ID:no2id,项目名称:php-docroot,代码行数:16,代码来源:bannerPic.php

示例2: process

 function process()
 {
     global $CONFIG;
     $matches = array();
     if (!preg_match("/^([0-9a-zA-Z]+)\\.png\$/", $this->file, $matches)) {
         error_exit("Invalid image request for {$this->file}");
     }
     $code = $matches[1];
     $basepath = trim($CONFIG['paths']['base_url'], '/') . '/image/pins';
     $basefile = trim($CONFIG['paths']['file_path'], '/') . '/image/pins';
     $localfile = "{$basefile}/{$code}.png";
     if (file_exists($localfile)) {
         header("Location: http://{$_SERVER['HTTP_HOST']}/{$basepath}/{$code}.png");
     } else {
         if (!function_exists('ImageCreateFromPNG')) {
             header("Location: http://{$_SERVER['HTTP_HOST']}/{$basepath}/blank-marker.png");
         } else {
             $font = 'ttf-bitstream-vera/Vera';
             $size = 6;
             if (strlen($code) < 3) {
                 # Bigger image for number-only pins
                 $size = 8;
             }
             $im = ImageCreateFromPNG("{$basefile}/blank-marker.png");
             imageSaveAlpha($im, true);
             $tsize = ImageTTFBBox($size, 0, $font, $code);
             $textbg = ImageColorAllocate($im, 255, 119, 207);
             $black = ImageColorAllocate($im, 0, 0, 0);
             $dx = abs($tsize[2] - $tsize[0]);
             $dy = abs($tsize[5] - $tsize[3]);
             $x = (ImageSx($im) - $dx) / 2 + 1;
             $y = (ImageSy($im) - $dy) / 2;
             ImageTTFText($im, $size, 0, $x, $y, $black, $font, $code);
             header('Content-Type: image/png');
             ImagePNG($im);
             ImagePNG($im, $localfile);
             ImageDestroy($im);
         }
     }
     exit;
 }
开发者ID:roboshed,项目名称:leaguerunner,代码行数:41,代码来源:pins.php

示例3: CreatThumb

 public function CreatThumb($filetype, $tsrc, $dest, $n_width, $n_height)
 {
     if ($filetype == "gif") {
         $im = ImageCreateFromGIF($dest);
         // Original picture width is stored
         $width = ImageSx($im);
         // Original picture height is stored
         $height = ImageSy($im);
         $newimage = imagecreatetruecolor($n_width, $n_height);
         imageCopyResized($newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height);
         ImageGIF($newimage, $tsrc);
         chmod("{$tsrc}", 0755);
     }
     if ($filetype == "jpg") {
         $im = ImageCreateFromJPEG($dest);
         // Original picture width is stored
         $width = ImageSx($im);
         // Original picture height is stored
         $height = ImageSy($im);
         $newimage = imagecreatetruecolor($n_width, $n_height);
         imageCopyResized($newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height);
         ImageJpeg($newimage, $tsrc);
         chmod("{$tsrc}", 0755);
     }
     if ($filetype == "png") {
         $im = ImageCreateFromPNG($dest);
         // Original picture width is stored
         $width = ImageSx($im);
         // Original picture height is stored
         $height = ImageSy($im);
         $newimage = imagecreatetruecolor($n_width, $n_height);
         imageCopyResized($newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height);
         imagepng($newimage, $tsrc);
         chmod("{$tsrc}", 0755);
     }
 }
开发者ID:jaanusnurmoja,项目名称:redjoomla,代码行数:36,代码来源:thumbnail.php

示例4: add_image


//.........这里部分代码省略.........
            if (file_exists($pic_gif)) {
                unlink($pic_gif);
            }
            chmod($_FILES[$image]['tmp_name'], 0644);
            // 1. if directory ./avatars/USERID does not exist, create it
            // 2. create the subdirs for ORIGINAL, LARGE (128) and SMALL(32)
            if (!is_dir($af_dir_ads . $user_id)) {
                mkdir($af_dir_ads . $user_id);
                mkdir($af_dir_ads . $user_id . "/original");
                // ORIGINAL
                mkdir($af_dir_ads . $user_id . "/large");
                // LARGE (128)
                mkdir($af_dir_ads . $user_id . "/small");
                // SMALL (32)
            }
            $original_image = $af_dir_ads . $user_id . "/original/" . $user_id . "." . $thispicext;
            $large_image = $af_dir_ads . $user_id . "/large/" . $user_id . "." . $thispicext;
            $small_image = $af_dir_ads . $user_id . "/small/" . $user_id . "." . $thispicext;
            // copy original image to folder "original"
            move_uploaded_file($_FILES[$image]['tmp_name'], $original_image);
            // create "large" image 128px
            switch ($af_size[2]) {
                case 1:
                    $src = ImageCreateFromGif($original_image);
                    break;
                case 2:
                    $src = ImageCreateFromJpeg($original_image);
                    break;
                case 3:
                    $src = ImageCreateFromPng($original_image);
                    break;
            }
            $width_before = ImageSx($src);
            $height_before = ImageSy($src);
            if ($width_before >= $height_before) {
                $width_new = min(128, $width_before);
                $scale = $width_before / $height_before;
                $height_new = round($width_new / $scale);
            } else {
                $height_new = min(128, $height_before);
                $scale = $height_before / $width_before;
                $width_new = round($height_new / $scale);
            }
            $dst = ImageCreateTrueColor($width_new, $height_new);
            // GD Lib 2
            ImageCopyResampled($dst, $src, 0, 0, 0, 0, $width_new, $height_new, $width_before, $height_before);
            switch ($af_size[2]) {
                case 1:
                    ImageGIF($dst, $large_image);
                    break;
                case 2:
                    ImageJPEG($dst, $large_image);
                    break;
                case 3:
                    ImagePNG($dst, $large_image);
                    break;
            }
            imagedestroy($dst);
            imagedestroy($src);
            // create "small" image 32px
            switch ($af_size[2]) {
                case 1:
                    $src = ImageCreateFromGif($original_image);
                    break;
                case 2:
                    $src = ImageCreateFromJpeg($original_image);
开发者ID:rbista,项目名称:Discussions-J1.6,代码行数:67,代码来源:imagehelper.php

示例5: create_image

function create_image()
{
    // To send to print sizes, per original asset.
    $sizes['print']['w'] = 5315;
    $sizes['print']['h'] = 3780;
    // Preview size
    $sizes['preview']['w'] = 786;
    $sizes['preview']['h'] = 588;
    // Create print size document, so all additional components are in correct position
    $printCanvas = imagecreatetruecolor($sizes['print']['w'], $sizes['print']['h']);
    // Colour references, white for foil blocked text (won't be on final print) and black for date and names.
    $colours['white'] = imagecolorallocate($printCanvas, 255, 255, 255);
    $colours['black'] = imagecolorallocate($printCanvas, 0, 0, 0);
    // Initially start with black image
    imagefill($printCanvas, 0, 0, $colours['black']);
    // Load in print asset
    $printSrc = imagecreatefromjpeg('final.jpg');
    // Add print asset to current canvas
    imagecopymerge($printCanvas, $printSrc, 0, 0, 0, 0, $sizes['print']['w'], $sizes['print']['h'], 100);
    // Once merged, destroy source image
    imagedestroy($printSrc);
    // Add in foil blocked text if in preview mode
    if (isset($_GET['preview'])) {
        imagettftext($printCanvas, 300, 0, 1865, 1225, $colours['white'], '28DaysLater.ttf', 'Established');
        imagettftext($printCanvas, 200, 0, 2418, 2325, $colours['white'], '28DaysLater.ttf', isset($_GET['title']) ? $_GET['title'] : 'Title here');
    }
    // If we have a valid information, set it, else just change to "Data here"
    if (isset($_GET['date'])) {
        $date = $_GET['date'];
    } else {
        $date = 'Date here';
    }
    if (isset($_GET['names'])) {
        $names = $_GET['names'];
    } else {
        $names = 'Names here';
    }
    if (isset($_GET['image'])) {
        $image = $_GET['image'];
    } else {
        $image = 'http://lorempixel.com/1280/1120/people/Sample Image';
    }
    // Print names onto the canvas
    imagettftext($printCanvas, 120, 0, 2418, 2490, $colours['black'], 'Rockwell.ttf', $names);
    // Print date onto the canvas, make the end of it match up to the end of "Established" above
    $type_space = imagettfbbox(120, 0, 'Rockwell.ttf', $date);
    imagettftext($printCanvas, 120, 0, 3750 - $type_space[4], 1360, $colours['black'], 'Rockwell.ttf', $date);
    // Ascertain if this is a external image, and if not, add on the current server address
    if (substr($image, 0, 4) != 'http') {
        $image = 'http://' . $_SERVER['SERVER_NAME'] . '/' . $image;
    }
    // Create image using the supplied image, and log the size
    $imageSrc = imagecreatefromjpeg($image);
    $sizes['image']['w'] = ImageSx($imageSrc);
    $sizes['image']['h'] = ImageSy($imageSrc);
    if (1280 - $sizes['image']['w'] < 1120 - $sizes['image']['h']) {
        $s = 1120 / $sizes['image']['h'];
        $sizes['imageSrc']['w'] = round($sizes['image']['w'] * $s);
        $sizes['imageSrc']['h'] = round($sizes['image']['h'] * $s);
    } else {
        $s = 1280 / $sizes['image']['w'];
        $sizes['imageSrc']['w'] = round($sizes['image']['w'] * $s);
        $sizes['imageSrc']['h'] = round($sizes['image']['h'] * $s);
    }
    // Create canvas for the supplied image to sit in
    $imageCanvas = ImageCreateTrueColor(1280, 1120);
    // Adjust the image position if the width or height is too big, to place the image in the centre
    if ($sizes['imageSrc']['w'] > 1280) {
        $newX = -(($sizes['imageSrc']['w'] - 1280) / 2);
    } else {
        $newX = 0;
    }
    if ($sizes['imageSrc']['h'] > 1120) {
        $newY = -(($sizes['imageSrc']['h'] - 1120) / 2);
    } else {
        $newY = 0;
    }
    // Copy image source onto the canvas
    imagecopyresized($imageCanvas, $imageSrc, $newX, $newY, 0, 0, $sizes['imageSrc']['w'], $sizes['imageSrc']['h'], $sizes['image']['w'], $sizes['image']['h']);
    // Prep the image for rotation
    $canvasTrans = imagecolorallocatealpha($imageCanvas, 0, 0, 0, 127);
    // Rotate image, and log new size
    $imageCanvas = imagerotate($imageCanvas, 5, $canvasTrans);
    $sizes['rotated-image']['w'] = ImageSx($imageCanvas);
    $sizes['rotated-image']['h'] = ImageSy($imageCanvas);
    // Add the rotated supplied image onto the print canvas
    ImageCopyResampled($printCanvas, $imageCanvas, 870, 1650, 0, 0, $sizes['rotated-image']['w'], $sizes['rotated-image']['h'], $sizes['rotated-image']['w'], $sizes['rotated-image']['h']);
    // Once copied, destroy image canvas, and source image
    imagedestroy($imageSrc);
    imagedestroy($imageCanvas);
    // If generating preview, adjust size of output
    if (isset($_GET['preview'])) {
        // Calculate how the aspect ratio should be calculated
        if ($sizes['preview']['w'] - $sizes['print']['w'] > $sizes['preview']['h'] - $sizes['print']['h']) {
            $s = $sizes['preview']['h'] / $sizes['print']['h'];
            $nw = round($sizes['print']['w'] * $s);
            $nh = round($sizes['print']['h'] * $s);
        } else {
            $s = $sizes['preview']['w'] / $sizes['print']['w'];
            $nw = round($sizes['print']['w'] * $s);
//.........这里部分代码省略.........
开发者ID:AttitudeDesign,项目名称:Image-Generator,代码行数:101,代码来源:index.php

示例6: array_search

    }
    $key = array_search($pref, $music_position);
    if ($key == FALSE) {
        continue;
    } else {
        $stamp_size = $img_music_size;
        $key1 = strstr($key, '_', true);
        $key2 = str_replace($key1 . "_", "", $key);
        if ($pref == "23_0") {
            $img_stamp = imagecreatefrompng('img/stamp_c.png');
        } else {
            $img_stamp = imagecreatefrompng('img/stamp.png');
        }
        // 縮小処理
        $width = ImageSx($img_stamp);
        $height = ImageSy($img_stamp);
        $resize = ImageCreateTrueColor($stamp_size, $stamp_size);
        imagealphablending($resize, false);
        imagesavealpha($resize, true);
        ImageCopyResampled($resize, $img_stamp, 0, 0, 0, 0, $stamp_size, $stamp_size, $width, $height);
        imagecopymerge($img, $resize, $key1, $key2, 0, 0, $stamp_size, $stamp_size, 55);
    }
}
// foreachおわり
// 合計曲数を入れる
ImageTTFText($img, 20, 0, 160, 280, $black, $font, $debut . " / " . $music_max / 4);
ImageTTFText($img, 20, 0, 160, 311, $black, $font, $regular . " / " . $music_max / 4);
ImageTTFText($img, 20, 0, 160, 342, $black, $font, $pro . " / " . $music_max / 4);
ImageTTFText($img, 20, 0, 160, 373, $black, $font, $master . " / " . $music_max / 4);
// 全曲総合処理
$music_sum = $debut + $regular + $pro + $master + $maspuls;
开发者ID:habu1010,项目名称:FullCombo-management-tool-for-sl-stage,代码行数:31,代码来源:process.php

示例7: pathinfo

 $path_parts = pathinfo($fn2);
 //echo $path_parts['extension'];
 if ($path_parts['extension'] == "JPG" || $path_parts['extension'] == "jpg") {
     //JPEGファイルを読み込む
     $image = ImageCreateFromJPEG($fn2);
 } else {
     if ($path_parts['extension'] == "png") {
         //$fn2=mb_convert_encoding($fn,$file_char_code,'auto');
         $image = imagecreatefrompng($fn2);
         //imagecreatefromstring(file_get_contents($fn));
     }
 }
 //echo $info;
 // 元画像のファイルサイズを取得
 $original_width = ImageSx($image);
 $original_height = ImageSy($image);
 //元画像の比率を計算し、高さを設定
 $proportion = $original_width / $original_height;
 $height = $width / $proportion;
 //高さが幅より大きい場合は、高さを幅に合わせ、横幅を縮小
 if ($proportion < 1) {
     $height = $width;
     $width = $width * $proportion;
 }
 $new_image = ImageCreateTrueColor($width, $height);
 // 画像作成
 // 元画像から再サンプリング
 ImageCopyResampled($new_image, $image, 0, 0, 0, 0, $width, $height, $original_width, $original_height);
 // 保存
 ImageJpeg($new_image, '/var/www/lifelog/DATA/boost/s/' . $newstr, 80);
 header('Content-Type: image/jpeg');
开发者ID:JFLABO,项目名称:lifelog,代码行数:31,代码来源:img_m2.php

示例8: add_image

 function add_image($thread, $id, $image, $absolute_path, $db, $imagenumber)
 {
     // get max_imagesize from parameters
     $params = JComponentHelper::getParams('com_discussions');
     $max_image_size = $params->get('maxImageSize', '209715200');
     // 200 KByte default
     $discussions_folder = $absolute_path . "/images/discussions/";
     if (!is_dir($discussions_folder)) {
         mkdir($discussions_folder);
     }
     $thread_folder = $absolute_path . "/images/discussions/posts/";
     if (!is_dir($thread_folder)) {
         mkdir($thread_folder);
     }
     $image_folder = $absolute_path . "/images/discussions/posts/" . $thread . "/";
     if (!is_dir($image_folder)) {
         mkdir($image_folder);
     }
     $image_too_big = 0;
     if (isset($_FILES[$image])) {
         if ($_FILES[$image]['size'] > $max_image_size) {
             $image_too_big = 1;
         }
     }
     if ($image_too_big == 1) {
         echo "<font color='#CC0000'>";
         echo JText::_('COFI_UPLOADED_IMAGE_TOO_BIG');
         echo "</font>";
         echo "<br>";
         echo "<br>";
     } else {
         $af_size = GetImageSize($_FILES[$image]['tmp_name']);
         switch ($af_size[2]) {
             case 1:
                 $thispicext = 'gif';
                 break;
             case 2:
                 $thispicext = 'jpg';
                 break;
             case 3:
                 $thispicext = 'png';
                 break;
         }
         // if ( $af_size[2] >= 1 && $af_size[2] <= 3) { // 1=GIF, 2=JPG or 3=PNG
         if ($af_size[2] >= 2 && $af_size[2] <= 3) {
             // 2=JPG or 3=PNG
             chmod($_FILES[$image]['tmp_name'], 0644);
             // 1. if directory ./images/USERID does not exist, create it
             // 2. create the subdirs for ORIGINAL, LARGE (128) and SMALL(32)
             if (!is_dir($image_folder . $id)) {
                 mkdir($image_folder . $id);
                 mkdir($image_folder . $id . "/original");
                 // ORIGINAL
                 mkdir($image_folder . $id . "/large");
                 // LARGE (800)
                 mkdir($image_folder . $id . "/small");
                 // SMALL (128)
             }
             $original_image = $image_folder . $id . "/original/" . $id . "_" . $imagenumber . "." . $thispicext;
             $large_image = $image_folder . $id . "/large/" . $id . "_" . $imagenumber . "." . $thispicext;
             $small_image = $image_folder . $id . "/small/" . $id . "_" . $imagenumber . "." . $thispicext;
             // copy original image to folder "original"
             move_uploaded_file($_FILES[$image]['tmp_name'], $original_image);
             // create "large" image 800px
             switch ($af_size[2]) {
                 case 1:
                     $src = ImageCreateFromGif($original_image);
                     break;
                 case 2:
                     $src = ImageCreateFromJpeg($original_image);
                     break;
                 case 3:
                     $src = ImageCreateFromPng($original_image);
                     break;
             }
             $width_before = ImageSx($src);
             $height_before = ImageSy($src);
             if ($width_before >= $height_before) {
                 $width_new = min(800, $width_before);
                 $scale = $width_before / $height_before;
                 $height_new = round($width_new / $scale);
             } else {
                 $height_new = min(600, $height_before);
                 $scale = $height_before / $width_before;
                 $width_new = round($height_new / $scale);
             }
             $dst = ImageCreateTrueColor($width_new, $height_new);
             // GD Lib 2
             ImageCopyResampled($dst, $src, 0, 0, 0, 0, $width_new, $height_new, $width_before, $height_before);
             switch ($af_size[2]) {
                 case 1:
                     ImageGIF($dst, $large_image);
                     break;
                 case 2:
                     ImageJPEG($dst, $large_image);
                     break;
                 case 3:
                     ImagePNG($dst, $large_image);
                     break;
             }
//.........这里部分代码省略.........
开发者ID:rbista,项目名称:Discussions-J1.6,代码行数:101,代码来源:posting.php

示例9: imagecreatetruecolor

     $newimage = imagecreatetruecolor($n_width, $n_height);
     imageCopyResized($newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height);
     ImageJPEG($newimage, $tsrc);
 }
 //		$to = "skippy@skippysearch.com"; //
 //		$subject = "***Skippy Alert***"; //
 //		$body = "Somebody just used Skippy the Shoe Finder!"; //
 //		$headers = "From: noreply@skippysearch.com\n"; //
 //		mail($to,$subject,$body,$headers); //
 // Color Select //
 $sample = 100;
 $pig = 32;
 // Get picture height and width //
 $im = imagecreatefromjpeg($tsrc);
 $width = ImageSx($im);
 $height = ImageSy($im);
 $winc = round($width / sqrt($sample / ($height / $width)));
 $hinc = round($height / sqrt($sample / ($width / $height)));
 // Scan the picture //
 $tick = 0;
 $winc = 3;
 $hinc = 3;
 $topx = $width * 0.4;
 $bottomx = $width * 0.6;
 $topy = $height * 0.4;
 $bottomy = $height * 0.6;
 for ($x = $topx; $x < $bottomx; $x += $winc) {
     for ($y = $topy; $y < $bottomy; $y += $hinc) {
         $tick = $tick + 1;
         $samp[$tick] = ImageColorAt($im, $x, $y);
         $sred[$tick] = $samp[$tick] >> 16 & 0xff;
开发者ID:ezchx,项目名称:skippy,代码行数:31,代码来源:index.php

示例10: md5

 // return the finished image as PNG
 if (!headers_sent()) {
     Safe::header("Content-type: image/png");
 }
 // enable 30-minute caching (30*60 = 1800), even through https, to help IE6 on download
 http::expire(1800);
 // strong validator
 $etag = '"' . md5($item['geo_place_name'] . $item['longitude'] . $item['latitude']) . '"';
 // manage web cache
 if (http::validate(NULL, $etag)) {
     return;
 }
 // load the main image
 $image = ImageCreateFromJpeg($context['path_to_root'] . 'locations/images/earth_310.jpg');
 $width = ImageSx($image);
 $height = ImageSy($image);
 // ensure we have split coordinates
 if (!$item['latitude'] || !$item['longitude']) {
     list($item['latitude'], $item['longitude']) = preg_split('/[\\s,;]+/', $item['geo_position']);
 }
 // scale coordinates
 $x = round(($item['longitude'] + 180) * ($width / 360));
 $y = round(($item['latitude'] * -1 + 90) * ($height / 180));
 // mark the point on the map using a red 4 pixel rectangle
 $red = ImageColorAllocate($image, 255, 0, 0);
 ImageFilledRectangle($image, $x - 2, $y - 2, $x + 2, $y + 2, $red);
 // actual transmission except on a HEAD request
 if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
     ImagePng($image);
 }
 ImageDestroy($image);
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:map_on_earth.php

示例11: getPos

 function getPos($sourcefile_width, $sourcefile_height, $pos, $wm_image = "")
 {
     if ($wm_image) {
         $insertfile_width = ImageSx($wm_image);
         $insertfile_height = ImageSy($wm_image);
     } else {
         $lineCount = explode("\n", $this->wm_text);
         $fontSize = imagettfbbox($this->wm_text_size, $this->wm_text_angle, $this->wm_text_font, $this->wm_text);
         $insertfile_width = $fontSize[2] - $fontSize[0];
         $insertfile_height = count($lineCount) * ($fontSize[1] - $fontSize[7]);
     }
     switch ($pos) {
         case 0:
             $dest_x = $sourcefile_width / 2 - $insertfile_width / 2;
             $dest_y = $sourcefile_height / 2 - $insertfile_height / 2;
             break;
         case 1:
             $dest_x = 0;
             if ($this->wm_text) {
                 $dest_y = $insertfile_height;
             } else {
                 $dest_y = 0;
             }
             break;
         case 2:
             $dest_x = $sourcefile_width - $insertfile_width;
             if ($this->wm_text) {
                 $dest_y = $insertfile_height;
             } else {
                 $dest_y = 0;
             }
             break;
         case 3:
             $dest_x = $sourcefile_width - $insertfile_width;
             $dest_y = $sourcefile_height - $insertfile_height;
             break;
         case 4:
             $dest_x = 0;
             $dest_y = $sourcefile_height - $insertfile_height;
             break;
         case 5:
             $dest_x = ($sourcefile_width - $insertfile_width) / 2;
             if ($this->wm_text) {
                 $dest_y = $insertfile_height;
             } else {
                 $dest_y = 0;
             }
             break;
         case 6:
             $dest_x = $sourcefile_width - $insertfile_width;
             $dest_y = $sourcefile_height / 2 - $insertfile_height / 2;
             break;
         case 7:
             $dest_x = ($sourcefile_width - $insertfile_width) / 2;
             $dest_y = $sourcefile_height - $insertfile_height;
             break;
         case 8:
             $dest_x = 0;
             $dest_y = $sourcefile_height / 2 - $insertfile_height / 2;
             break;
         default:
             $dest_x = $sourcefile_width - $insertfile_width;
             $dest_y = $sourcefile_height - $insertfile_height;
             break;
     }
     return array("dest_x" => $dest_x, "dest_y" => $dest_y);
 }
开发者ID:noikiy,项目名称:MyShop,代码行数:67,代码来源:mdl.gdimage.php

示例12: update_produk

 function update_produk()
 {
     $this->load->library('form_validation');
     $this->form_validation->set_rules('nama', 'nama', 'trim|required');
     $this->form_validation->set_rules('harga', 'harga', 'trim|required');
     $this->form_validation->set_rules('stok', 'stok', 'trim|required');
     $this->form_validation->set_rules('dibeli', 'dibeli', 'trim|required');
     $this->form_validation->set_rules('username', 'Username', 'trim|required');
     $this->form_validation->set_rules('deskripsi', 'deskripsi', 'trim|required');
     $this->form_validation->set_error_delimiters('<span style="color:#FF00000">' . '</span>');
     $kategori = mysql_real_escape_string($this->input->post('kategori'));
     $nama = mysql_real_escape_string($this->input->post('nama'));
     $harga = mysql_real_escape_string($this->input->post('harga'));
     $stok = mysql_real_escape_string($this->input->post('stok'));
     $dibeli = mysql_real_escape_string($this->input->post('dibeli'));
     $deskripsi = mysql_real_escape_string($this->input->post('deskripsi'));
     $tipe = mysql_real_escape_string($this->input->post('tipe'));
     $kode = $this->input->post('id');
     $gbr = $this->input->post('gbr');
     if (empty($_FILES['imagefile']['name'])) {
         $this->produk_model->jalankan_query_manual("update produk set id_kategori='" . $kategori . "', nama_produk='" . $nama . "', harga='" . $harga . "', stok='" . $stok . "', dibeli='" . $dibeli . "', deskripsi='" . $deskripsi . "' where id_produk='" . $kode . "'");
         echo "<meta http-equiv='refresh' content='0; url=" . site_url() . "/produk'>";
     } else {
         if ($_FILES['imagefile']['type'] == "image/jpeg") {
             $ori_src = "assets/produk/imgoriginal/" . strtolower(str_replace(' ', '_', $_FILES['imagefile']['name']));
             if (move_uploaded_file($_FILES['imagefile']['tmp_name'], $ori_src)) {
                 chmod("{$ori_src}", 0777);
             } else {
                 echo "Gagal melakukan proses upload file.";
                 exit;
             }
             $thumb_src = "assets/produk/" . strtolower(str_replace(' ', '_', $_FILES['imagefile']['name']));
             $n_width = 150;
             $n_height = 150;
             if ($_FILES['imagefile']['type'] == "image/jpeg" || $_FILES['imagefile']['type'] == "image/png" || $_FILES['imagefile']['type'] == "image/gif") {
                 $im = @ImageCreateFromJPEG($ori_src) or $im = @ImageCreateFromPNG($ori_src) or $im = @ImageCreateFromGIF($ori_src) or $im = false;
                 // If image is not JPEG, PNG, or GIF
                 //$im=ImageCreateFromJPEG($ori_src);
                 $width = ImageSx($im);
                 // Original picture width is stored
                 $height = ImageSy($im);
                 // Original picture height is stored
                 if ($n_height == 0 && $n_width == 0) {
                     $n_height = $height;
                     $n_width = $width;
                 }
                 if (!$im) {
                     echo '<p>Gagal membuat thumnail</p>';
                     exit;
                 } else {
                     $newimage = @imagecreatetruecolor($n_width, $n_height);
                     @imageCopyResized($newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height);
                     @ImageJpeg($newimage, $thumb_src);
                     chmod("{$thumb_src}", 0777);
                 }
             }
             $this->produk_model->jalankan_query_manual("update produk set id_kategori='" . $kategori . "', nama_produk='" . $nama . "', harga='" . $harga . "', stok='" . $stok . "', dibeli='" . $dibeli . "', gbr_kecil='" . $_FILES['imagefile']['name'] . "', gbr_besar='" . $_FILES['imagefile']['name'] . "', deskripsi='" . $deskripsi . "' where id_produk='" . $kode . "'");
             $file_kcl = './assets/produk/' . $gbr;
             $file_bsr = './assets/produk/imgoriginal/' . $gbr;
             unlink($file_kcl);
             unlink($file_bsr);
             echo "<meta http-equiv='refresh' content='0; url=" . site_url() . "/produk'>";
         } else {
             echo "Mohon upload foto yang berjenis gambar!";
         }
     }
 }
开发者ID:NaszvadiG,项目名称:codeigniter-e-commerce,代码行数:67,代码来源:produk.php

示例13: update_produk

 function update_produk()
 {
     if ($this->session->userdata('masuk')) {
         $kategori = mysql_real_escape_string($this->input->post('kategori'));
         $nama = mysql_real_escape_string($this->input->post('nama'));
         $harga = mysql_real_escape_string($this->input->post('harga'));
         $stok = mysql_real_escape_string($this->input->post('stok'));
         $dibeli = mysql_real_escape_string($this->input->post('dibeli'));
         $deskripsi = mysql_real_escape_string($this->input->post('deskripsi'));
         $tipe = mysql_real_escape_string($this->input->post('tipe'));
         $kode = $this->input->post('id');
         $gbr = $this->input->post('gbr');
         $gbr2 = $this->input->post('gbr2');
         if (empty($_FILES['imagefile']['name'])) {
             //gambar 2 edit mulai
             if (empty($_FILES['imagefile2']['name'])) {
                 $this->m_awal->jalankan_query_manual("update tbl_produk set id_kategori='" . $kategori . "', nama_produk='" . $nama . "', harga='" . $harga . "', \n\t\t\t\t\tstok='" . $stok . "', dibeli='" . $dibeli . "', deskripsi='" . $deskripsi . "', tipe_produk='" . $tipe . "' where kode_produk='" . $kode . "'");
                 echo "<meta http-equiv='refresh' content='0; url=" . base_url() . "index.php/admin'>";
             } else {
                 if ($_FILES['imagefile2']['type'] == "image/jpeg") {
                     $ori_src = "asset/produk/imgoriginal/" . strtolower(str_replace(' ', '_', $_FILES['imagefile2']['name']));
                     if (move_uploaded_file($_FILES['imagefile2']['tmp_name'], $ori_src)) {
                         chmod("{$ori_src}", 0777);
                     } else {
                         echo "Gagal melakukan proses upload file.";
                         exit;
                     }
                     $thumb_src = "asset/produk/" . strtolower(str_replace(' ', '_', $_FILES['imagefile2']['name']));
                     $n_width = 150;
                     $n_height = 150;
                     if ($_FILES['imagefile2']['type'] == "image/jpeg" || $_FILES['imagefile2']['type'] == "image/png" || $_FILES['imagefile2']['type'] == "image/gif") {
                         $im = @ImageCreateFromJPEG($ori_src) or $im = @ImageCreateFromPNG($ori_src) or $im = @ImageCreateFromGIF($ori_src) or $im = false;
                         // If image is not JPEG, PNG, or GIF
                         //$im=ImageCreateFromJPEG($ori_src);
                         $width = ImageSx($im);
                         // Original picture width is stored
                         $height = ImageSy($im);
                         // Original picture height is stored
                         if ($n_height == 0 && $n_width == 0) {
                             $n_height = $height;
                             $n_width = $width;
                         }
                         if (!$im) {
                             echo '<p>Gagal membuat thumnail</p>';
                             exit;
                         } else {
                             $newimage = @imagecreatetruecolor($n_width, $n_height);
                             @imageCopyResized($newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height);
                             @ImageJpeg($newimage, $thumb_src);
                             chmod("{$thumb_src}", 0777);
                         }
                     }
                     $this->m_awal->jalankan_query_manual("update tbl_produk set id_kategori='" . $kategori . "', nama_produk='" . $nama . "', harga='" . $harga . "', \n\t\t\t\t\t\tstok='" . $stok . "', dibeli='" . $dibeli . "', gbr_kecil2='" . $_FILES['imagefile2']['name'] . "', gbr_besar2='" . $_FILES['imagefile2']['name'] . "', \n\t\t\t\t\t\tdeskripsi='" . $deskripsi . "', tipe_produk='" . $tipe . "' where kode_produk='" . $kode . "'");
                     $file_kcl = './asset/produk/' . $gbr2;
                     $file_bsr = './asset/produk/imgoriginal/' . $gbr2;
                     unlink($file_kcl);
                     unlink($file_bsr);
                     echo "<meta http-equiv='refresh' content='0; url=" . base_url() . "index.php/admin'>";
                 } else {
                     echo "Hayooo,,,mau upload file apaan tuh...??? Upload yang berjenis gambar aja mas brow, gak usah macam-macam...!!! OKOK";
                 }
                 //gambar 2 edit selssai
             }
         } else {
             if (empty($_FILES['imagefile2']['name'])) {
                 if ($_FILES['imagefile']['type'] == "image/jpeg") {
                     $ori_src = "asset/produk/imgoriginal/" . strtolower(str_replace(' ', '_', $_FILES['imagefile']['name']));
                     if (move_uploaded_file($_FILES['imagefile']['tmp_name'], $ori_src)) {
                         chmod("{$ori_src}", 0777);
                     } else {
                         echo "Gagal melakukan proses upload file.";
                         exit;
                     }
                     $thumb_src = "asset/produk/" . strtolower(str_replace(' ', '_', $_FILES['imagefile']['name']));
                     $n_width = 150;
                     $n_height = 150;
                     if ($_FILES['imagefile']['type'] == "image/jpeg" || $_FILES['imagefile']['type'] == "image/png" || $_FILES['imagefile']['type'] == "image/gif") {
                         $im = @ImageCreateFromJPEG($ori_src) or $im = @ImageCreateFromPNG($ori_src) or $im = @ImageCreateFromGIF($ori_src) or $im = false;
                         // If image is not JPEG, PNG, or GIF
                         //$im=ImageCreateFromJPEG($ori_src);
                         $width = ImageSx($im);
                         // Original picture width is stored
                         $height = ImageSy($im);
                         // Original picture height is stored
                         if ($n_height == 0 && $n_width == 0) {
                             $n_height = $height;
                             $n_width = $width;
                         }
                         if (!$im) {
                             echo '<p>Gagal membuat thumnail</p>';
                             exit;
                         } else {
                             $newimage = @imagecreatetruecolor($n_width, $n_height);
                             @imageCopyResized($newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height);
                             @ImageJpeg($newimage, $thumb_src);
                             chmod("{$thumb_src}", 0777);
                         }
                     }
                     $this->m_awal->jalankan_query_manual("update tbl_produk set id_kategori='" . $kategori . "', nama_produk='" . $nama . "', harga='" . $harga . "', \n\t\t\t\t\t\tstok='" . $stok . "', dibeli='" . $dibeli . "', gbr_kecil='" . $_FILES['imagefile']['name'] . "', gbr_besar='" . $_FILES['imagefile']['name'] . "', \n\t\t\t\t\t\tdeskripsi='" . $deskripsi . "', tipe_produk='" . $tipe . "' where kode_produk='" . $kode . "'");
                     $file_kcl = './asset/produk/' . $gbr;
//.........这里部分代码省略.........
开发者ID:mteguhe,项目名称:cws,代码行数:101,代码来源:admin.php

示例14: ImageRectangle

 // Draw a border in destination image
 ImageRectangle($imageOut, 0, 0, $outX - 1, $outY - 1, ImageColorAllocate($imageOut, 0, 0, 0));
 // Do the work
 $nextX = BORDER_LEFT;
 $nextY = BORDER_TOP;
 foreach ($imageKeys as $imageKey) {
     // Fetch the image
     print "  Fetch image '{$imageKey}'\n";
     $image = $s3->get_object(BOOK_BUCKET, $imageKey);
     // Convert it to GD format
     $imageBits = ImageCreateFromString($image->body);
     // Copy it to proper spot in the destination
     print "  Render image at {$nextX}, {$nextY}\n";
     ImageCopy($imageOut, $imageBits, $nextX, $nextY, 0, 0, ImageSx($imageBits), ImageSy($imageBits));
     // Draw a border around it
     ImageRectangle($imageOut, $nextX, $nextY, $nextX + ImageSx($imageBits), $nextY + ImageSy($imageBits), ImageColorAllocate($imageOut, 0, 0, 0));
     // Update position for next image
     $nextX += THUMB_SIZE + GAP_SIZE;
     if ($nextX + THUMB_SIZE > $outX) {
         $nextX = BORDER_LEFT;
         $nextY += THUMB_SIZE + GAP_SIZE;
     }
 }
 // Get the bits of the destination image
 $imageFileOut = tempnam('/tmp', 'aws') . '.png';
 ImagePNG($imageOut, $imageFileOut, 0);
 $imageBitsOut = file_get_contents($imageFileOut);
 unlink($imageFileOut);
 // Store the final image in S3
 $key = 'page_image_' . md5($pageTitle) . '.png';
 if (uploadObject($s3, BOOK_BUCKET, $key, $imageBitsOut, AmazonS3::ACL_PUBLIC)) {
开发者ID:websider,项目名称:amazon-web-services,代码行数:31,代码来源:render_images.php

示例15: resizeImage

/**
* resize image
*/

function resizeImage($path,$file,$filename,$width,$height,$format) {
	/*
	use this example for reference
	path: C:/xampp/htdocs/vl/onlinefiles/uploads/_usericons/84/,
	file: C:/xampp/htdocs/vl/onlinefiles/uploads/_usericons/84/bmwx62.jpg,
	filename: bmwx62.jpg,
	width: 640,
	height: 480,
	dir: ,
	format: jpg
	*/
	
	//thumbnail settings
	$tmb_src=0;
	$tmb_src=$file;
					
	//thumbnail creation
	$image=0;
	$imagewidth=0;
	$imageheight=0;
				
	switch($format) {
		case GIF:
		case gif:
			$image=ImageCreateFromGIF($tmb_src);
		break;
		case JPEG:
		case JPG:
		case jpeg:
		case jpg:
			$image=ImageCreateFromJPEG($tmb_src);
		break;
		case PNG:
			$image=ImageCreateFromPNG($tmb_src);
		break;
	}
		
	//parsed dimensions
	$tmb_width=0;
	$tmb_height=0;

	//default dimensions
	$imagewidth=ImageSx($image);
	$imageheight=ImageSy($image);
					
	$newimage=0;
	//do the neccessary resizing on condition that ...
	if($imagewidth>$width || $imageheight>$height) {
		if ($imagewidth > $imageheight) {
			$tmb_width=$width;
			$tmb_height=$imageheight*($width/$imagewidth);
		} else if($imageheight > $imagewidth) {
			$tmb_height=$height;
			$tmb_width=$imagewidth*($height/$imageheight);
		} else {
			$tmb_width=$width;
			$tmb_height=$height;
		}
	} else {
		$tmb_width=$imagewidth;
		$tmb_height=$imageheight;
	}
		
	$newimage=imagecreatetruecolor($tmb_width,$tmb_height);
	imageCopyResized($newimage,$image,0,0,0,0,$tmb_width,$tmb_height,$imagewidth,$imageheight);
	switch($format) {
		case GIF:
		case gif:
			if(function_exists("imagegif")) {
				//Header("Content-type: image/gif");
				ImageGIF($newimage,$path.$filename);
				chmod($path.$filename,0755);
			} else if(function_exists("imagejpeg")) {
				//Header("Content-type: image/jpeg");
				ImageJPEG($newimage,$path.$filename);
				chmod($path.$filename,0755);
			}
		break;
		case JPEG:
		case JPG:
		case jpeg:
		case jpg:
			if(function_exists("imagejpeg")) {
				//Header("Content-type: image/jpeg");
				ImageJPEG($newimage,$path.$filename);
				chmod($path.$filename,0755);
			}
		break;
		case PNG:
		case png:
			if(function_exists("imagepng")) {
				//Header("Content-type: image/png");
				ImagePNG($newimage,$path.$filename);
				chmod($path.$filename,0755);
			}
		break;
//.........这里部分代码省略.........
开发者ID:CHAIUganda,项目名称:ViralLoad,代码行数:101,代码来源:functions.files.php


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