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


PHP ImageCreateFromJPEG函数代码示例

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


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

示例1: src

 public function src($src, $ext = null)
 {
     if (!is_file($src)) {
         throw new FileNotFoundException($src);
     }
     $this->src = $src;
     if (!$ext) {
         $info = new \SplFileInfo($src);
         $this->ext = strtoupper($info->getExtension());
     } else {
         $this->ext = strtoupper($ext);
     }
     if (is_file($src) && ($this->ext == "JPG" or $this->ext == "JPEG")) {
         $this->image = ImageCreateFromJPEG($src);
     } else {
         if (is_file($src) && $this->ext == "PNG") {
             $this->image = ImageCreateFromPNG($src);
         } else {
             throw new FileNotFoundException($src);
         }
     }
     $this->input_width = imagesx($this->image);
     $this->input_height = imagesy($this->image);
     return $this;
 }
开发者ID:jilson-asis,项目名称:image-resize,代码行数:25,代码来源:ImageResizer.php

示例2: thumbnail

 function thumbnail($imgfile)
 {
     //detect image format
     //$this->img["format"]=ereg_replace(".*\.(.*)$","\\1",$imgfile);
     $this->img["format"] = preg_replace('/.*\\.(.*)$/', "\\1", $imgfile);
     $this->img["format"] = strtoupper($this->img["format"]);
     if ($this->img["format"] == "JPG" || $this->img["format"] == "JPEG") {
         //JPEG
         $this->img["format"] = "JPEG";
         $this->img["src"] = ImageCreateFromJPEG($imgfile);
     } elseif ($this->img["format"] == "PNG") {
         //PNG
         $this->img["format"] = "PNG";
         $this->img["src"] = ImageCreateFromPNG($imgfile);
     } elseif ($this->img["format"] == "GIF") {
         //GIF
         $this->img["format"] = "GIF";
         $this->img["src"] = ImageCreateFromGIF($imgfile);
     } elseif ($this->img["format"] == "WBMP") {
         //WBMP
         $this->img["format"] = "WBMP";
         $this->img["src"] = ImageCreateFromWBMP($imgfile);
     } else {
         //DEFAULT
         echo "Not Supported File";
         exit;
     }
     @($this->img["lebar"] = imagesx($this->img["src"]));
     @($this->img["tinggi"] = imagesy($this->img["src"]));
     //default quality jpeg
     $this->img["quality"] = 75;
 }
开发者ID:AntonioJoseMGonzalez,项目名称:Demo_Gallery,代码行数:32,代码来源:resize.php

示例3: ResizeImage

function ResizeImage($image_from, $image_to, $fitwidth = 200, $fitheight = 270, $quality = 75)
{
    $os = $originalsize = getimagesize($image_from);
    if ($originalsize[2] != 2 && $originalsize[2] != 3 && $originalsize[2] != 6 && ($originalsize[2] < 9 or $originalsize[2] > 12)) {
        return false;
    }
    if ($originalsize[0] > $fitwidth or $originalsize[1] > $fitheight) {
        $h = getimagesize($image_from);
        if ($h[0] / $fitwidth > $h[1] / $fitheight) {
            $fitheight = $h[1] * $fitwidth / $h[0];
        } else {
            $fitwidth = $h[0] * $fitheight / $h[1];
        }
        if ($os[2] == 2 or $os[2] >= 9 && $os[2] <= 12) {
            $i = ImageCreateFromJPEG($image_from);
        }
        $o = ImageCreateTrueColor($fitwidth, $fitheight);
        imagecopyresampled($o, $i, 0, 0, 0, 0, $fitwidth, $fitheight, $h[0], $h[1]);
        imagejpeg($o, $image_to, $quality);
        chmod($image_to, 0777);
        imagedestroy($o);
        imagedestroy($i);
        return 2;
    }
    if ($originalsize[0] <= $fitwidth && $originalsize[1] <= $fitheight) {
        $i = ImageCreateFromJPEG($image_from);
        imagejpeg($i, $image_to, $quality);
        chmod($image_to, 0777);
        return 1;
    }
}
开发者ID:progervlad,项目名称:utils,代码行数:31,代码来源:test.php

示例4: thumbnail

function thumbnail($PicPathIn, $PicPathOut, $PicFilenameIn, $PicFilenameOut, $neueHoehe, $Quality)
{
    // Bilddaten ermitteln
    $size = getimagesize("{$PicPathIn}" . "{$PicFilenameIn}");
    $breite = $size[0];
    $hoehe = $size[1];
    $neueBreite = intval($breite * $neueHoehe / $hoehe);
    if ($size[2] == 1) {
        // GIF
        $altesBild = ImageCreateFromGIF("{$PicPathIn}" . "{$PicFilenameIn}");
        $neuesBild = imageCreateTrueColor($neueBreite, $neueHoehe);
        imageCopyResized($neuesBild, $altesBild, 0, 0, 0, 0, $neueBreite, $neueHoehe, $breite, $hoehe);
        imageJPEG($neuesBild, "{$PicPathOut}" . "{$PicFilenameOut}", $Quality);
    }
    if ($size[2] == 2) {
        // JPG
        $altesBild = ImageCreateFromJPEG("{$PicPathIn}" . "{$PicFilenameIn}");
        $neuesBild = imageCreateTrueColor($neueBreite, $neueHoehe);
        imageCopyResized($neuesBild, $altesBild, 0, 0, 0, 0, $neueBreite, $neueHoehe, $breite, $hoehe);
        ImageJPEG($neuesBild, "{$PicPathOut}" . "{$PicFilenameOut}", $Quality);
    }
    if ($size[2] == 3) {
        // PNG
        $altesBild = ImageCreateFromPNG("{$PicPathIn}" . "{$PicFilenameIn}");
        $neuesBild = imageCreateTrueColor($neueBreite, $neueHoehe);
        imageCopyResized($neuesBild, $altesBild, 0, 0, 0, 0, $neueBreite, $neueHoehe, $breite, $hoehe);
        ImageJPEG($neuesBild, "{$PicPathOut}" . "{$PicFilenameOut}", $Quality);
    }
}
开发者ID:nchiapol,项目名称:ecamp,代码行数:29,代码来源:action_save_change_avatar.php

示例5: Resampling

function Resampling($tmp_name, $directorio, $name)
{
    // Indico el destino del directorio de la imagen
    $imagen_origen = ImageCreateFromJPEG($tmp_name);
    // Calculo el tamaño de la imagen original
    $tam_ancho = imagesx($imagen_origen);
    $tam_alto = imagesy($imagen_origen);
    //Calculo la medida que va a tener
    if ($tam_ancho >= $tam_alto) {
        $ancho = 38;
        $alto = 38 * $tam_alto / $tam_ancho;
    } else {
        $ancho = 38 * $tam_ancho / $tam_alto;
        $alto = 38;
    }
    //Creo una imagen
    $imagen_destino = ImageCreateTrueColor($ancho, $alto);
    //Resize
    imagecopyresized($imagen_destino, $imagen_origen, 0, 0, 0, 0, $ancho, $alto, $tam_ancho, $tam_alto);
    $nombre_destino = $directorio . $name;
    //Genero Copia Destino
    ImageJPEG($imagen_destino, $nombre_destino, 100);
    //Borro imagen virtual
    ImageDestroy($imagen_destino);
}
开发者ID:eulisesquidel,项目名称:elviajero,代码行数:25,代码来源:modificar.php

示例6: ImageManipulation

 /**
  * Contructor method. Will create a new image from the target file.
  * Accepts an image filename as a string. Method also works out how
  * big the image is and stores this in the $image array.
  *
  * @param string $imgFile The image filename.
  */
 public function ImageManipulation($imgfile)
 {
     //detect image format
     $this->image["format"] = strtolower(substr(strrchr($imgfile, '.'), 1));
     $this->image["format"] = strtoupper($this->image["format"]);
     // convert image into usable format.
     if ($this->image["format"] == "JPG" || $this->image["format"] == "JPEG") {
         //JPEG
         $this->image["format"] = "JPEG";
         $this->image["src"] = ImageCreateFromJPEG($imgfile);
     } elseif ($this->image["format"] == "PNG") {
         //PNG
         $this->image["format"] = "PNG";
         $this->image["src"] = imagecreatefrompng($imgfile);
     } elseif ($this->image["format"] == "GIF") {
         //GIF
         $this->image["format"] = "GIF";
         $this->image["src"] = ImageCreateFromGif($imgfile);
     } elseif ($this->image["format"] == "WBMP") {
         //WBMP
         $this->image["format"] = "WBMP";
         $this->image["src"] = ImageCreateFromWBMP($imgfile);
     } else {
         //DEFAULT
         return false;
     }
     // Image is ok
     $this->imageok = true;
     // Work out image size
     $this->image["sizex"] = imagesx($this->image["src"]);
     $this->image["sizey"] = imagesy($this->image["src"]);
 }
开发者ID:superwow,项目名称:cms,代码行数:39,代码来源:img.manipulation.php

示例7: thumbnail

 function thumbnail($imgfile, $format = "image/jpeg")
 {
     //detect image format
     $pos = strpos($format, "/");
     $this->img["format"] = strtoupper(substr($format, $pos + 1));
     //$this->img["format"]=ereg_replace(".*\.(.*)$","\\1",$imgfile);
     //$this->img["format"]=strtoupper($this->img["format"]);
     if ($this->img["format"] == "JPG" || $this->img["format"] == "JPEG") {
         //JPEG
         $this->img["format"] = "JPEG";
         $this->img["src"] = ImageCreateFromJPEG($imgfile);
     } elseif ($this->img["format"] == "PNG") {
         //PNG
         $this->img["format"] = "PNG";
         $this->img["src"] = ImageCreateFromPNG($imgfile);
     } elseif ($this->img["format"] == "GIF") {
         //GIF
         $this->img["format"] = "GIF";
         $this->img["src"] = ImageCreateFromGIF($imgfile);
     } elseif ($this->img["format"] == "WBMP") {
         //WBMP
         $this->img["format"] = "WBMP";
         $this->img["src"] = ImageCreateFromWBMP($imgfile);
     } else {
         //DEFAULT
         echo "Not Supported File ";
         $this->is_img = false;
         return;
         //exit();
     }
     @($this->img["lebar"] = imagesx($this->img["src"]));
     @($this->img["tinggi"] = imagesy($this->img["src"]));
     //default quality jpeg
     $this->img["quality"] = 75;
 }
开发者ID:Rattatouille,项目名称:myaqa_test,代码行数:35,代码来源:resize.php

示例8: thumbnail

 private function thumbnail($imgfile)
 {
     //detect image format
     $this->acHWArr = getimagesize($imgfile);
     $this->img["format"] = ereg_replace(".*\\.(.*)\$", "\\1", $imgfile);
     $this->img["format"] = strtoupper($this->img["format"]);
     if ($this->img["format"] == "JPG" || $this->img["format"] == "JPEG") {
         //JPEG
         $this->img["format"] = "JPEG";
         $this->img["src"] = ImageCreateFromJPEG($imgfile);
     } elseif ($this->img["format"] == "PNG") {
         //PNG
         $this->img["format"] = "PNG";
         $this->img["src"] = ImageCreateFromPNG($imgfile);
     } elseif ($this->img["format"] == "GIF") {
         //GIF
         $this->img["format"] = "GIF";
         $this->img["src"] = ImageCreateFromGIF($imgfile);
     } elseif ($this->img["format"] == "WBMP") {
         //WBMP
         $this->img["format"] = "WBMP";
         $this->img["src"] = ImageCreateFromWBMP($imgfile);
     } else {
         //DEFAULT
         echo "Not Supported File <a href='" . $_SERVER[HTTP_REFERER] . "'>Back</a>";
         exit;
     }
     @($this->img["lebar"] = imagesx($this->img["src"]));
     @($this->img["tinggi"] = imagesy($this->img["src"]));
     //default quality jpeg
     $this->img["quality"] = 75;
 }
开发者ID:nstungxd,项目名称:F2CA5,代码行数:32,代码来源:class.imagecrop.php

示例9: open_image

 function open_image($file = null)
 {
     $image_type = $this->image_type($file);
     if (!$image_type) {
         trigger_error("Invalid image file: {$file}.", E_USER_ERROR);
     }
     $this->type = $image_type[0];
     $this->width = $image_type[1];
     $this->height = $image_type[2];
     if (!in_array($this->type, $this->supported_img_types)) {
         trigger_error("File type '{$this->type}' not supported.", E_USER_ERROR);
     }
     // Destroy if already open
     if ($this->image) {
         ImageDestroy($this->image);
     }
     switch ($this->type) {
         case 'JPG':
             $this->image = ImageCreateFromJPEG($file);
             break;
         case 'GIF':
             $this->image = ImageCreateFromGIF($file);
             break;
         case 'PNG':
             $this->image = ImageCreateFromPNG($file);
             break;
     }
 }
开发者ID:netdust,项目名称:ntdst-cms,代码行数:28,代码来源:Images.php

示例10: fixOrientation

 public function fixOrientation()
 {
     if (exif_imagetype($this->image) == 2) {
         $exif = exif_read_data($this->image);
         if (array_key_exists('Orientation', $exif)) {
             $orientation = $exif['Orientation'];
             $images_orig = ImageCreateFromJPEG($this->image);
             $rotate = "";
             switch ($orientation) {
                 case 3:
                     $rotate = imagerotate($images_orig, 180, 0);
                     break;
                 case 6:
                     $rotate = imagerotate($images_orig, -90, 0);
                     break;
                 case 8:
                     $rotate = imagerotate($images_orig, 90, 0);
                     break;
             }
             if ($rotate != "") {
                 ImageJPEG($rotate, $this->image);
                 ImageDestroy($rotate);
             }
             ImageDestroy($images_orig);
         }
     }
 }
开发者ID:HyuchiaDiego,项目名称:Kirino,代码行数:27,代码来源:Image.php

示例11: create_banner

 /**
  * Create the banners
  * @return jpeg
  */
 private function create_banner()
 {
     //Load image
     $rImg = ImageCreateFromJPEG($this->imgpath);
     //Define colours
     $textcolour1 = imagecolorallocate($rImg, $this->colour1['0'], $this->colour1['1'], $this->colour1['2']);
     $textcolour2 = imagecolorallocate($rImg, $this->colour2['0'], $this->colour2['1'], $this->colour2['2']);
     //Make text uppercase
     $text1 = strtoupper($this->banner_line1);
     $text2 = strtoupper($this->banner_line2);
     //Get string length
     $count1 = strlen($text1);
     $count2 = strlen($text2);
     //Select font size depending on string length
     $fsize1 = $this->fontsize($count1);
     $fsize2 = $this->fontsize($count2);
     //Center align the text
     $xalign1 = $this->aligntext($count1, $fsize1, $text1);
     $xalign2 = $this->aligntext($count2, $fsize2, $text2);
     // Adds text to image
     imagettftext($rImg, $fsize1, 0, $xalign1, $this->valign1, $textcolour1, $this->font, $text1);
     imagettftext($rImg, $fsize2, 0, $xalign2, $this->valign2, $textcolour2, $this->font, $text2);
     //Output image
     header('Content-type: image/jpeg');
     imagejpeg($rImg, NULL, 100);
     imagedestroy($rImg);
 }
开发者ID:suchm,项目名称:Banner-Generator,代码行数:31,代码来源:image.php

示例12: marcadeagua

function marcadeagua($img_original, $img_marcadeagua, $img_nueva, $calidad)
{
    // obtener datos de la fotografia
    $info_original = getimagesize($img_original);
    $anchura_original = $info_original[0];
    $altura_original = $info_original[1];
    // obtener datos de la "marca de agua"
    $info_marcadeagua = getimagesize($img_marcadeagua);
    $anchura_marcadeagua = $info_marcadeagua[0];
    $altura_marcadeagua = $info_marcadeagua[1];
    // calcular la posición donde debe copiarse la "marca de agua" en la fotografia
    /* 
    // Posicion: Centrado
    $horizmargen = ($anchura_original - $anchura_marcadeagua)/2; 
    $vertmargen = ($altura_original - $altura_marcadeagua)/2; 
    */
    // Posicion: abajo a la izquierda
    $horizmargen = 10;
    $vertmargen = $altura_original - $altura_marcadeagua - 10;
    // crear imagen desde el original
    $original = ImageCreateFromJPEG($img_original);
    ImageAlphaBlending($original, true);
    // crear nueva imagen desde la marca de agua
    $marcadeagua = ImageCreateFromPNG($img_marcadeagua);
    // copiar la "marca de agua" en la fotografia
    ImageCopy($original, $marcadeagua, $horizmargen, $vertmargen, 0, 0, $anchura_marcadeagua, $altura_marcadeagua);
    // guardar la nueva imagen
    ImageJPEG($original, $img_nueva, $calidad);
    // cerrar las imágenes
    ImageDestroy($original);
    ImageDestroy($marcadeagua);
}
开发者ID:jorgea3004,项目名称:GeneraGaleria,代码行数:32,代码来源:index.php

示例13: ImageManipulation

 /**
  * Contructor method. Will create a new image from the target file.
  * Accepts an image filename as a string. Method also works out how
  * big the image is and stores this in the $image array.
  *
  * @param string $imgFile The image filename.
  */
 public function ImageManipulation($imgfile)
 {
     //detect image format
     $this->image["format"] = preg_replace("/.*\\.(.*)\$/", "\\1", $imgfile);
     //$this->image["format"] = preg_replace(".*\.(.*)$", "\\1", $imgfile);
     $this->image["format"] = strtoupper($this->image["format"]);
     // convert image into usable format.
     if ($this->image["format"] == "JPG" || $this->image["format"] == "JPEG") {
         //JPEG
         $this->image["format"] = "JPEG";
         $this->image["src"] = ImageCreateFromJPEG($imgfile);
     } elseif ($this->image["format"] == "PNG") {
         //PNG
         $this->image["format"] = "PNG";
         $this->image["src"] = imagecreatefrompng($imgfile);
     } elseif ($this->image["format"] == "GIF") {
         //GIF
         $this->image["format"] = "GIF";
         $this->image["src"] = ImageCreateFromGif($imgfile);
     } elseif ($this->image["format"] == "WBMP") {
         //WBMP
         $this->image["format"] = "WBMP";
         $this->image["src"] = ImageCreateFromWBMP($imgfile);
     } else {
         //DEFAULT
         return false;
     }
     // Image is ok
     $this->imageok = true;
     // Work out image size
     $this->image["sizex"] = imagesx($this->image["src"]);
     $this->image["sizey"] = imagesy($this->image["src"]);
 }
开发者ID:ali-codehoppers,项目名称:adventskalender,代码行数:40,代码来源:ImageManipulation.php

示例14: thumbnail

 /** 
  * @private
  */
 function thumbnail($imgfile)
 {
     //detect image format
     $this->img["format"] = ereg_replace(".*\\.(.*)\$", "\\1", $imgfile);
     $this->img["format"] = strtoupper($this->img["format"]);
     if ($this->img["format"] == "JPG" || $this->img["format"] == "JPEG") {
         $this->img["format"] = "JPEG";
         $this->img["src"] = @ImageCreateFromJPEG($imgfile);
     } elseif ($this->img["format"] == "PNG") {
         $this->img["format"] = "PNG";
         $this->img["src"] = @ImageCreateFromPNG($imgfile);
     } elseif ($this->img["format"] == "GIF") {
         $this->img["format"] = "GIF";
         if (function_exists("imagecreatefromgif")) {
             $this->img["src"] = @ImageCreateFromGIF($imgfile);
         } else {
             return false;
         }
     } else {
         // not a recognized format
         throw new Exception("Trying to generate a thumbnail of an unsupported format!");
         //die();
     }
     // check for errors
     if (!$this->img["src"]) {
         return false;
     }
     // if no errors, continue
     @($this->img["lebar"] = imagesx($this->img["src"]));
     @($this->img["tinggi"] = imagesy($this->img["src"]));
     //default quality jpeg
     $this->img["quality"] = 85;
     return true;
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:37,代码来源:gallerygdresizer.class.php

示例15: update_picture

 public function update_picture()
 {
     if (trim($_FILES["myfile"]["tmp_name"]) != "") {
         $images = $_FILES["myfile"]["tmp_name"];
         $new_images = "thumb_" . $this->session->userdata('std_cardid') . '_' . $_FILES["myfile"]["name"];
         copy($_FILES["myfile"]["tmp_name"], "assets/uploads/photo/" . $_FILES["myfile"]["name"]);
         $width = 150;
         //*** Fix Width & Heigh (Autu caculate) ***//
         $size = GetimageSize($images);
         $height = round($width * $size[1] / $size[0]);
         $images_orig = ImageCreateFromJPEG($images);
         $photoX = ImagesX($images_orig);
         $photoY = ImagesY($images_orig);
         $images_fin = ImageCreateTrueColor($width, $height);
         ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width + 1, $height + 1, $photoX, $photoY);
         ImageJPEG($images_fin, "assets/uploads/photo/" . $new_images);
         ImageDestroy($images_orig);
         ImageDestroy($images_fin);
     }
     $fileName = $_FILES["myfile"]["name"];
     $ret[] = $fileName;
     $data_picture = array('std_picture' => $new_images);
     $this->Students_model->update_student_picture($this->session->userdata('std_cardid'), $data_picture);
     //echo  base_url()."assets/uploads/photo/".$new_images;
     redirect('/front_profiles/student_edit', 'refresh');
     //ChromePhp::log($ret);
     //exit;
 }
开发者ID:project2you,项目名称:student-attendance,代码行数:28,代码来源:front_profiles.php


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