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

PHP SimpleImage类代码示例

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

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



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

示例1: imageDualResize

 function imageDualResize($filename, $cleanFilename, $wtarget, $htarget)
 {
     if (!file_exists($cleanFilename)) {
         $dims = getimagesize($filename);
         $width = $dims[0];
         $height = $dims[1];
         while ($width > $wtarget || $height > $htarget) {
             if ($width > $wtarget) {
                 $percentage = $wtarget / $width;
             }
             if ($height > $htarget) {
                 $percentage = $htarget / $height;
             }
             /*if($width > $height)
             		{
             			$percentage = ($target / $width);
             		}
             		else
             		{
             			$percentage = ($target / $height);
             		}*/
             //gets the new value and applies the percentage, then rounds the value
             $width = round($width * $percentage);
             $height = round($height * $percentage);
         }
         $image = new SimpleImage();
         $image->load($filename);
         $image->resize($width, $height);
         $image->save($cleanFilename);
         $image = null;
     }
     //returns the new sizes in html image tag format...this is so you can plug this function inside an image tag and just get the
     return "src=\"{$baseurl}/{$cleanFilename}\"";
 }
开发者ID:dave7y,项目名称:thegamesdb,代码行数:34,代码来源:tab_platform-edit.php


示例2: upload_imagem_unica

function upload_imagem_unica($pasta_upload, $novo_tamanho_imagem, $novo_tamanho_imagem_miniatura, $host_retorno, $upload_miniatura)
{
    // data atual
    $data_atual = data_atual();
    // array com fotos
    $fotos = $_FILES['foto'];
    // extensoes de imagens disponiveis
    $extensoes_disponiveis[] = ".jpeg";
    $extensoes_disponiveis[] = ".jpg";
    $extensoes_disponiveis[] = ".png";
    $extensoes_disponiveis[] = ".gif";
    $extensoes_disponiveis[] = ".bmp";
    // nome imagem
    $nome_imagem = $fotos['tmp_name'];
    $nome_imagem_real = $fotos['name'];
    // dimensoes da imagem
    $image_info = getimagesize($_FILES["foto"]["tmp_name"]);
    $largura_imagem = $image_info[0];
    $altura_imagem = $image_info[1];
    // extencao
    $extensao_imagem = "." . strtolower(pathinfo($nome_imagem_real, PATHINFO_EXTENSION));
    // nome final de imagem
    $nome_imagem_final = md5($nome_imagem_real . $data_atual) . $extensao_imagem;
    $nome_imagem_final_miniatura = md5($nome_imagem_real . $data_atual . $data_atual) . $extensao_imagem;
    // endereco final de imagem
    $endereco_final_salvar_imagem = $pasta_upload . $nome_imagem_final;
    $endereco_final_salvar_imagem_miniatura = $pasta_upload . $nome_imagem_final_miniatura;
    // informa se a extensao de imagem e permitida
    $extensao_permitida = retorne_elemento_array_existe($extensoes_disponiveis, $extensao_imagem);
    // se nome for valido entao faz upload
    if ($nome_imagem != null and $nome_imagem_real != null and $extensao_permitida == true) {
        // upload de imagem normal
        $image = new SimpleImage();
        $image->load($nome_imagem);
        // aplica escala
        if ($largura_imagem > $novo_tamanho_imagem) {
            $image->resizeToWidth($novo_tamanho_imagem);
        }
        // salva a imagem grande
        $image->save($endereco_final_salvar_imagem);
        // upload de miniatura
        if ($upload_miniatura == true) {
            $image = new SimpleImage();
            $image->load($nome_imagem);
            // modo de redimencionar
            if ($largura_imagem > $novo_tamanho_imagem_miniatura) {
                $image->resizeToWidth($novo_tamanho_imagem_miniatura);
            }
            // salva a imagem em miniatura
            $image->save($endereco_final_salvar_imagem_miniatura);
        }
        // array de retorno
        $retorno['normal'] = $host_retorno . $nome_imagem_final;
        $retorno['miniatura'] = $host_retorno . $nome_imagem_final_miniatura;
        $retorno['normal_root'] = $endereco_final_salvar_imagem;
        $retorno['miniatura_root'] = $endereco_final_salvar_imagem_miniatura;
        // retorno
        return $retorno;
    }
}
开发者ID:xcution,项目名称:SitepressCMS,代码行数:60,代码来源:upload_imagem_unica.php


示例3: actionUpload

 /**
  * 上传图片
  */
 public function actionUpload()
 {
     $fn = $_GET['CKEditorFuncNum'];
     $url = WaveCommon::getCompleteUrl();
     $imgTypeArr = WaveCommon::getImageTypes();
     if (!in_array($_FILES['upload']['type'], $imgTypeArr)) {
         echo '<script type="text/javascript">
             window.parent.CKEDITOR.tools.callFunction("' . $fn . '","","图片格式错误!");
             </script>';
     } else {
         $projectPath = Wave::app()->projectPath;
         $uploadPath = $projectPath . 'data/uploadfile/substance';
         if (!is_dir($uploadPath)) {
             mkdir($uploadPath, 0777);
         }
         $ym = WaveCommon::getYearMonth();
         $uploadPath .= '/' . $ym;
         if (!is_dir($uploadPath)) {
             mkdir($uploadPath, 0777);
         }
         $imgType = strtolower(substr(strrchr($_FILES['upload']['name'], '.'), 1));
         $imageName = time() . '_' . rand() . '.' . $imgType;
         $file_abso = $url . '/data/uploadfile/substance/' . $ym . '/' . $imageName;
         $SimpleImage = new SimpleImage();
         $SimpleImage->load($_FILES['upload']['tmp_name']);
         $SimpleImage->resizeToWidth(800);
         $SimpleImage->save($uploadPath . '/' . $imageName);
         echo '<script type="text/javascript">
             window.parent.CKEDITOR.tools.callFunction("' . $fn . '","' . $file_abso . '","上传成功");
             </script>';
     }
 }
开发者ID:xpmozong,项目名称:wavephp2_demos,代码行数:35,代码来源:SubstanceController.php


示例4: uploadFile

 protected function uploadFile()
 {
     if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $this->path)) {
         $path = $this->path;
         if (!$this->db->query("INSERT photo (name,folder,time,status) \n\t\t\tVALUES ('" . $this->name . "','" . $this->folder . "','" . time() . "','temp')")) {
             die("error");
         }
         $id = $this->db->getLastId();
         $this->image->load($path);
         $full = new SimpleImage();
         $full->load($path);
         if ($full->getWidth() > 1200) {
             $full->resizeToWidth(1200);
         }
         $full->save(str_replace('.', '.full.', $path));
         if ($this->image->getWidth() > 600) {
             $this->image->resizeToWidth(600);
         }
         $this->image->save($path);
         $size = $this->f->getFullSize($path, 90, 90);
         $img = array('name' => $this->name, 'path' => $path, 'count' => $this->getNum(), 'width' => $size['width'], 'height' => $size['height'], 'id' => $id);
         echo json_encode($img);
     } else {
         echo "error";
     }
 }
开发者ID:Sywooch,项目名称:dump,代码行数:26,代码来源:upload.php


示例5: processScreenshots

function processScreenshots($gameID)
{
    ## Select all fanart rows for the requested game id
    $ssResult = mysql_query(" SELECT filename FROM banners WHERE keyvalue = {$gameID} AND keytype = 'screenshot' ORDER BY filename ASC ");
    ## Process each fanart row incrementally
    while ($ssRow = mysql_fetch_assoc($ssResult)) {
        ## Construct file names
        $ssOriginal = $ssRow['filename'];
        $ssThumb = "screenshots/thumb" . str_replace("screenshots", "", $ssRow['filename']);
        ## Check to see if the original fanart file actually exists before attempting to process
        if (file_exists("../banners/{$ssOriginal}")) {
            ## Check if thumb already exists
            if (!file_exists("../banners/{$ssThumb}")) {
                ## If thumb is non-existant then create it
                $image = new SimpleImage();
                $image->load("../banners/{$ssOriginal}");
                $image->resizeToWidth(300);
                $image->save("../banners/{$ssThumb}");
                //makeFanartThumb("../banners/$ssOriginal", "../banners/$ssThumb");
            }
            ## Get Fanart Image Dimensions
            list($image_width, $image_height, $image_type, $image_attr) = getimagesize("../banners/{$ssOriginal}");
            $ssWidth = $image_width;
            $ssHeight = $image_height;
            ## Output Fanart XML Branch
            print "<screenshot>\n";
            print "<original width=\"{$ssWidth}\" height=\"{$ssHeight}\">{$ssOriginal}</original>\n";
            print "<thumb>{$ssThumb}</thumb>\n";
            print "</screenshot>\n";
        }
    }
}
开发者ID:dave7y,项目名称:thegamesdb,代码行数:32,代码来源:GetArt.php


示例6: _generateThumbnail

 /**
  * Generates the thumbnail for a given file.
  */
 protected function _generateThumbnail()
 {
     $image = new SimpleImage();
     $image->load($this->source);
     $image->resizeToWidth(Configure::read('Image.width'));
     $image->save($this->thumb_path);
 }
开发者ID:johnulist,项目名称:Markab,代码行数:10,代码来源:thumbnail.php


示例7: insertImageSub

function insertImageSub($file, $sub_id, $menu_id)
{
    $error = false;
    $arr = explode('.', $file["name"]);
    $imageFileType = end($arr);
    if ($file["size"] > 5000000) {
        $error = true;
    }
    if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") {
        $error = true;
    }
    if (!$error) {
        $target_dir = "../images/menu_" . $menu_id . "/sub_" . $sub_id . "/";
        $target_file = $target_dir . $file["name"];
        //
        if (!file_exists($target_dir)) {
            mkdir($target_dir, 0777, true);
        }
        if (file_exists($target_file)) {
            unlink($target_file);
        }
        if (move_uploaded_file($file["tmp_name"], $target_file)) {
            include 'classSimpleImage.php';
            $image = new SimpleImage();
            $image->load($target_file);
            $image->resize(218, 138);
            $image->save($target_file);
            $arr = explode("../", $target_file);
            return end($arr);
        }
    } else {
        return false;
    }
}
开发者ID:DbyD,项目名称:cruk,代码行数:34,代码来源:upload_file.php


示例8: action_index

 public function action_index()
 {
     $tags = array();
     $imager = new SimpleImage();
     if ($this->request->param('path')) {
         // Берем новость
         $post = ORM::factory('blog')->where('url', '=', $this->request->param('path'))->find();
     } else {
         $post = ORM::factory('blog');
     }
     if ($_POST) {
         $post_name = Arr::get($_POST, 'post_name');
         $post_url = Arr::get($_POST, 'post_url');
         $short_text = Arr::get($_POST, 'short_text');
         $full_text = Arr::get($_POST, 'full_text');
         $tag = Arr::get($_POST, 'tag');
         // Загрузка изображения
         $image = $_FILES["imgupload"]["name"];
         if (!empty($image)) {
             $imager = new SimpleImage();
             //$this->news->deleteImage($post->id);
             //$image = $this->image->upload_image($image['tmp_name'], $image['name'], $this->config->news_images_dir."big/");
             move_uploaded_file($_FILES["imgupload"]["tmp_name"], "files/blog/" . $_FILES["imgupload"]["name"]);
             $imager->load("files/blog/" . $image);
             $imager->resize(200, 200);
             $imager->save("files/blog/miniatures/" . $image);
         }
         $post->set('name', $post_name)->set('url', $post_url)->set('date', DB::expr('now()'))->set('short_text', $short_text)->set('full_text', $full_text)->set('image', $image)->set('tag_id', ORM::factory('tags')->where('name', '=', $tag)->find())->save();
     }
     $tags = ORM::factory('tags')->find_all();
     $content = View::factory('/admin/post')->bind('tags', $tags)->bind('post', $post);
     $this->template->content = $content;
 }
开发者ID:helloween141,项目名称:MyBlog,代码行数:33,代码来源:Post.php


示例9: ImageResize

function ImageResize($file)
{
    $image = new SimpleImage();
    $image->load('traffic-images/temp/' . $file);
    $image->resize(300, 200);
    $image->save('traffic-images/' . $file);
    unlink("traffic-images/temp/" . $file);
}
开发者ID:tilak001,项目名称:Traffic-Police-System,代码行数:8,代码来源:change-image-size.inc.php


示例10: Load

 public function Load($pathToImage)
 {
     if (!extension_loaded('gd')) {
         die('gd extension is required for image upload');
     }
     $image = new SimpleImage();
     $image->load($pathToImage);
     return new Image($image);
 }
开发者ID:Trideon,项目名称:gigolo,代码行数:9,代码来源:ImageFactory.php


示例11: saveImageInFile

 public function saveImageInFile($file)
 {
     $t = $file['tmp_name'];
     $n = $file['name'];
     $path = App::get("uploads_dir_original") . DIRECTORY_SEPARATOR . $n;
     move_uploaded_file($t, $path);
     $image = new SimpleImage();
     $image->load($path);
     $image->resize(250, 250);
     $image->save(App::get("uploads_dir_small") . DIRECTORY_SEPARATOR . $n);
     return $n;
 }
开发者ID:romamolodyko,项目名称:gallery,代码行数:12,代码来源:UploadController.php


示例12: upload

 function upload()
 {
     if (!isset($_FILES['upload'])) {
         $this->directrender('S3/S3');
         return;
     }
     global $params;
     // Params to vars
     $client_id = '1b5cc674ae2f335';
     // Validations
     $this->startValidations();
     $this->validate($_FILES['upload']['error'] === 0, $err, 'upload error');
     $this->validate($_FILES['upload']['size'] <= 10 * 1024 * 1024, $err, 'size too large');
     // Code
     if ($this->isValid()) {
         $fname = $_FILES['upload']['tmp_name'];
         require_once $GLOBALS['dirpre'] . 'includes/S3/SimpleImage.php';
         $image = new SimpleImage();
         $this->validate($image->load($fname), $err, 'invalid image type');
         if ($this->isValid()) {
             if ($image->getHeight() > 1000) {
                 $image->resizeToHeight(1000);
             }
             $image->save($fname);
             function getMIME($fname)
             {
                 $finfo = finfo_open(FILEINFO_MIME_TYPE);
                 $mime = finfo_file($finfo, $fname);
                 finfo_close($finfo);
                 return $mime;
             }
             $filetype = explode('/', getMIME($fname));
             $valid_formats = array("jpg", "png", "gif", "jpeg");
             $this->validate($filetype[0] === 'image' and in_array($filetype[1], $valid_formats), $err, 'invalid image type');
             if ($this->isValid()) {
                 require_once $GLOBALS['dirpre'] . 'includes/S3/s3_config.php';
                 //Rename image name.
                 $actual_image_name = time() . "." . $filetype[1];
                 $this->validate($s3->putObjectFile($fname, $bucket, $actual_image_name, S3::ACL_PUBLIC_READ), $err, 'upload failed');
                 if ($this->isValid()) {
                     $reply = "https://{$bucket}.s3.amazonaws.com/{$actual_image_name}";
                     $this->success('image successfully uploaded');
                     $this->directrender('S3/S3', array('reply' => "up(\"{$reply}\");"));
                     return;
                 }
             }
         }
     }
     $this->error($err);
     $this->directrender('S3/S3');
 }
开发者ID:edwardshe,项目名称:sublite-1,代码行数:51,代码来源:S3Controller.php


示例13: uploadArquivo

    function uploadArquivo($campoFormulario, $idGravado) {
        $ext = pathinfo($_FILES[$campoFormulario][name], PATHINFO_EXTENSION);

        if (($_FILES[$campoFormulario][name] <> "") && ($_FILES[$campoFormulario][size]) > 0 && in_array(strtolower($ext), $this->extensions)) {
            $arquivoTmp = $_FILES[$campoFormulario]['tmp_name'];
            $nome = str_replace(".", "", microtime(true)) . "_" . $_FILES[$campoFormulario]['name'];

            if (function_exists("exif_imagetype")) {
                $test = exif_imagetype($arquivoTmp);
                $image_type = $test;
            } else {
                $test = getimagesize($arquivoTmp);
                $image_type = $test[2];
            }


            if (in_array($image_type, array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP))) {
                $image = new SimpleImage();
                $image->load($arquivoTmp);
                $l = $image->getWidth();
                $h = $image->getHeight();
                if ($l > $h) {
                    $funcao = "resizeToWidth";
                    $novoTamanho = 1024;
                } else {
                    $funcao = "resizeToHeight";
                    $novoTamanho = 768;
                }

                $image->$funcao($novoTamanho);
                $copiou = $image->save($this->diretorio . $nome);

                if ($this->prefixoMarcaDagua) {
                    $image->$funcao(300);
                    $image->watermark();
                    $image->save($this->diretorio . $this->prefixoMarcaDagua . $nome);
                }
                if ($this->prefixoMiniatura) {
                    $image->load($arquivoTmp);
                    $image->$funcao(380);
                    $image->save($this->diretorio . $this->prefixoMiniatura . $nome);
                }
            } else {
                $copiou = copy($arquivoTmp, $this->diretorio . $nome);
            }
            if ($copiou) {
                $sql = "update $this->tabela set $this->campoBD = '$nome' where id='$idGravado'";
                #$altualizaNome = mysql_query($sql) or die($sql . mysql_error);
                $this->conexao->executeQuery($sql);
            }
        } else {
            return false;
        }
        return $idGravado;
    }
开发者ID:jhmachado,项目名称:anotation,代码行数:55,代码来源:Upload.php


示例14: xulyImage

function xulyImage($img, $urlImgTemp, $urlImg, $urlImgThumb, $original = 1)
{
    $file = $urlImgTemp . $img;
    $sizeInfo = getimagesize($file);
    if (is_array($sizeInfo)) {
        include_once 'libraries/SimpleImage.php';
        $image = new SimpleImage();
        $image->load($file);
        $width = $sizeInfo[0];
        $height = $sizeInfo[1];
        if ($width <= IMAGE_THUMB_WIDTH && $height <= IMAGE_THUMB_HEIGHT) {
            copy($file, $urlImgThumb . $img);
        } elseif ($width >= $height) {
            $image->resizeToWidth(IMAGE_THUMB_WIDTH);
            $image->save($urlImgThumb . $img);
        } elseif ($width < $height) {
            $image->resizeToHeight(IMAGE_THUMB_HEIGHT);
            $image->save($urlImgThumb . $img);
        }
        if ($original == 1) {
            $image->load($file);
            if ($width >= $height && $width > IMAGE_MAX_WIDTH) {
                $image->resizeToWidth(IMAGE_MAX_WIDTH);
                $image->save($urlImg . $img);
            } elseif ($width <= $height && $height > IMAGE_MAX_HEIGHT) {
                $image->resizeToHeight(IMAGE_MAX_HEIGHT);
                $image->save($urlImg . $img);
            } else {
                copy($file, $urlImg . $img);
            }
            if (file_exists($file)) {
                unlink($file);
            }
        } else {
            if (copy($file, $urlImg . $img)) {
                if (file_exists($file)) {
                    unlink($file);
                }
            }
        }
        return true;
    } else {
        return false;
    }
}
开发者ID:hieunhan1,项目名称:all-website-v5,代码行数:45,代码来源:controlAjaxAdmin.php


示例15: resizeImagesInFolder

function resizeImagesInFolder($dir, $i)
{
    if (!is_dir('cover/' . $dir)) {
        toFolder('cover/' . $dir);
    }
    $files = scandir($dir);
    foreach ($files as $key => $file) {
        if ($file != '.' && $file != '..') {
            if (!is_dir($dir . '/' . $file)) {
                echo $dir . '/' . $file;
                $image = new SimpleImage();
                $image->load($dir . '/' . $file);
                if ($image->getHeight() < $image->getWidth()) {
                    $image->resizeToWidth(1920);
                } else {
                    $image->resizeToHeight(1920);
                }
                // $new = 'cover/' . $dir . '/'.$image->name;
                if ($i < 10) {
                    $new = 'cover/' . $dir . '/00' . $i . '.' . $image->type;
                } elseif ($i < 100) {
                    $new = 'cover/' . $dir . '/0' . $i . '.' . $image->type;
                } else {
                    $new = 'cover/' . $dir . '/' . $i . '.' . $image->type;
                }
                $image->save($new);
                echo ' ---------> ' . $new . '<br>';
                $i++;
            } else {
                resizeImagesInFolder($dir . '/' . $file, 1);
            }
        }
    }
}
开发者ID:locnd,项目名称:demo,代码行数:34,代码来源:resize.php


示例16: executeProcess

/**
 * Процесс строит скрипты для вставки ячеек в БД
 * 
 * @param array $argv
 */
function executeProcess(array $argv)
{
    $DM = DirManager::inst(array(__DIR__, 'output'));
    $customNum = $argv[1];
    dolog('Processing mosaic demo, custom num={}', $customNum);
    /* @var $dir DirItem */
    foreach ($DM->getDirContent(null, DirItemFilter::DIRS) as $dir) {
        if (is_inumeric($customNum) && $customNum != $dir->getName()) {
            continue;
            //----
        }
        $imgDM = DirManager::inst($dir->getAbsPath());
        $imgDI = end($imgDM->getDirContent(null, DirItemFilter::IMAGES));
        $map = $imgDM->getDirItem(null, 'map', 'txt')->getFileAsProps();
        $demoDM = DirManager::inst($imgDM->absDirPath(), 'demo');
        $demoDM->clearDir();
        dolog("Building map for: [{}].", $imgDI->getRelPath());
        //CELLS BINDING
        $dim = $imgDM->getDirItem(null, 'settings', 'txt')->getFileAsProps();
        $dim = $dim['dim'];
        $dim = explode('x', $dim);
        $cw = 1 * $dim[0];
        $ch = 1 * $dim[1];
        $sourceImg = SimpleImage::inst()->load($imgDI);
        $w = $sourceImg->getWidth();
        $h = $sourceImg->getHeight();
        $destImg = SimpleImage::inst()->create($w, $h, MosaicImage::BG_COLOR);
        dolog("Img size: [{$w} x {$h}].");
        check_condition($w > 0 && !($w % $cw), 'Bad width');
        check_condition($h > 0 && !($h % $ch), 'Bad height');
        $totalCells = count($map);
        $lengtn = strlen("{$totalCells}");
        //dolog("Cells cnt: [$xcells x $ycells], total: $totalCells.");
        //СТРОИМ КАРТИНКИ
        $secundomer = Secundomer::startedInst();
        //$encoder = new PsGifEncoder();
        for ($cellCnt = 0; $cellCnt <= $totalCells; $cellCnt++) {
            $name = pad_zero_left($cellCnt, $lengtn);
            $copyTo = $demoDM->absFilePath(null, $name, 'jpg');
            if ($cellCnt > 0) {
                $cellParams = $map[$cellCnt];
                $cellParams = explode('x', $cellParams);
                $xCell = $cellParams[0];
                $yCell = $cellParams[1];
                $x = ($xCell - 1) * $cw;
                $y = ($yCell - 1) * $ch;
                $destImg->copyFromAnother($sourceImg, $x, $y, $x, $y, $cw, $ch);
            }
            $destImg->save($copyTo);
            dolog("[{$totalCells}] {$copyTo}");
        }
        //$encoder->saveToFile($demoDM->absFilePath(null, 'animation'));
        $secundomer->stop();
        dolog('Execution time: ' . $secundomer->getTotalTime());
    }
}
开发者ID:ilivanoff,项目名称:ps-sdk-dev,代码行数:61,代码来源:demo.php


示例17: scale

 function scale($size = 100)
 {
     if (!$this->image && !$this->checked) {
         $this->get();
     }
     if (!$this->image) {
         return false;
     }
     // New code to get rectangular images
     require_once mnminclude . "simpleimage.php";
     $thumb = new SimpleImage();
     $thumb->image = $this->image;
     if ($thumb->resize($size, $size, true)) {
         //$this->image = $thumb->image;
         //$this->x=imagesx($this->image);
         //$this->y=imagesy($this->image);
         return $thumb;
     }
     return false;
 }
开发者ID:brainsqueezer,项目名称:fffff,代码行数:20,代码来源:webimages.php


示例18: get_file

 public function get_file($modelID = '', $id = '', $filetype = '', $filename = '')
 {
     if ($id != '') {
         $fileinfo = $this->file_model->get_fileinfo($modelID, $id, $filetype);
         if ($fileinfo['Status']) {
             if (file_exists(absolute_path() . APPPATH . 'files/' . $fileinfo['LocalFileName'])) {
                 switch (strtolower($filetype)) {
                     case "thumbnails":
                         $size = explode('_', $filename);
                         if (!is_numeric($size[0]) or $size[0] <= 0) {
                             show_404();
                         }
                         if (!is_numeric($size[1]) or $size[0] <= 0) {
                             show_404();
                         }
                         $img = new SimpleImage();
                         $img->load(absolute_path() . APPPATH . 'files/' . $fileinfo['LocalFileName'])->best_fit($size[0], $size[1]);
                         $img->output('jpg');
                         break;
                     default:
                         $mm_type = mime_content_type($fileinfo['FileName']);
                         header('Content-Description: File Transfer');
                         header('Content-Type: ' . $mm_type);
                         header('Content-Disposition: ' . $fileinfo['DispositionType'] . '; filename=' . basename($fileinfo['FileName']));
                         header('Content-Transfer-Encoding: binary');
                         header('Expires: 0');
                         header('Cache-Control: must-revalidate');
                         header('Pragma: public');
                         header('Content-Length: ' . filesize(APPPATH . 'files/' . $fileinfo['LocalFileName']));
                         ob_clean();
                         flush();
                         readfile(APPPATH . 'files/' . $fileinfo['LocalFileName']);
                 }
             }
         } else {
             show_404();
         }
     } else {
         show_404();
     }
 }
开发者ID:mdbhk,项目名称:retailersurvey.themdbfamily.com,代码行数:41,代码来源:file.php


示例19: create

 /**
  * Создание новости
  */
 public function create()
 {
     if (!User::isAdmin()) {
         App::abort('403');
     }
     if (Request::isMethod('post')) {
         $news = new News();
         $news->category_id = Request::input('category_id');
         $news->user_id = User::get('id');
         $news->title = Request::input('title');
         $news->slug = '';
         $news->text = Request::input('text');
         $image = Request::file('image');
         if ($image && $image->isValid()) {
             $ext = $image->getClientOriginalExtension();
             $filename = uniqid(mt_rand()) . '.' . $ext;
             if (in_array($ext, ['jpeg', 'jpg', 'png', 'gif'])) {
                 $img = new SimpleImage($image->getPathName());
                 $img->best_fit(1280, 1280)->save('uploads/news/images/' . $filename);
                 $img->best_fit(200, 200)->save('uploads/news/thumbs/' . $filename);
             }
             $news->image = $filename;
         }
         if ($news->save()) {
             if ($tags = Request::input('tags')) {
                 $tags = array_map('trim', explode(',', $tags));
                 foreach ($tags as $tag) {
                     $tag = Tag::create(['name' => $tag]);
                     $tag->create_news_tags(['news_id' => $news->id]);
                 }
             }
             App::setFlash('success', 'Новость успешно создана!');
             App::redirect('/' . $news->category->slug . '/' . $news->slug);
         } else {
             App::setFlash('danger', $news->getErrors());
             App::setInput($_POST);
         }
     }
     $categories = Category::getAll();
     App::view('news.create', compact('categories'));
 }
开发者ID:visavi,项目名称:rotorcms,代码行数:44,代码来源:NewsController.php


示例20: _write_product_image

 private function _write_product_image($file = '', $prd_id = '')
 {
     $val = rand(999, 99999999);
     $image_name = "PRO" . $val . $prd_id . ".png";
     //$this->upload_image($file, $image_name);
     $this->request->data['Product']['image'] = $image_name;
     $this->request->data['Product']['id'] = $prd_id;
     $this->Product->save($this->request->data, false);
     /* if (!empty($file)) {
            $this->FileWrite->file_write_path = PRODUCT_IMAGE_PATH;
            $this->FileWrite->_write_file($file, $image_name);
        }*/
     include "SimpleImage.php";
     $image = new SimpleImage();
     if (!empty($file)) {
         $image->load($file['tmp_name']);
         $image->save(PRODUCT_IMAGE_PATH . $image_name);
         $image->resizeToWidth(150, 150);
         $image->save(PRODUCT_IMAGE_THUMB_PATH . $image_name);
     }
 }
开发者ID:89itworld,项目名称:pricecomparison,代码行数:21,代码来源:WoolworthsController.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP SimpleInvokerDecorator类代码示例发布时间:2022-05-23
下一篇:
PHP SimpleHttpRequest类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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