• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP imagejpeg函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: cropnsave

 public function cropnsave($id)
 {
     $basepath = app_path() . '/storage/uploads/';
     $jpeg_quality = 90;
     $src = $basepath . 'resize_' . $id;
     if (ImageModel::getImgTypeByExtension($id) == ImageModel::IMGTYPE_PNG) {
         $img_r = imagecreatefrompng($src);
     } else {
         $img_r = imagecreatefromjpeg($src);
     }
     $dst_r = ImageCreateTrueColor(Input::get('w'), Input::get('h'));
     imagecopyresampled($dst_r, $img_r, 0, 0, Input::get('x'), Input::get('y'), Input::get('w'), Input::get('h'), Input::get('w'), Input::get('h'));
     $filename = $basepath . 'crop_' . $id;
     imagejpeg($dst_r, $filename, $jpeg_quality);
     $image = ImageModel::createImageModel('crop_' . $id);
     try {
         $session = Session::get('user');
         $userService = new SoapClient(Config::get('wsdl.user'));
         $currentUser = $userService->getUserById(array("userId" => $session['data']->id));
         $currentUser = $currentUser->user;
         $currentUser->avatar = $image;
         $result = $userService->updateUser(array("user" => $currentUser));
         // Cleanup
         File::delete($src);
         File::delete($filename);
         File::delete($basepath . $id);
         return Response::json($result->complete);
     } catch (Exception $ex) {
         error_log($ex);
     }
 }
开发者ID:Yatko,项目名称:Gifteng,代码行数:31,代码来源:ImageController.php


示例2: filter

 public function filter($value)
 {
     if (!file_exists($value)) {
         throw new Zend_Filter_Exception('Image does not exist: ' . $value);
     }
     $image = imagecreatefromstring(file_get_contents($value));
     if (false === $image) {
         throw new Zend_Filter_Exception('Can\'t load image: ' . $value);
     }
     // find ratio to scale down to
     // TODO: pass 600 as parameter in the future
     $origWidth = imagesx($image);
     $origHeight = imagesy($image);
     $ratio = max($origWidth, $origHeight) / 600;
     if ($ratio > 1) {
         // img too big! create a scaled down image
         $newWidth = round($origWidth / $ratio);
         $newHeight = round($origHeight / $ratio);
         $resized = imagecreatetruecolor($newWidth, $newHeight);
         imagecopyresampled($resized, $image, 0, 0, 0, 0, $newWidth, $newHeight, $origWidth, $origHeight);
         // determine type and store to disk
         $explodeResult = explode(".", $value);
         $type = strtolower($explodeResult[count($explodeResult) - 1]);
         $writeFunc = 'image' . $type;
         if ($type == 'jpeg' || $type == 'jpg') {
             imagejpeg($resized, $value, 100);
         } else {
             $writeFunc($resized, $value);
         }
     }
     return $value;
 }
开发者ID:RadioCampusFrance,项目名称:airtime,代码行数:32,代码来源:ImageSize.php


示例3: index

 public function index()
 {
     $code = substr(sha1(mt_rand()), 17, 6);
     $this->session->set_userdata('captcha_code', $code);
     $width = '120';
     $height = '40';
     $font = APPPATH . 'modules/contact/assets/fonts/monofont.ttf';
     $font_size = $height * 0.75;
     $image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream');
     /* set the colours */
     $background_color = imagecolorallocate($image, 255, 255, 255);
     $text_color = imagecolorallocate($image, 20, 40, 100);
     $noise_color = imagecolorallocate($image, 100, 120, 180);
     /* generate random dots in background */
     for ($i = 0; $i < $width * $height / 3; $i++) {
         imagefilledellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);
     }
     /* generate random lines in background */
     for ($i = 0; $i < $width * $height / 150; $i++) {
         imageline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $noise_color);
     }
     /* create textbox and add text */
     $textbox = imagettfbbox($font_size, 0, $font, $code) or die('Error in imagettfbbox function');
     $x = ($width - $textbox[4]) / 2;
     $y = ($height - $textbox[5]) / 2;
     imagettftext($image, $font_size, 0, $x, $y, $text_color, $font, $code) or die('Error in imagettftext function');
     /* output captcha image to browser */
     header('Content-Type: image/jpeg');
     imagejpeg($image);
     imagedestroy($image);
 }
开发者ID:binaek89,项目名称:cms-canvas,代码行数:31,代码来源:captcha.php


示例4: create_pic

function create_pic($upfile, $new_path, $width)
{
    $quality = 100;
    $image_path = $upfile;
    $image_info = getimagesize($image_path);
    $exname = '';
    //1  =  GIF,  2  =  JPG,  3  =  PNG,  4  =  SWF,  5  =  PSD,  6  =  BMP,  7  =  TIFF(intel  byte  order),  8  =  TIFF(motorola  byte  order),  9  =  JPC,  10  =  JP2,  11  =  JPX,  12  =  JB2,  13  =  SWC,  14  =  IFF
    switch ($image_info[2]) {
        case 1:
            @($image = imagecreatefromgif($image_path));
            $exname = 'gif';
            break;
        case 2:
            @($image = imagecreatefromjpeg($image_path));
            $exname = 'jpg';
            break;
        case 3:
            @($image = imagecreatefrompng($image_path));
            $exname = 'png';
            break;
        case 6:
            @($image = imagecreatefromwbmp($image_path));
            $exname = 'wbmp';
            break;
    }
    $T_width = $image_info[0];
    $T_height = $image_info[1];
    if (!empty($image)) {
        $image_x = imagesx($image);
        $image_y = imagesy($image);
    } else {
        return FALSE;
    }
    @chmod($new_path, 0777);
    if ($image_x > $width) {
        $x = $width;
        $y = intval($x * $image_y / $image_x);
    } else {
        @copy($image_path, $new_path . '.' . $exname);
        return $exname;
    }
    $newimage = imagecreatetruecolor($x, $y);
    imagecopyresampled($newimage, $image, 0, 0, 0, 0, $x, $y, $image_x, $image_y);
    switch ($image_info[2]) {
        case 1:
            imagegif($newimage, $new_path . '.gif', $quality);
            break;
        case 2:
            imagejpeg($newimage, $new_path . '.jpg', $quality);
            break;
        case 3:
            imagepng($newimage, $new_path . '.png', $quality);
            break;
        case 6:
            imagewbmp($newimage, $new_path . '.wbmp', $quality);
            break;
    }
    imagedestroy($newimage);
    return $exname;
}
开发者ID:yunsite,项目名称:cyaskuc,代码行数:60,代码来源:global.func.php


示例5: createthumb

function createthumb($originalImage, $new_w, $new_h)
{
    $src_img = imagecreatefromjpeg("uploads/" . $originalImage);
    # Add the _t to our image name
    list($imageName, $extension) = explode(".", $originalImage);
    $newName = $imageName . "_t." . $extension;
    # Maintain proportions
    $old_x = imageSX($src_img);
    $old_y = imageSY($src_img);
    if ($old_x > $old_y) {
        $thumb_w = $new_w;
        $thumb_h = $old_y * ($new_h / $old_x);
    }
    if ($old_x < $old_y) {
        $thumb_w = $old_x * ($new_w / $old_y);
        $thumb_h = $new_h;
    }
    if ($old_x == $old_y) {
        $thumb_w = $new_w;
        $thumb_h = $new_h;
    }
    # Create destination-image-resource
    $dst_img = ImageCreateTrueColor($thumb_w, $thumb_h);
    # Copy source-image-resource to destination-image-resource
    imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y);
    # Create the final image from the destination-image-resource
    imagejpeg($dst_img, "uploads/" . $newName);
    # Delete our image-resources
    imagedestroy($dst_img);
    imagedestroy($src_img);
    # Show results
    return $newName;
}
开发者ID:ritarafaeli,项目名称:notes,代码行数:33,代码来源:uploaderExample_functions.php


示例6: resizewidth

 static function resizewidth($width, $imageold, $imagenew)
 {
     $image_info = getimagesize($imageold);
     $image_type = $image_info[2];
     if ($image_type == IMAGETYPE_JPEG) {
         $image = imagecreatefromjpeg($imageold);
     } elseif ($this->image_type == IMAGETYPE_GIF) {
         $image = imagecreatefromgif($imageold);
     } elseif ($this->image_type == IMAGETYPE_PNG) {
         $image = imagecreatefrompng($imageold);
     }
     $ratio = imagesy($image) / imagesx($image);
     $height = $width * $ratio;
     //$width = imagesx($image) * $width/100;
     // $height = imagesx($image) * $width/100;
     $new_image = imagecreatetruecolor($width, $height);
     imagecopyresampled($new_image, $image, 0, 0, 0, 0, $width, $height, $image_info[0], $image_info[1]);
     $image = $new_image;
     $compression = 75;
     $permissions = null;
     if ($image_type == IMAGETYPE_JPEG) {
         imagejpeg($image, $imagenew, $compression);
     } elseif ($image_type == IMAGETYPE_GIF) {
         imagegif($image, $imagenew);
     } elseif ($image_type == IMAGETYPE_PNG) {
         imagepng($image, $imagenew);
     }
     if ($permissions != null) {
         chmod($imagenew, $permissions);
     }
 }
开发者ID:blackorwhite1233,项目名称:fakekinhdoanh,代码行数:31,代码来源:SimpleImage.php


示例7: create_thumbnail

function create_thumbnail($filename)
{
    $percent = 0.1;
    list($width, $height) = getimagesize("/var/www/amberandbrice.com/workspace/images/" . $filename);
    $newwidth = $width * $percent;
    $newheight = $height * $percent;
    $thumb = imagecreatetruecolor($newwidth, $newheight);
    $ext = pathinfo($filename)['extension'];
    echo "<h1>{$ext}</h1>";
    switch ($ext) {
        case 'jpg':
        case 'jpeg':
        case 'JPG':
            $source = imagecreatefromjpeg("images/" . $filename);
            imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
            imagejpeg($thumb, "./thumbs/" . $filename);
            break;
        case 'gif':
            $source = imagecreatefromgif("images/" . $filename);
            imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
            imagejpeg($thumb, "./thumbs/" . $filename);
            break;
        case 'png':
            $source = imagecreatefrompng("images/" . $filename);
            imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
            imagejpeg($thumb, "./thumbs/" . $filename);
            break;
        default:
            die("image extension cannot be determined");
    }
}
开发者ID:bbathel12,项目名称:workspace,代码行数:31,代码来源:config.php


示例8: upload

function upload($tmp, $name, $nome, $larguraP, $pasta)
{
    $ext = strtolower(end(explode('.', $name)));
    if ($ext == 'jpg') {
        $img = imagecreatefromjpeg($tmp);
    } elseif ($ext == 'gif') {
        $img = imagecreatefromgif($tmp);
    } else {
        $img = imagecreatefrompng($tmp);
    }
    $x = imagesx($img);
    $y = imagesy($img);
    $largura = $x > $larguraP ? $larguraP : $x;
    $altura = $largura * $y / $x;
    if ($altura > $larguraP) {
        $altura = $larguraP;
        $largura = $altura * $x / $y;
    }
    $nova = imagecreatetruecolor($largura, $altura);
    imagecopyresampled($nova, $img, 0, 0, 0, 0, $largura, $altura, $x, $y);
    imagejpeg($nova, "{$pasta}/{$nome}");
    imagedestroy($img);
    imagedestroy($nova);
    return $nome;
}
开发者ID:mauriliovilela,项目名称:ser-social,代码行数:25,代码来源:funcoes.php


示例9: generate

 /**
  * Return captcha image
  * @param number $maxChar
  */
 public function generate($maxChar = 4)
 {
     // $characters = '23456789abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ';
     $characters = 'ABCDEFGHKMNPQRST';
     $captchaText = '';
     for ($i = 0; $i < $maxChar; $i++) {
         $captchaText .= $characters[rand(0, strlen($characters) - 1)];
     }
     strtoupper(substr(md5(microtime()), 0, 7));
     \Session::put('captchaHash', \Hash::make($captchaText));
     $image = imagecreate(30 * $maxChar, 35);
     $background = imagecolorallocatealpha($image, 255, 255, 255, 1);
     $textColor = imagecolorallocatealpha($image, 206, 33, 39, 1);
     $x = 5;
     $y = 20;
     $angle = 0;
     for ($i = 0; $i < 7; $i++) {
         $fontSize = 16;
         $text = substr($captchaText, $i, 1);
         imagettftext($image, $fontSize, $angle, $x, $y, $textColor, public_path('/fonts/LibreBaskerville/librebaskerville-regular.ttf'), $text);
         $x = $x + 17 + mt_rand(1, 10);
         $y = mt_rand(18, 25);
         $angle = mt_rand(0, 20);
     }
     header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
     header('Pragma: no-cache');
     header('Content-type: image/jpeg');
     imagejpeg($image, null, 100);
     imagedestroy($image);
 }
开发者ID:atudz,项目名称:gorabelframework,代码行数:34,代码来源:CaptchaLibrary.php


示例10: resizer

function resizer($filename, $copypath, $MaxWidth, $MaxHeight)
{
    //cesta k souboru, ktery chcete zmensit cesta, kam zmenseny soubor ulozit maximalni sirka zmenseneho obrazku   //maximalni vyska zmenseneho obrazku
    //zjistime puvodni velikost obrazku
    list($OrigWidth, $OrigHeight) = getimagesize($filename);
    //hodnota 0 v parametrech MaxWidth resp. MaxHeight znamena, ze sirka resp. vyska vysledku muze byt libovolna
    if ($MaxWidth == 0) {
        $MaxWidth = $OrigWidth;
    }
    if ($MaxHeight == 0) {
        $MaxHeight = $OrigHeight;
    }
    //nyni vypocitam pomer zmenseni
    $pw = $OrigWidth / $MaxWidth;
    $ph = $OrigHeight / $MaxHeight;
    if ($pw > $ph) {
        $p = $pw;
    } else {
        $p = $ph;
    }
    if ($p < 1) {
        $p = 1;
    }
    //v p ted mame pomer pro zmenseni vypocitame vysku a sirku zmenseneho obrazku
    $NewWidth = (int) $OrigWidth / $p;
    $NewHeight = (int) $OrigHeight / $p;
    //vytvorime novy obrazek pozadovane vysky a sirky
    $image_p = imagecreatetruecolor($NewWidth, $NewHeight);
    //otevreme puvodni obrazek se souboru
    $image = imagecreatefromjpeg($filename);
    //a okopirujeme zmenseny puvodni obrazek do noveho
    imagecopyresampled($image_p, $image, 0, 0, 0, 0, $NewWidth, $NewHeight, $OrigWidth, $OrigHeight);
    //a ulozime
    imagejpeg($image_p, $copypath, 100);
}
开发者ID:GE3,项目名称:GE3,代码行数:35,代码来源:galerie.php


示例11: render

 /**
  * Render the gradient to an image
  **/
 public function render($width, $height, $format = 'png', $filename = null)
 {
     $image = $this->render_gd($width, $height);
     switch ($format) {
         case 'jpg':
         case 'jpeg':
         case 'jpe':
             if (empty($filename)) {
                 header('Content-Type: image/jpeg');
             }
             imagejpeg($image, $filename, 90);
             break;
         case 'gif':
             if (empty($filename)) {
                 header('Content-Type: image/gif');
             }
             imagegif($image, $filename);
             break;
         case 'png':
         default:
             if (empty($filename)) {
                 header('Content-Type: image/png');
             }
             imagepng($image, $filename, 9);
             break;
     }
     imagedestroy($image);
 }
开发者ID:Pesulap,项目名称:php-utils,代码行数:31,代码来源:linear-gradient.php


示例12: resizeThumbnailImage

 function resizeThumbnailImage($thumb, $image, $width, $height, $start_width, $start_height, $scale)
 {
     $newImageWidth = ceil($width * $scale);
     $newImageHeight = ceil($height * $scale);
     $newImage = imagecreatetruecolor($newImageWidth, $newImageHeight);
     $ext = strtolower(substr(basename($image), strrpos(basename($image), '.') + 1));
     $source = '';
     if ($ext == 'png') {
         $source = imagecreatefrompng($image);
     } elseif ($ext == 'jpg' || $ext == 'jpeg') {
         $source = imagecreatefromjpeg($image);
     } elseif ($ext == 'gif') {
         $source = imagecreatefromgif($image);
     }
     imagecopyresampled($newImage, $source, 0, 0, $start_width, $start_height, $newImageWidth, $newImageHeight, $width, $height);
     $ext = strtolower(substr(basename($thumb), strrpos(basename($thumb), '.') + 1));
     if ($ext == 'png') {
         $result = imagepng($newImage, $thumb, 0);
     } elseif ($ext == 'jpg' || $ext == 'jpeg') {
         $result = imagejpeg($newImage, $thumb, 90);
     } elseif ($ext == 'gif') {
         $result = imagegif($newImage, $thumb);
     }
     if (!$result) {
         return false;
     }
     chmod($thumb, 0664);
     return $thumb;
 }
开发者ID:roboshed,项目名称:Zuluru,代码行数:29,代码来源:image_crop.php


示例13: convertImage

function convertImage($originalImage, $outputImage, $quality = 100)
{
    $myfile = fopen($outputImage, "w");
    // jpg, png, gif or bmp?
    $exploded = explode('.', $originalImage);
    $ext = $exploded[count($exploded) - 1];
    if (preg_match('/jpg|jpeg/i', $ext)) {
        $imageTmp = imagecreatefromjpeg($originalImage);
    } else {
        if (preg_match('/png/i', $ext)) {
            $imageTmp = imagecreatefrompng($originalImage);
        } else {
            if (preg_match('/gif/i', $ext)) {
                $imageTmp = imagecreatefromgif($originalImage);
            } else {
                if (preg_match('/bmp/i', $ext)) {
                    $imageTmp = imagecreatefrombmp($originalImage);
                } else {
                    return 0;
                }
            }
        }
    }
    imagejpeg($imageTmp, $outputImage, $quality);
    imagedestroy($imageTmp);
    return $outputImage;
}
开发者ID:princeraju,项目名称:compare_images,代码行数:27,代码来源:check_similar.php


示例14: captcha

function captcha($width, $height, $code)
{
    $font = "./font/ChalkboardBold.ttf";
    $font_size = 17;
    $image = imagecreate($width, $height);
    $background_color = imagecolorallocate($image, 255, 255, 255);
    $text_color = imagecolorallocate($image, 20, 40, 100);
    $noise_color = imagecolorallocate($image, 100, 120, 180);
    for ($i = 0; $i < $width * $height / 3; $i++) {
        imagefilledellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);
    }
    for ($i = 0; $i < $width * $height / 150; $i++) {
        imageline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $noise_color);
    }
    $x = 3;
    $y = 20;
    imagettftext($image, $font_size, rand(-45, 45), $x, $y + rand() % 16, $text_color, $font, $code[0]);
    imagettftext($image, $font_size, rand(-45, 45), $x + 23, $y + rand() % 16, $text_color, $font, $code[1]);
    imagettftext($image, $font_size, rand(-45, 45), $x + 46, $y + rand() % 16, $text_color, $font, $code[2]);
    imagettftext($image, $font_size, rand(-45, 45), $x + 69, $y + rand() % 16, $text_color, $font, $code[3]);
    imagettftext($image, $font_size, rand(-45, 45), $x + 92, $y + rand() % 16, $text_color, $font, $code[4]);
    imagettftext($image, $font_size, rand(-45, 45), $x + 115, $y + rand() % 16, $text_color, $font, $code[5]);
    header('Content-Type: image/jpeg');
    imagejpeg($image);
    imagedestroy($image);
}
开发者ID:brenoinojosa,项目名称:ragnarok-public,代码行数:26,代码来源:img.php


示例15: resize_image

function resize_image($pathToImages, $pathToThumbs, $thumbWidth)
{
    // open the directory
    $dir = opendir($pathToImages);
    // loop through it, looking for any/all JPG files:
    while (false !== ($fname = readdir($dir))) {
        // parse path for the extension
        $info = pathinfo($pathToImages . $fname);
        // continue only if this is a JPEG image
        if (strtolower($info['extension']) == 'jpg' && $fname != "thumb.jpg") {
            // load image and get image size
            $img = imagecreatefromjpeg("{$pathToImages}" . "/" . "{$fname}");
            $width = imagesx($img);
            $height = imagesy($img);
            // calculate thumbnail size
            $new_width = $thumbWidth;
            $new_height = floor($height * ($thumbWidth / $width));
            // create a new temporary image
            $tmp_img = imagecreatetruecolor($new_width, $new_height);
            // copy and resize old image into new image
            imagecopyresized($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
            // save thumbnail into a file
            imagejpeg($tmp_img, "{$pathToThumbs}" . "/" . "{$fname}");
            echo "Se redujo la imagen  {$fname} <br />";
            //echo "$pathToThumbs" . "/" . "$fname<br/>";
        }
    }
    // close the directory
    closedir($dir);
}
开发者ID:tineo,项目名称:webapoyopublicitario,代码行数:30,代码来源:index.php


示例16: resize

function resize($photo_src, $width, $name)
{
    $parametr = getimagesize($photo_src);
    list($width_orig, $height_orig) = getimagesize($photo_src);
    $ratio_orig = $width_orig / $height_orig;
    $new_width = $width;
    $new_height = $width / $ratio_orig;
    $newpic = imagecreatetruecolor($new_width, $new_height);
    $col2 = imagecolorallocate($newpic, 255, 255, 255);
    imagefilledrectangle($newpic, 0, 0, $new_width, $new_width, $col2);
    switch ($parametr[2]) {
        case 1:
            $image = imagecreatefromgif($photo_src);
            break;
        case 2:
            $image = imagecreatefromjpeg($photo_src);
            break;
        case 3:
            $image = imagecreatefrompng($photo_src);
            break;
    }
    imagecopyresampled($newpic, $image, 0, 0, 0, 0, $new_width, $new_height, $width_orig, $height_orig);
    imagejpeg($newpic, $name, 100);
    return true;
}
开发者ID:pioytazsko,项目名称:garantmarket,代码行数:25,代码来源:new_item.php


示例17: saveImage

 /**
  * Save the image as the image type the original image was
  *
  * @param  String[type] $savePath     - The path to store the new image
  * @param  string $imageQuality 	  - The qulaity level of image to create
  *
  * @return Saves the image
  */
 public function saveImage($savePath, $imageQuality = "100", $download = false)
 {
     switch ($this->ext) {
         case 'image/jpg':
         case 'image/jpeg':
             // Check PHP supports this file type
             if (imagetypes() & IMG_JPG) {
                 imagejpeg($this->newImage, $savePath, $imageQuality);
             }
             break;
         case 'image/gif':
             // Check PHP supports this file type
             if (imagetypes() & IMG_GIF) {
                 imagegif($this->newImage, $savePath);
             }
             break;
         case 'image/png':
             $invertScaleQuality = 9 - round($imageQuality / 100 * 9);
             // Check PHP supports this file type
             if (imagetypes() & IMG_PNG) {
                 imagepng($this->newImage, $savePath, $invertScaleQuality);
             }
             break;
     }
     if ($download) {
         header('Content-Description: File Transfer');
         header("Content-type: application/octet-stream");
         header("Content-disposition: attachment; filename= " . $savePath . "");
         readfile($savePath);
     }
     imagedestroy($this->newImage);
 }
开发者ID:swarajjena,项目名称:hackathon,代码行数:40,代码来源:Resize_image.php


示例18: saveinfo

 function saveinfo()
 {
     $juser =& JFactory::getUser();
     if ($juser->guest) {
         $error = 'Bạn phải đăng nhập để thực hiện chức năng này';
         $this->setError($error);
         return false;
     }
     $post = JRequest::get('post');
     $data = array();
     $data['user_id'] = $juser->id;
     $data['couple_name'] = $post['couple_name'];
     $data['address'] = $post['address'];
     $data['country'] = $post['country'];
     if (isset($_FILES['avatar']) && $_FILES['avatar']['error'] == 0) {
         require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'thumb.php';
         $p = manThumb::resize($_FILES['avatar']['tmp_name'], 96, 96);
         $name = 'avatar_' . $juser->id . '.jpg';
         $file = JPATH_ROOT . DS . 'images' . DS . 'wedding' . DS . 'avatar' . DS . $name;
         imagejpeg($p, $file, 90);
         imagedestroy($p);
         $data['avatar'] = 'images/wedding/avatar/' . $name;
     }
     $row =& $this->getTable('users');
     if (!$row->bind($data)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     if (!$row->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     return true;
 }
开发者ID:ngxuanmui,项目名称:hanhphuc.vn,代码行数:34,代码来源:profile.php


示例19: index

 public function index()
 {
     ob_clean();
     $image_handle = imagecreatetruecolor(150, 60);
     $white = imagecolorallocate($image_handle, 255, 255, 255);
     $rndm = imagecolorallocate($image_handle, rand(64, 192), rand(64, 192), rand(64, 192));
     imagefill($image_handle, 0, 0, $white);
     $fontName = PUBLICPATH . "/fonts/elephant.ttf";
     $myX = 15;
     $myY = 30;
     $angle = 0;
     for ($x = 0; $x <= 100; $x++) {
         $myX = rand(1, 148);
         $myY = rand(1, 58);
         imageline($image_handle, $myX, $myY, $myX + rand(-5, 5), $myY + rand(-5, 5), $rndm);
     }
     $myCryptBase = tep_create_random_value(50, 'digits');
     $secure_image_hash_string = "";
     for ($x = 0; $x <= 4; $x++) {
         $dark = imagecolorallocate($image_handle, rand(5, 128), rand(5, 128), rand(5, 128));
         $capChar = substr($myCryptBase, rand(1, 35), 1);
         $secure_image_hash_string .= $capChar;
         $fs = rand(20, 26);
         $myX = 15 + ($x * 28 + rand(-5, 5));
         $myY = rand($fs + 2, 55);
         $angle = rand(-30, 30);
         ImageTTFText($image_handle, $fs, $angle, $myX, $myY, $dark, $fontName, $capChar);
     }
     $this->session->set_userdata('secure_image_hash_string', $secure_image_hash_string);
     header("Content-type: image/jpeg");
     imagejpeg($image_handle, "", 95);
     imagedestroy($image_handle);
     die;
 }
开发者ID:rongandat,项目名称:ookcart-project,代码行数:34,代码来源:secure_image.php


示例20: hacknrollify

function hacknrollify($picfilename)
{
    $logofilename = "logo.png";
    $logoPicPath = "logopics/" . $logofilename;
    $originalPicPath = "originalpics/" . $picfilename;
    $editedfilename = "hnr_" . $picfilename;
    $editedPicPath = "editedpics/" . $editedfilename;
    // read the original image from file
    $profilepic = imagecreatefromjpeg($originalPicPath);
    $profilepicWidth = imagesx($profilepic);
    $profilepicHeight = imagesy($profilepic);
    // create the black image overlay
    $blackoverlay = imagecreate($profilepicWidth, $profilepicHeight);
    imagecolorallocate($blackoverlay, 0, 0, 0);
    // then merge the black and profilepic
    imagecopymerge($profilepic, $blackoverlay, 0, 0, 0, 0, $profilepicWidth, $profilepicHeight, 50);
    imagedestroy($blackoverlay);
    // merge the resized logo
    $logo = resizeImage($logoPicPath, $profilepicWidth - 80, 999999);
    imageAlphaBlending($logo, false);
    imageSaveAlpha($logo, true);
    $logoWidth = imagesx($logo);
    $logoHeight = imagesy($logo);
    $verticalOffset = $profilepicHeight / 2 - $logoHeight / 2;
    $horizontalOffset = 40;
    imagecopyresampled($profilepic, $logo, $horizontalOffset, $verticalOffset, 0, 0, $logoWidth, $logoHeight, $logoWidth, $logoHeight);
    $mergeSuccess = imagejpeg($profilepic, $editedPicPath);
    if (!$mergeSuccess) {
        echo "Image merge failed!";
    }
    imagedestroy($profilepic);
    imagedestroy($logo);
    return $editedPicPath;
}
开发者ID:nicholaslum444,项目名称:HacknRollify,代码行数:34,代码来源:lib_hacknrollify.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP imagelayereffect函数代码示例发布时间:2022-05-15
下一篇:
PHP imageistruecolor函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap