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


PHP func::image_type_to_extension方法代码示例

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


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

示例1: update

 /** загрузка(сохранение/обновление) аватара
  * @param integer ID записи
  * @param boolean удалять предыдущий аватар
  * @return имя файла успешно загруженной аватары | false
  */
 function update($nRecordID, $bDeletePrevious = false, $bDoUpdateQuery = false)
 {
     global $oDb;
     if ($nRecordID && !empty($_FILES) && $_FILES[$this->input]['error'] == UPLOAD_ERR_OK) {
         $oUpload = new Upload($this->input, false);
         $aImageSize = getimagesize($_FILES[$this->input]['tmp_name']);
         if ($oUpload->isSuccessfull() && $aImageSize !== FALSE && in_array($aImageSize[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
             if ($bDeletePrevious) {
                 $this->delete($nRecordID, false);
             }
             $sExtension = func::image_type_to_extension($aImageSize[2], false);
             $sFilename = Func::generateRandomName($this->filenameLetters, true, true) . '.' . $sExtension;
             //проверяем размер файла
             if (!$oUpload->checkSize($this->maxsize)) {
                 return false;
             }
             //создаем thumbnail
             $oThumb = new thumbnail($_FILES[$this->input]['tmp_name']);
             $oThumb->jpeg_quality(85);
             $oThumb->crop_proportionaly(1, 1, 'middle', 'center');
             $oThumb->createTumbnail_if_more_then($this->path . $nRecordID . '_' . $sFilename, $this->width, $this->height, true);
             @unlink($_FILES[$this->input]['tmp_name']);
             if ($bDoUpdateQuery) {
                 $oDb->execute("UPDATE {$this->table} \n                                   SET {$this->fieldAvatar} =" . $oDb->str2sql($sFilename) . "\n                                   WHERE {$this->fieldID} = {$nRecordID} ");
             }
             return $sFilename;
         }
     }
     return false;
 }
开发者ID:Sywooch,项目名称:dobox,代码行数:35,代码来源:avatar.php

示例2: update

 /** загрузка(сохранение/обновление) скриншота
  * @param integer ID записи
  * @param boolean удалять предыдущий скриншот
  * @return имя файла успешно загруженного скриншота | false
  */
 function update($nRecordID, $bDeletePrevious = false, $bDoUpdateQuery = false)
 {
     global $oDb;
     if ($nRecordID && !empty($_FILES) && $_FILES[$this->input]['error'] == UPLOAD_ERR_OK) {
         $oUpload = new Upload($this->input, false);
         $aImageSize = getimagesize($_FILES[$this->input]['tmp_name']);
         if ($oUpload->isSuccessfull() && $aImageSize !== FALSE && in_array($aImageSize[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
             if ($bDeletePrevious) {
                 $this->delete($nRecordID, false);
             }
             $sExtension = func::image_type_to_extension($aImageSize[2], false);
             $sFilename = Func::generateRandomName($this->filenameLetters, true, true) . '.' . $sExtension;
             //проверяем размер файла
             if (!$oUpload->checkSize($this->maxsize)) {
                 return false;
             }
             //создаем thumbnail
             $oThumb = new thumbnail($_FILES[$this->input]['tmp_name']);
             $oThumb->jpeg_quality(85);
             $bFileMoved = false;
             foreach ($this->sizes as $s) {
                 if (!empty($s['original'])) {
                     $oUpload->save($this->path, $nRecordID . '_' . $s['p'] . $sFilename, false, false);
                     $bFileMoved = true;
                     break;
                 }
                 $oThumb->createTumbnail_if_more_then($this->path . $nRecordID . '_' . $s['p'] . $sFilename, $s['w'], $s['h'], isset($s['autofit']) ? $s['autofit'] : true);
             }
             if (!$bFileMoved) {
                 @unlink($_FILES[$this->input]['tmp_name']);
             }
             if ($bDoUpdateQuery) {
                 $oDb->execute("UPDATE {$this->table} \n                                   SET {$this->fieldPreview} =" . $oDb->str2sql($sFilename) . "\n                                   WHERE {$this->fieldID} = {$nRecordID}");
             }
             return $sFilename;
         }
     }
     return false;
 }
开发者ID:Sywooch,项目名称:dobox,代码行数:44,代码来源:preview.php

示例3: uploadImages

 /** 
  * Загрузка файлов изображений, при помощи input=file
  * @param integer ID записи
  * @param integer кол-во букв в сгенерированном имени файла
  * @return string имена загруженных файлов @example: '1.jpg,2.jpg' (CSV)
  */
 function uploadImages($ID, $nGenerateLettersCount = 5)
 {
     $aFilenames = array();
     if (func::isPostMethod()) {
         $ID = intval($ID);
         if (empty($nGenerateLettersCount)) {
             $nGenerateLettersCount = 5;
         }
         foreach ($_FILES as $sInputName => $aFile) {
             if ($aFile['name'] != '') {
                 $pUpload = new Upload($sInputName);
                 $aImageSize = getimagesize($pUpload->getFilenameUploaded());
                 if ($aImageSize !== FALSE && $pUpload->isSuccessfull() && in_array($aImageSize[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
                     $sExtension = func::image_type_to_extension($aImageSize[2], false);
                     $sFilename = Func::generateRandomName($nGenerateLettersCount, false, true);
                     $sFilenameFull = "{$sFilename}.{$sExtension}";
                     if ($this->saveImageFile($ID, $sFilenameFull, $pUpload, array('name' => $sFilename, 'ext' => $sExtension))) {
                         $aFilenames[] = $sFilenameFull;
                     }
                 }
             }
         }
     }
     if (count($aFilenames) > 0) {
         $sFilenames = implode(',', $aFilenames);
     }
     return isset($sFilenames) ? $sFilenames : '';
 }
开发者ID:Sywooch,项目名称:dobox,代码行数:34,代码来源:imagesfield.php

示例4: save

 function save($save = "", $bMakeWatermark = false, $nRoundCornersRadius = false)
 {
     if ($this->bSaveAsOriginal) {
         $res = @copy($this->sSourcePath2file, $save);
         if (!$res) {
             echo 'cann`t writre to ' . $save;
             exit;
         }
     }
     if (extension_loaded('gd') || extension_loaded('gd2')) {
         if (!function_exists('imagecreatetruecolor')) {
             str2log(__CLASS__ . '::' . __FUNCTION__ . ' - cant`t find ImageCreateTrueColor()', 'error.log');
             return false;
         }
         if (!function_exists('imagecopyresampled')) {
             str2log(__CLASS__ . '::' . __FUNCTION__ . ' - cant`t find ImageCopyResampled()', 'error.log');
             return false;
         }
         //save thumb
         if (empty($save)) {
             $save = mb_strtolower('./thumb' . func::image_type_to_extension($this->img['format'], true));
         }
         /* change ImageCreateTrueColor to ImageCreate if your GD not supported ImageCreateTrueColor function*/
         $this->img["des"] = ImageCreateTrueColor($this->img["lebar_thumb"], $this->img["tinggi_thumb"]);
         // задаем чересстрочный режим
         //if ($this->bProgressive) ImageInterlace($this->img["des"], 1);
         if ($this->img['format'] == IMAGETYPE_PNG || $this->img['format'] == IMAGETYPE_GIF) {
             @ImageAlphaBlending($this->img["des"], false);
             @ImageSaveAlpha($this->img["des"], true);
         }
         ImageCopyResampled($this->img["des"], $this->img["src"], 0, 0, $this->img['src_x'], $this->img['src_y'], $this->img["lebar_thumb"], $this->img["tinggi_thumb"], $this->img['lebar'], $this->img['tinggi']);
         if ($bMakeWatermark) {
             $this->make_watermark('des', $this->img["lebar_thumb"], $this->img["tinggi_thumb"]);
         }
         $nImageFormat = $this->img['format'];
         if (isset($nRoundCornersRadius) && $nRoundCornersRadius !== false && $nRoundCornersRadius > 0) {
             $this->make_roundcorners('des', $nRoundCornersRadius);
             $nImageFormat = IMAGETYPE_PNG;
         }
         //сохраняем картинку
         switch ($nImageFormat) {
             case IMAGETYPE_GIF:
                 imageGIF($this->img['des'], $save);
                 break;
             case IMAGETYPE_JPEG:
                 imageJPEG($this->img['des'], $save, $this->img['quality']);
                 break;
             case IMAGETYPE_PNG:
                 imagePNG($this->img['des'], $save);
                 break;
             case IMAGETYPE_WBMP:
                 imageWBMP($this->img['des'], $save);
                 break;
         }
         ImageDestroy($this->img['des']);
     } else {
         $res = system('convert ' . $this->img['src'] . ' ' . '-resize "' . $this->img["lebar_thumb"] . 'x' . $this->img["tinggi_thumb"] . '"  ' . $save . ' > /dev/null 2>/opt/hosting/www.alof.com/htdocs/log.txt', $retval);
         //debug('convert  '.'-resize '.((int)$this->img["lebar_thumb"]).'x'.((int)$this->img["tinggi_thumb"]).' '.$this->img['src'].' '.$save);
         $res = system('convert -version');
         if (!$res) {
             debug('Sorry, imageMagic - not defined!. GD library not defined!. Please Contact to administrator.');
             exit;
         }
     }
     return true;
 }
开发者ID:Sywooch,项目名称:dobox,代码行数:66,代码来源:thumbnail.php


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