2010-11-30 31 views
5

Şu anda Zend Framework'de büyük bir arka uç uygulaması üzerinde çalışıyorum. Bir çok nesne bir nesne veya eylem için yanlış simgeyi kullanarak sonlandırıyorum.PHP kodu simgeleri oluşturmak için

Benim Soru Simgeleri otomatik olarak oluşturmak için herhangi bir php kodu var mı ????

Tabii ki bu simgeler büyülü olarak oluşturulmayacak, en iyi durum senaryosuna sahip olan bir simgeler koleksiyonumuz var.

  • Nesne (kullanıcı, kategori, ürün, rss vs) (vs güncellemek, silmek, düzenleme ekleyin)
  • Eylem

biz simgelerin farklı karıştırarak simgeler oluşturabilir Bu şekilde Sinek.

Simgeyi sağ alt köşede 32x32 ile silmek ve simgeyi silmek için bir simge oluşturma kodu.

 
$icon = new Icon(); 
$icon->object('user')->action('delete'); 
$icon->action_align('right')->action_valign('bottom'); 
$icon->action_height(10)->action_width(10); 
$icon->height(32)->width(32); 
$icon->create(); 

Bu, daha önce hiç çıkılmayan bir simge nasıl oluşturabiliriz diye bir örnektir.

+0

Ben belirtildiği gibi kütüphaneyi bulmak için umut veya i kendim yazmak zorunda. –

+1

Burada bir tane var sanırım. Ama ahbap, bu oldukça iyi bir fikir! – Shikiryu

+0

O zaman ona bir şey vereceğim. –

cevap

2

Görüntüleri dışa aktarmak için .12 biçiminde değil, ancak .bmp tamam olacak şekilde GD library kullanabilirsiniz. Imagick ile doğrudan .ico dosyaları yapabilirsiniz görünüyor.

+0

Teşekkürler, evet GD Kütüphanesinin yapacaklarından oldukça eminim. –

+1

me2. Ayrıca bir pimler oluşturabilirsiniz. Sanırım ico olarak kabul ediliyorlar. –

+0

Eğer yanlış yorumlu varsa, birincil amacı png, gif oluşturmak için ama ico dosyaları artı bir etmektir. –

2

Hey ben sana bu tür dosyalayıcı oluşturmak için önerebilirsiniz:

Filter that creates image thumbnail

<?php 
/** 
* Class for thumbnailing images 
* 
* @author Michał Bachowski ([email protected]) 
* @package JPL 
* @subpackage Jpl_Filter 
* @version 0.1 
* @uses Zend_Filter_Interface, IMagick 
* @license http://framework.zend.com/license/new-bsd  New BSD License 
*/ 
class Jpl_Filter_File_Image_Thumbnail { 
    /** 
    * Thumbnail width 
    * 
    * @var integer 
    */ 
    protected $_width = null; 
    /** 
    * Thumbnail height 
    * 
    * @var integer 
    */ 
    protected $_height = null; 
    /** 
    * Information whether to keep ratio or not while making thumbnail 
    * 
    * @var bool 
    */ 
    protected $_bestFit = true; 
    /** 
    * Information whether crop image or just to resize it 
    * 
    * @var bool 
    */ 
    protected $_crop = false; 
    /** 
    * Method sets destination thumbnail width 
    * 
    * @param integer $width 
    * @return Jpl_Filter_File_Image_Thumbnail 
    */ 
    public function setWidth($width = null) { 
     $this->_width = (int) $width; 
     return $this; 
    } 
    /** 
    * Method sets destination thumbnail height 
    * 
    * @param integer $height 
    * @return Jpl_Filter_File_Image_Thumbnail 
    */ 
    public function setHeight($height = null) { 
     $this->_height = (int) $height; 
     return $this; 
    } 
    /** 
    * Method changes behaviour of filter. 
    * Filter will resize image exactly to given dimensions (false) 
    * or resize image to fit given dimensions but keep original dimension ratio (true). 
    * Setting bestFit to true both dimensions are become mandatory! 
    * 
    * @param bool  $bestFit 
    * @return Jpl_Filter_File_Image_Thumbnail 
    */ 
    public function setBestFit($bestFit = false) { 
     $this->_bestFit = (bool) $bestFit; 
     return $this; 
    } 
    /** 
    * Method changes behaviour of filter. 
    * Filter either just resizes image (false) 
    * or resizes with keeping ratio and crop to best fit given width and height (true) 
    * If true ommits self::$_bestFit attribute! 
    * 
    * @param bool $crop 
    * @return Jpl_Filter_File_Image_Thumbnail 
    */ 
    public function setCrop($crop = false) { 
     $this->_crop = (bool) $crop; 
     return $this; 
    } 
    /** 
    * Method filters given file - makes thumb 
    * 
    * @param string $file path to file 
    * @return string name of file 
    */ 
    public function filter($file) { 
     $im = new IMagick($file); 
     if ($this->_crop) { 
      $im->cropThumbnailImage(
       $this->_width, 
       $this->_height 
      ); 
     } else { 
      $im->thumbnailImage(
       $this->_width, 
       $this->_height, 
       $this->_bestFit 
      ); 
     } 
     $im->writeImage($file); 
    } 
} 
+0

Teşekkürler ama GD Kütüphanesi'ni tercih ederim, bu yüzden imagemajick bağımlı olmak zorunda değiliz. –

+1

, bu kolay olmalı, sadece gerekli değişiklikleri yapın – tawfekov

İlgili konular