Esempio n. 1
0
 static function getPoster($id)
 {
     $poster = ROOT . DS . "cache" . DS . "serie" . DS . "poster";
     if (!is_dir($poster)) {
         mkdir($poster, 0777, true);
     }
     if (!file_exists($poster . DS . $id . ".jpg")) {
         $film = \model\mysql\Serie::getPoster($id);
         if (is_null($film->urlposter)) {
             //No poster
             $content = MyImage::nonImageAddTexte($film->titre, ROOT . DS . "font" . DS . "comic.ttf", 30);
             file_put_contents($poster . DS . $id . ".jpg", $content);
         } else {
             copy($film->urlposter, $poster . DS . $id . ".jpg");
         }
     }
     return $poster . DS . $id . ".jpg";
 }
Esempio n. 2
0
File: frm.php Progetto: vobinh/PHP
<?php 
}
// end if
if (empty($mr['banner_name']) || $mr['banner_type'] == 'image') {
    ?>
<div class="yui3-g">
	<div class="yui3-u-1-6 right"><?php 
    echo Kohana::lang('global_lang.lbl_image');
    ?>
:</div>
    <div class="yui3-u-4-5">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    	
    	<?php 
    if (!empty($mr['banner_name'])) {
        $src = "uploads/banner/" . $mr['banner_name'];
        $arr = MyImage::thumbnail(300, 300, $src);
        ?>
        	
            <img src="<?php 
        echo url::base();
        ?>
uploads/banner/<?php 
        echo $mr['banner_name'];
        ?>
" width="<?php 
        echo !empty($arr['width']) ? $arr['width'] . 'px' : 'auto';
        ?>
" height="<?php 
        echo !empty($arr['height']) ? $arr['height'] . 'px' : @$maxh;
        ?>
"/>&nbsp;         
Esempio n. 3
0
File: list.php Progetto: vobinh/PHP
" id="row_<?php 
        echo $list['banner_id'];
        ?>
"> 
    <td align="center"><?php 
        echo $list['banner_id'];
        ?>
</td>   
   
    <td align="center">    
    <?php 
        if (@$list['banner_type'] == 'image' && file_exists($list['path_file']) && is_file($list['path_file'])) {
            $src = "uploads/banner/" . $list['path_file'];
            $maxw = Configuration_Model::get_value('MAX_WIDTH_BANNER_ADMIN_LIST');
            $maxh = Configuration_Model::get_value('MAX_HEIGHT_BANNER_ADMIN_LIST');
            $arr = MyImage::thumbnail($maxw, $maxh, $src);
            ?>
        <a href="<?php 
            echo url::base();
            ?>
uploads/banner/<?php 
            echo $list['banner_name'];
            ?>
">
        <img src="<?php 
            echo url::base();
            ?>
uploads/banner/<?php 
            echo $list['banner_name'];
            ?>
" width="<?php 
 public function postProcess()
 {
     if (Tools::isSubmit('submitAdd' . $this->table)) {
         //$newFilename="image_".time().".jpg";
         $slideshowInfos = $this->getSlideshow((int) Tools::getValue('id_opartslideshow_slideshow'));
         $obj = new MyImage((int) Tools::getValue('id_opartslideshow_slideshow_image'));
         $errors = "";
         if (isset($_FILES['image_file']) && is_uploaded_file($_FILES['image_file']['tmp_name'])) {
             $filename = Tools::getValue('filename');
             if (file_exists($this->imgDir . $filename)) {
                 unlink($this->imgDir . $filename);
                 if (file_exists(_PS_ROOT_DIR_ . "/img/tmp/" . $this->table . '_' . $filename)) {
                     unlink(_PS_ROOT_DIR_ . "/img/tmp/" . $this->table . '_' . $filename);
                 }
                 //on rechange le filename pour eviter la mise en cache de la nouvelle image
                 $filename = "image_" . time() . ".jpg";
                 $changeFilename = true;
             }
             $sizes = getimagesize($_FILES['image_file']['tmp_name']);
             if ($error = ImageManager::validateUpload($_FILES['image_file'])) {
                 $errors .= $error;
             } elseif (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) || !move_uploaded_file($_FILES['image_file']['tmp_name'], $tmpName)) {
                 return false;
             }
             if ($sizes[0] == $slideshowInfos['width'] && $sizes[1] == $slideshowInfos['height']) {
                 rename($tmpName, $this->imgDir . $filename);
                 chmod($this->imgDir . $filename, 0705);
             } elseif (!ImageManager::resize($tmpName, $this->imgDir . $filename, $slideshowInfos['width'], $slideshowInfos['height'])) {
                 $errors .= Tools::displayError($this->l('An error occurred during the image upload.'));
             }
             if (file_exists($tmpName)) {
                 unlink($tmpName);
             }
             $obj->copyFromPost();
             if (isset($changeFilename) && $changeFilename === true) {
                 $obj->filename = $filename;
             }
         } else {
             $obj->copyFromPost();
         }
         $obj->save();
     } else {
         parent::postProcess();
     }
 }
Esempio n. 5
0
 /**
  * 保存到指定文件
  *
  * @param string $file 文件地址
  * @param string $format 文件格式
  * @return bool
  */
 public function save($file, $format = 'jpg')
 {
     $product = $this->product;
     $func = $this->imageFunc($format);
     $params = array($product, $file);
     if ($format == "jpg") {
         $params[] = 100;
     }
     $res = call_user_func_array($func[1], $params);
     if ($res) {
         $image = new MyImage();
         $image->setFile($file);
         return $image;
     }
     $this->destroy($product);
     return false;
 }