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


PHP GetimageSize函数代码示例

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


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

示例1: 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

示例2: resize

function resize($image_tmp, $image_name, $width_size, $folder)
{
    $images = $image_tmp;
    $new_images = $image_name;
    $width = $width_size;
    $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, $folder . $new_images);
    ImageDestroy($images_orig);
    ImageDestroy($images_fin);
}
开发者ID:ideagital,项目名称:how2doo.com,代码行数:16,代码来源:action_faqs.php

示例3: subir_imagen

 protected function subir_imagen()
 {
     $imagen = $_FILES['logo']['name'];
     $directorio = "src/marcas_logo/";
     $fecha = date('d.m.Y_H.i.s');
     $nombre_archivo = "logo_" . $fecha;
     $i = strlen($imagen) - 1;
     $extension = '';
     while ($imagen[$i] != '.') {
         $extension = $imagen[$i] . $extension;
         $i--;
     }
     $nombre_archivo = $nombre_archivo . '.' . $extension;
     $new_images = $nombre_archivo;
     $images = $_FILES['logo']['tmp_name'];
     switch ($extension) {
         case "jpg":
         case "jpeg":
         case "JPG":
         case "JPEG":
             $thumb = ImageCreateFromJPEG($images);
             break;
         case "gif":
         case "GIF":
             $thumb = imagecreatefromgif($images);
             break;
         case "png":
         case "PNG":
             try {
                 $thumb = imagecreatefrompng($images);
             } catch (Exception $e) {
                 $this->resultado = -1;
                 exit;
             }
             break;
         default:
             $this->resultado = 2;
             exit;
             break;
     }
     copy($images, '../' . $directorio . $nombre_archivo);
     $width = 300;
     $size = GetimageSize($images);
     if ($size != 0) {
         $height = round($width * $size[1] / $size[0]);
         //$height = 150;
     }
     $newwidth = 150;
     $newheight = $height;
     $srcWidth = imagesx($thumb);
     $srcHeight = imagesy($thumb);
     $newImg = imagecreatetruecolor($width, $height);
     imagealphablending($newImg, false);
     imagesavealpha($newImg, true);
     $transparent = imagecolorallocatealpha($newImg, 255, 255, 255, 127);
     imagefilledrectangle($newImg, 0, 0, $width, $height, $transparent);
     imagecopyresampled($newImg, $thumb, 0, 0, 0, 0, $width, $height, $srcWidth, $srcHeight);
     imagepng($newImg, '../' . $directorio . $new_images);
     /*
                 imagealphablending($thumb, false);
                 imagesavealpha($thumb, true);  
                 imagealphablending($thumb, true);
                 /*$photoX = ImagesX($thumb);
                 $photoY = ImagesY($thumb);
                 $new_image = imagecreatetruecolor ( $width, $height );
                 imagecopyresampled($new_image, $thumb, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY);*/
     /*switch($extension){
           case "jpg": case "jpeg":
               ImageJPEG($new_image,'../'.$directorio.$new_images);
               break;
           case "gif":
               imagegif($new_image,'../'.$directorio.$new_images);
               break;
           case "png":
               echo "helo";
               imagepng ($new_image,'../'.$directorio.$new_images, 9);
               break;
           default:
               $this->resultado = 2;
               exit();
       }*/
     ImageDestroy($thumb);
     if (!is_dir('../' . $directorio)) {
         mkdir('../' . $directorio, 0777);
     }
     return mysqli_real_escape_string($this->sql_con, $directorio . $nombre_archivo);
 }
开发者ID:llanosCoder,项目名称:mybu,代码行数:87,代码来源:nueva_marca.php

示例4: array

<?php

if ($_FILES['file']['error'] > 0) {
    $erreur = "Erreur lors du transfert";
} else {
    $extensions_valides = array('jpg', 'jpeg', 'gif', 'png');
    //1. strrchr renvoie l'extension avec le point (« . »).
    //2. substr(chaine,1) ignore le premier caractère de chaine.
    //3. strtolower met l'extension en minuscules.
    $extension_upload = strtolower(substr(strrchr($_FILES['file']['name'], '.'), 1));
    if (!in_array($extension_upload, $extensions_valides)) {
        $erreur = "Unexpected file type";
        echo $erreur;
    } else {
        $width = 500;
        //*** Fix Width & Heigh (Autu caculate) ***//
        $size = GetimageSize($_FILES['file']['tmp_name']);
        $height = round($width * $size[1] / $size[0]);
        $images_orig = ImageCreateFromJPEG($_FILES['file']['tmp_name']);
        $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);
        $name = "../uploads/" . $_POST['title'] . "." . $extension_upload;
        ImageJPEG($images_fin, $name);
        header("location:../uploadImages.php");
    }
}
开发者ID:laiello,项目名称:site-web-php,代码行数:28,代码来源:upload.php

示例5: subir_imagen

 protected function subir_imagen()
 {
     $imagen = $_FILES['imagen']['name'];
     $directorio = "src/productos/";
     $fecha = date('d.m.Y_H.i.s');
     $nombre_archivo = "logo_" . $fecha;
     $i = strlen($imagen) - 1;
     $extension = '';
     while ($imagen[$i] != '.') {
         $extension = $imagen[$i] . $extension;
         $i--;
     }
     $nombre_archivo = $nombre_archivo . '.' . $extension;
     $new_images = $nombre_archivo;
     //
     $images = $_FILES["imagen"]["tmp_name"];
     copy($images, '../' . $directorio . $nombre_archivo);
     $width = 150;
     //*** Fix Width & Heigh (Autu caculate) ***//
     $size = GetimageSize($images);
     $height = round($width * $size[1] / $size[0]);
     switch ($extension) {
         case "jpg":
         case "jpeg":
         case "JPG":
         case "JPEG":
             $images_orig = ImageCreateFromJPEG($images);
             break;
         case "gif":
         case "GIF":
             $images_orig = imagecreatefromgif($images);
             break;
         case "png":
         case "PNG":
             $images_orig = imagecreatefrompng($images);
             break;
         default:
             $this->resultado = 2;
             exit;
     }
     $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, '../' . $directorio . $new_images);
     ImageDestroy($images_orig);
     //ImageDestroy($images_fin);
     //
     if (!is_dir('../' . $directorio)) {
         mkdir('../' . $directorio, 0777);
     }
     /*if ($imagen && move_uploaded_file($images_fin,'../'.$directorio.$nombre_archivo))
       {
          $this->resultado = 1;
       }else{
           $this->resultado = 0;
       }*/
     return mysqli_real_escape_string($this->sql_con, $directorio . $nombre_archivo);
 }
开发者ID:llanosCoder,项目名称:mybu,代码行数:59,代码来源:nuevo_producto.php

示例6: jResize2

function jResize2($tmp, $name)
{
    copy($_FILES, "Photos/" . $_FILES["userfile"]["name"]);
    $width = 500;
    //*** Fix Width & Heigh (Autu caculate) ***//
    $size = GetimageSize($tmp);
    $height = round($width * $size[1] / $size[0]);
    $images_orig = ImageCreateFromJPEG($tmp);
    $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, "Photos/" . $name);
    ImageDestroy($images_orig);
    ImageDestroy($images_fin);
}
开发者ID:sharifov,项目名称:MyProcedureFramework,代码行数:16,代码来源:functions.php

示例7: count

 //count file
 $count = count($_FILES["file_"]["name"]);
 $title_rep = str_replace(" ", "", $en_title);
 for ($i = 1; $i < $count; $i++) {
     $file_name = $_FILES["file_"]["name"][$i];
     if ($file_name != "") {
         //file rename
         $f_name = explode(".", $file_name);
         $f_rename = $maxID . "_" . $i . "_" . $title_rep . "." . $f_name['1'];
         //Resize//
         $images = $_FILES["file_"]["tmp_name"][$i];
         $new_images = $f_rename;
         //copy($_FILES["file_"]["tmp_name"][$i],"file/resize1/".$_FILES["file_"]["name"][$i]); //size original
         $width = 500;
         //*** 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, "file/news/" . $new_images);
         //size thumbnails
         ImageDestroy($images_orig);
         ImageDestroy($images_fin);
         //Resize//
         //if(move_uploaded_file($_FILES["file_"]["tmp_name"][$i],"file/news/".$f_rename))
         //{
         $result_insert = mysqli_query($mysqli, "INSERT INTO w_news_file (id,news_id,name) VALUES (NULL, '{$maxID}','{$f_rename}')");
         //}
开发者ID:Nong-Surapon,项目名称:newspective,代码行数:31,代码来源:new-activities-add.php

示例8: array

    // 1以上の値
}
$height = 0;
// 指定しない場合は0 指定する場合は1以上の値
include_once '../../mainfile.php';
$photo_path = $_GET['photo'];
$photo_path = XOOPS_ROOT_PATH . $photo_path;
if (!isset($photo_path)) {
    return array(0, "イメージのパスが設定されていません。");
    exit;
}
if (!file_exists($photo_path)) {
    return array(0, "指定されたパスにファイルが見つかりません。");
    exit;
}
$size = @GetimageSize($photo_path);
$re_size = $size;
//アスペクト比固定処理
$tmp_width = $size[0] / $width;
if ($height != 0) {
    $tmp_height = $size[1] / $height;
}
if ($tmp_width > 1 || $tmp_height > 1) {
    if ($height == 0) {
        if ($tmp_width > 1) {
            $re_size[0] = $width;
            $re_size[1] = $size[1] * $width / $size[0];
        }
    } else {
        if ($tmp_width > $tmp_height) {
            $re_size[0] = $width;
开发者ID:BackupTheBerlios,项目名称:peakxoops-svn,代码行数:31,代码来源:gdthumb.php

示例9: _upload_Image

function _upload_Image($directory, $input_name, $max_size, $setW_H, $setThumbnail)
{
    $array = array();
    $index = 0;
    if ($_FILES) {
        $img_name = $_FILES[$input_name]['name'];
        $img_type = $_FILES[$input_name]['type'];
        $img_size = $_FILES[$input_name]['size'];
        $img_tmp = $_FILES[$input_name]['tmp_name'];
        if (is_array($img_tmp)) {
            if (file_exists($directory)) {
                for ($i = 0; $i < count($img_name); $i++) {
                    if ($img_type[$i] == "image/jpeg" || $img_type[$i] == "image/png" || $img_type[$i] == "image/gif") {
                        if ($max_size > $img_size[$i] / 1024) {
                            $img_W = getimagesize($img_tmp[$i]);
                            if ($setW_H < $img_W[0] && $setW_H < $img_W[0]) {
                                if (!file_exists($directory . $img_name[$i])) {
                                    $nameRandom = set_namefileUpload($img_name[$i], "Img-");
                                    $content = $directory . $nameRandom;
                                    if (copy($img_tmp[$i], $content)) {
                                        $images = $img_tmp[$i];
                                        if (!file_exists($directory . "thumbnail/")) {
                                            mkdir($directory . "thumbnail");
                                        }
                                        $new_images = $directory . "thumbnail/" . "thumbnails_" . $nameRandom;
                                        $width = $setThumbnail;
                                        //*** Fix Width & Heigh (Autu caculate) ** */
                                        $size = GetimageSize($images);
                                        $height = round($width * $size[1] / $size[0]);
                                        if (ereg("(gif)\$", $img_name[$i])) {
                                            $images_orig = imagecreatefromgif($images);
                                        } elseif (ereg("(png)\$", $img_name[$i])) {
                                            $images_orig = imagecreatefrompng($images);
                                        } else {
                                            $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);
                                        if (ereg("(gif)\$", $img_name[$i])) {
                                            imageGIF($images_fin, $new_images);
                                        } elseif (ereg("(png)\$", $img_name[$i])) {
                                            imagePNG($images_fin, $new_images);
                                        } else {
                                            ImageJPEG($images_fin, $new_images);
                                        }
                                        ImageDestroy($images_orig);
                                        ImageDestroy($images_fin);
                                        $array['data'][$index] = $nameRandom;
                                        $array['sucess'] .= "คัดลอกไฟล์ {$img_name[$i]} สำเร็จ !<br />";
                                        $index++;
                                    } else {
                                        $array['error'] .= "คัดลอกไฟล์ {$img_name[$i]} ไม่สำเร็จ !<br />";
                                    }
                                } else {
                                    $array['error'] .= "มีชื่อไฟล์ {$img_name[$i]} แล้ว กรุณาเปลี่ยนชื่อ !<br />";
                                }
                            } else {
                                $array['error'] .= "ไฟล์ {$img_name[$i]} มีขนาดความกว้างความสูงน้อยเกินไป !<br />";
                            }
                        } else {
                            $array['error'] .= "ไฟล์ {$img_name[$i]} มีขนาดมากกว่า {$max_size} KB !<br />";
                        }
                    } else {
                        $array['error'] .= "ระบบไม่รองรับกับไฟล์ {$img_name[$i]} นี้ !<br />";
                    }
                }
            } else {
                if (mkdir($directory)) {
                    for ($i = 0; $i < count($img_name); $i++) {
                        if ($img_type[$i] == "image/jpeg" || $img_type[$i] == "image/png" || $img_type[$i] == "image/gif") {
                            if ($max_size > $img_size[$i] / 1024) {
                                $img_W = getimagesize($img_tmp[$i]);
                                if ($setW_H < $img_W[0] && $setW_H < $img_W[0]) {
                                    if (!file_exists($directory . $img_name[$i])) {
                                        $nameRandom = set_namefileUpload($img_name[$i], "Img-");
                                        $content = $directory . $nameRandom;
                                        if (copy($img_tmp[$i], $content)) {
                                            $images = $img_tmp[$i];
                                            if (!file_exists($directory . "thumbnail/")) {
                                                mkdir($directory . "thumbnail");
                                            }
                                            $new_images = $directory . "thumbnail/" . "thumbnails_" . $nameRandom;
                                            $width = $setThumbnail;
                                            //*** Fix Width & Heigh (Autu caculate) ** */
                                            $size = GetimageSize($images);
                                            $height = round($width * $size[1] / $size[0]);
                                            if (ereg("(gif)\$", $img_name[$i])) {
                                                $images_orig = imagecreatefromgif($images);
                                            } elseif (ereg("(png)\$", $img_name[$i])) {
                                                $images_orig = imagecreatefrompng($images);
                                            } else {
                                                $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);
                                            if (ereg("(gif)\$", $img_name[$i])) {
//.........这里部分代码省略.........
开发者ID:wanchalerm15,项目名称:Project_2,代码行数:101,代码来源:php_function.php

示例10: save_image_picture

        function save_image_picture($file_pic, $num_file) {
            $rename_file_pic = '';
            $return_file = '';
            if (!empty($file_pic)) {
                $type_file_pic = explode(".", $file_pic);
                $end_file_pic = end($type_file_pic);
                if ($end_file_pic == "png" || $end_file_pic == "jpeg" || $end_file_pic == "gif" || $end_file_pic == "jpg") {
                    $rename_file_pic = rename_files('3') + 1;
//                    copy($_FILES['pic' . $num_file]['tmp_name'], 'new_files_images/' . $rename_file_pic . "." . $end_file_pic);
                    $width = 100; //*** Fix Width & Heigh (Autu caculate) ***//
                    $size = GetimageSize($_FILES['pic' . $num_file]['tmp_name']);
                    $height = round($width * $size[1] / $size[0]);
                    $images_orig = ImageCreateFromJPEG($_FILES['pic' . $num_file]['tmp_name']);
                    $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, "new_files_images/" . $rename_file_pic . "." . $end_file_pic); 
                    ImageJPEG($images_fin, "new_files_images/" . $rename_file_pic . "." . $end_file_pic);
                    ImageDestroy($images_orig);
                    ImageDestroy($images_fin);
                    update_num_max($rename_file_pic, '3');
                }
                $return_file = $rename_file_pic . "." . $end_file_pic;
            }
            return $return_file;
        }
开发者ID:HarmonySoftwareSE499,项目名称:VCS_SE499,代码行数:27,代码来源:new_course_structure_add.php

示例11: Main

 function Main($path, $width, $height, $dst_file, $header = false)
 {
     if (!isset($path)) {
         return array(0, "イメージのパスが設定されていません。");
     }
     if (!file_exists($path)) {
         return array(0, "指定されたパスにファイルが見つかりません。");
     }
     // 画像の大きさをセット
     if ($width) {
         $this->imgMaxWidth = $width;
     }
     if ($height) {
         $this->imgMaxHeight = $height;
     }
     $size = @GetimageSize($path);
     $re_size = $size;
     //アスペクト比固定処理
     if ($this->imgMaxWidth != 0) {
         $tmp_w = $size[0] / $this->imgMaxWidth;
     }
     if ($this->imgMaxHeight != 0) {
         $tmp_h = $size[1] / $this->imgMaxHeight;
     }
     if ($tmp_w > 1 || $tmp_h > 1) {
         if ($this->imgMaxHeight == 0) {
             if ($tmp_w > 1) {
                 $re_size[0] = $this->imgMaxWidth;
                 $re_size[1] = $size[1] * $this->imgMaxWidth / $size[0];
             }
         } else {
             if ($tmp_w > $tmp_h) {
                 $re_size[0] = $this->imgMaxWidth;
                 $re_size[1] = $size[1] * $this->imgMaxWidth / $size[0];
             } else {
                 $re_size[1] = $this->imgMaxHeight;
                 $re_size[0] = $size[0] * $this->imgMaxHeight / $size[1];
             }
         }
     }
     $imagecreate = function_exists("imagecreatetruecolor") ? "imagecreatetruecolor" : "imagecreate";
     $imageresize = function_exists("imagecopyresampled") ? "imagecopyresampled" : "imagecopyresized";
     switch ($size[2]) {
         // gif形式
         case "1":
             if (function_exists("imagecreatefromgif")) {
                 $src_im = imagecreatefromgif($path);
                 $dst_im = $imagecreate($re_size[0], $re_size[1]);
                 $transparent = imagecolortransparent($src_im);
                 $colorstotal = imagecolorstotal($src_im);
                 $dst_im = imagecreate($re_size[0], $re_size[1]);
                 if (0 <= $transparent && $transparent < $colorstotal) {
                     imagepalettecopy($dst_im, $src_im);
                     imagefill($dst_im, 0, 0, $transparent);
                     imagecolortransparent($dst_im, $transparent);
                 }
                 $imageresize($dst_im, $src_im, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]);
                 if (function_exists("imagegif")) {
                     // 画像出力
                     if ($header) {
                         header("Content-Type: image/gif");
                         imagegif($dst_im);
                         return "";
                     } else {
                         $dst_file = $dst_file . ".gif";
                         if ($re_size[0] == $size[0] && $re_size[1] == $size[1]) {
                             // サイズが同じ場合には、そのままコピーする。(画質劣化を防ぐ)
                             copy($path, $dst_file);
                         } else {
                             imagegif($dst_im, $dst_file);
                         }
                     }
                     imagedestroy($src_im);
                     imagedestroy($dst_im);
                 } else {
                     // 画像出力
                     if ($header) {
                         header("Content-Type: image/png");
                         imagepng($dst_im);
                         return "";
                     } else {
                         $dst_file = $dst_file . ".png";
                         if ($re_size[0] == $size[0] && $re_size[1] == $size[1]) {
                             // サイズが同じ場合には、そのままコピーする。(画質劣化を防ぐ)
                             copy($path, $dst_file);
                         } else {
                             imagepng($dst_im, $dst_file);
                         }
                     }
                     imagedestroy($src_im);
                     imagedestroy($dst_im);
                 }
             } else {
                 // サムネイル作成不可の場合(旧バージョン対策)
                 $dst_im = imageCreate($re_size[0], $re_size[1]);
                 imageColorAllocate($dst_im, 255, 255, 214);
                 //背景色
                 // 枠線と文字色の設定
                 $black = imageColorAllocate($dst_im, 0, 0, 0);
                 $red = imageColorAllocate($dst_im, 255, 0, 0);
//.........这里部分代码省略.........
开发者ID:casan,项目名称:eccube-2_13,代码行数:101,代码来源:gdthumb.php

示例12: houseImgUpload

 public function houseImgUpload($hid, $file)
 {
     $filename = $file['name'];
     $type = $file['type'];
     $source = $file['tmp_name'];
     $typename = explode("/", $type);
     $accepted_types = array('jpeg', 'png', 'gif', 'jpg');
     $temp_path = 'img_temp';
     if (is_dir($temp_path)) {
         chmod($temp_path, 0777);
     } else {
         mkdir($temp_path, 0777);
     }
     foreach ($accepted_types as $mime_type) {
         if ($mime_type == $typename[1]) {
             $status = 'OK';
             break;
         }
     }
     if ($status == 'OK') {
         //start resize
         $width = 600;
         $size = GetimageSize($source);
         $height = round($width * $size[1] / $size[0]);
         switch ($typename[1]) {
             case 'jpg':
                 $image = imagecreatefromjpeg($source);
                 break;
             case 'jpeg':
                 $image = imagecreatefromjpeg($source);
                 break;
             case 'png':
                 $image = imagecreatefrompng($source);
                 break;
             case 'gif':
                 $image = imagecreatefromgif($source);
                 break;
             default:
                 $image = imagecreatefromjpeg($source);
         }
         $x = imagesx($image);
         $y = imagesy($image);
         $imgfin = ImageCreateTrueColor($width, $height);
         ImageCopyResampled($imgfin, $image, 0, 0, 0, 0, $width + 1, $height + 1, $x, $y);
         ImageJPEG($imgfin, "img_temp/" . $hid . '_' . $filename);
         //end resize
         //start read image
         $img_temp = "img_temp/" . $hid . '_' . $filename;
         //
         $of = fopen($img_temp, 'r');
         $rb = fread($of, filesize($img_temp));
         fclose($of);
         $img = addslashes($rb);
         //end read image
         $sql = "update house set housepic='{$img}',dateupdate=DATE_FORMAT(NOW(),'%Y-%m-%d %H:%i:%s') where hcode='{$hid}'";
         $upload = $this->conn->prepare($sql);
         $upload->execute();
         unlink($img_temp);
         return 'OK';
     } else {
         return 'NOT';
     }
 }
开发者ID:kukks205,项目名称:jhhc,代码行数:63,代码来源:ImgClass.php

示例13: subir_imagen

 protected function subir_imagen()
 {
     $imagen = $_FILES['imagen']['name'];
     $directorio = "../src/avatar_usuarios/";
     $fecha = date('d.m.Y_H.i.s');
     $nombre_archivo = "avatar" . $fecha;
     $i = strlen($imagen) - 1;
     $extension = '';
     while ($imagen[$i] != '.') {
         $extension = $imagen[$i] . $extension;
         $i--;
     }
     $nombre_archivo = $nombre_archivo . '.' . $extension;
     $new_images = $nombre_archivo;
     //
     $images = $_FILES["imagen"]["tmp_name"];
     switch ($extension) {
         case "jpg":
         case "jpeg":
             $images_orig = ImageCreateFromJPEG($images);
             break;
         case "gif":
             $images_orig = imagecreatefromgif($images);
             break;
         case "png":
             $images_orig = imagecreatefrompng($images);
             break;
         default:
             $this->datos["respuesta"] = 7;
             exit;
             break;
     }
     copy($images, $directorio . $nombre_archivo);
     $width = 300;
     //*** Fix Width & Heigh (Autu caculate) ***//
     $size = GetimageSize($images);
     $height = round($width * $size[1] / $size[0]);
     $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, $directorio . $new_images);
     ImageDestroy($images_orig);
     //ImageDestroy($images_fin);
     //
     if (!is_dir($directorio)) {
         mkdir($directorio, 0777);
     }
     return mysqli_real_escape_string($this->sql_con, $directorio . $nombre_archivo);
 }
开发者ID:llanosCoder,项目名称:mybu,代码行数:50,代码来源:perfil.php

示例14: fread

        $imgtype = $rowData2['ProfileType'];
        $imgfile = "Profile/{$rowData2['ProfilePic']}";
        $imgname = $rowData2['ProfilePic'];
        if ($imgtype == NULL) {
            $imgtype = 'image/jpeg';
            $imgfile = "Profile2/thumbnails_profilePic.jpg";
            $imgname = "profilePic.jpg";
            $imgbinary = fread(fopen($imgfile, "r"), filesize($imgfile));
            echo "<img src='data:image/{$imgtype};base64," . base64_encode($imgbinary) . "' '/>";
        } else {
            //http://stackoverflow.com/questions/9650572/resize-image-php
            $new_images = "thumbnails_" . $imgname;
            //copy($rowData2,"Photos/".$rowData2['MediaTitle']);
            $height = 105;
            //*** Fix Width & Heigh (Autu caculate) ***//
            $size = GetimageSize($imgfile);
            $width = round($height * $size[0] / $size[1]);
            $images_orig = ImageCreateFromJPEG($imgfile);
            $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, "Profile2/" . $new_images);
            $imgfile = "Profile2/" . $new_images;
            $imgbinary = fread(fopen($imgfile, "r"), filesize($imgfile));
            echo "<img src='data:image/{$imgtype};base64," . base64_encode($imgbinary) . "' '/>";
        }
        ImageDestroy($images_orig);
        ImageDestroy($images_fin);
    }
}
开发者ID:jumanahalasadi,项目名称:Questbook,代码行数:31,代码来源:requests.php

示例15: compressedFotoBeritaUmum

 public static function compressedFotoBeritaUmum($img)
 {
     $imageFileType = explode('.', $img);
     $imageFileType = $imageFileType[1];
     $targetFile = '../../../View/img/Upload/beritaUmum/' . $img;
     $tempImg = '../../../View/img/Upload/beritaUmum/_' . $img;
     $finalImg = 'http://localhost/SIMasjid/View/img/Upload/beritaUmum/_' . $img;
     if (file_exists($tempImg)) {
         unlink($tempImg);
     }
     if (!file_exists($tempImg)) {
         if (copy($targetFile, $tempImg)) {
             $size = GetimageSize($tempImg);
             $width = 1000;
             $height = round($width * $size[1] / $size[0]);
             if ($imageFileType == 'JPEG' || $imageFileType == 'jpeg' || $imageFileType == 'JPG' || $imageFileType == 'jpg') {
                 $images_orig = ImageCreateFromJPEG($tempImg);
             } else {
                 if ($imageFileType == 'PNG' || $imageFileType == 'png') {
                     $images_orig = imagecreatefrompng($tempImg);
                 } else {
                     if ($imageFileType == 'GIF' || $imageFileType == 'gif') {
                         $images_orig = imagecreatefromgif($tempImg);
                     } else {
                         if ($imageFileType == 'BMP' || $imageFileType == 'bmp') {
                             $images_orig = imagecreatefromwbmp($tempImg);
                         }
                     }
                 }
             }
             $photoX = ImagesX($images_orig);
             $photoY = ImagesY($images_orig);
             $images_fin = ImageCreateTrueColor($width, $height);
             if ($imageFileType == 'PNG' || $imageFileType == 'png') {
                 imagealphablending($images_fin, false);
                 imagesavealpha($images_fin, true);
                 $transparent = imagecolorallocatealpha($images_fin, 255, 255, 255, 127);
                 imagefilledrectangle($images_fin, 0, 0, $w, $h, $transparent);
             }
             ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width + 1, $height + 1, $photoX, $photoY);
             if ($imageFileType == 'JPEG' || $imageFileType == 'jpeg' || $imageFileType == 'JPG' || $imageFileType == 'jpg') {
                 ImageJPEG($images_fin, $tempImg);
             } else {
                 if ($imageFileType == 'PNG' || $imageFileType == 'png') {
                     imagepng($images_fin, $tempImg);
                 } else {
                     if ($imageFileType == 'GIF' || $imageFileType == 'gif') {
                         imagegif($images_fin, $tempImg);
                     } else {
                         if ($imageFileType == 'BMP' || $imageFileType == 'bmp') {
                             imagewbmp($images_fin, $tempImg);
                         }
                     }
                 }
             }
             ImageDestroy($images_orig);
             ImageDestroy($images_fin);
         } else {
             $finalImg = null;
         }
         unlink($targetFile);
     }
     return $finalImg;
 }
开发者ID:arifpujiadi,项目名称:SI-Masjid-Kota-Bandung,代码行数:64,代码来源:ImageHandler.php


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