2010-11-30 14 views
5

वर्तमान में मैं ज़ेंड फ्रेमवर्क में एक विशाल बैक-एंड एप्लिकेशन पर काम कर रहा हूं। कुछ ऑब्जेक्ट या एक्शन के लिए गलत आइकन का उपयोग करके मैं कई बार समाप्त होता हूं।आइकन उत्पन्न करने के लिए PHP कोड

मेरा प्रश्न क्या स्वचालित रूप से आइकन उत्पन्न करने के लिए कोई PHP कोड है ????

इन आइकनों को जादूगर रूप से जेनरेट नहीं किया जाएगा, सर्वोत्तम केस परिदृश्य यह है कि हमारे पास आइकन का संग्रह है जिसमें प्रकार है।

  • वस्तु (उपयोगकर्ता, श्रेणी, उत्पाद, आरएसएस आदि)
  • एक्शन (जोड़ने, संपादित करने, हटाने, अद्यतन आदि)

इस तरह हम पर माउस के विभिन्न प्रकार के मिश्रण से प्रतीक बना सकते हैं मक्खी।

32x32 के साथ उपयोगकर्ता को हटाने और आइकन के निचले दाएं कोने में आइकन हटाने के लिए आइकन उत्पन्न करने के लिए कोड।

 
$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(); 

यह सिर्फ एक उदाहरण है कि हम एक आइकन कैसे बना सकते हैं जो पहले कभी नहीं निकला था।

+0

मैं पुस्तकालय को खोजने के लिए के रूप में मैं उल्लेख आशा या मैं इसे अपने आप को लिखने के लिए की है। –

+1

मुझे नहीं लगता कि यहां एक मौजूदा व्यक्ति है। लेकिन दोस्त, यह एक बहुत अच्छा विचार है! – Shikiryu

+0

तो मैं इसे जाने दूंगा। –

उत्तर

2

आप छवियों को निर्यात करने के लिए GD library का उपयोग कर सकते हैं, नहीं .ico प्रारूप में नहीं बल्कि एक .bmp ठीक रहेगा। Imagick के साथ ऐसा लगता है कि आप सीधे .ico फाइलें कर सकते हैं।

+0

धन्यवाद, हाँ मुझे पूरा भरोसा है कि जीडी लाइब्रेरी करेगा। –

+1

me2। आप एक पीएनजी भी बना सकते हैं। मुझे लगता है कि उन्हें इको के रूप में भी स्वीकार किया जाता है। –

+0

क्षमा करें अगर मैंने गलत व्याख्या की है, प्राथमिक उद्देश्य छवियों को बनाना है png, gif लेकिन ico फ़ाइलें एक प्लस है। –

2

अरे मैं आप इस तरह filer बनाने के लिए सुझाव है कि कर सकते हैं:

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

धन्यवाद लेकिन मैं जीडी लाइब्रेरी को पसंद करूंगा इसलिए हमें छविगत निर्भर होने की आवश्यकता नहीं है। –

+1

यह आसान होगा, बस आवश्यक परिवर्तन करें – tawfekov

संबंधित मुद्दे