當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ImageHelper::addWatermark方法代碼示例

本文整理匯總了PHP中ImageHelper::addWatermark方法的典型用法代碼示例。如果您正苦於以下問題:PHP ImageHelper::addWatermark方法的具體用法?PHP ImageHelper::addWatermark怎麽用?PHP ImageHelper::addWatermark使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ImageHelper的用法示例。


在下文中一共展示了ImageHelper::addWatermark方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getProcessRecord

 /**
  * Process each record and store it in the database
  *
  * @copyright
  * @author 		RolandD
  * @todo
  * @see
  * @access 		public
  * @param
  * @return
  * @since 		3.0
  */
 public function getProcessRecord()
 {
     $db = JFactory::getDbo();
     $jinput = JFactory::getApplication()->input;
     $csvilog = $jinput->get('csvilog', null, null);
     $template = $jinput->get('template', null, null);
     // Process the image
     $this->_processMedia();
     // Set some basic values
     if (!isset($this->modified_on)) {
         $this->_medias->modified_on = $this->date->toSql();
         $this->_medias->modified_by = $this->user->id;
     }
     // Find the media ID
     $this->_medias->file_url = $this->file_url;
     $this->_medias->check();
     $this->virtuemart_media_id = $this->_medias->virtuemart_media_id;
     // Do we need to delete a media file?
     if ($this->media_delete == 'Y') {
         $this->_deleteMedia();
     } else {
         // Check if the media exists
         if (empty($this->virtuemart_media_id)) {
             $this->_medias->created_on = $this->date->toMySQL();
             $this->_medias->created_by = $this->user->id;
         }
         // Bind all the data
         $this->_medias->bind($this);
         // Store the data
         if ($this->_medias->store()) {
             if ($this->queryResult() == 'UPDATE') {
                 $csvilog->AddStats('updated', JText::_('COM_CSVI_UPDATE_MEDIAFILE'));
             } else {
                 $csvilog->AddStats('added', JText::_('COM_CSVI_ADD_MEDIAFILE'));
             }
             // Watermark image if needed
             $imagehelper = new ImageHelper();
             if ($template->get('full_watermark', 'image')) {
                 $imagehelper->addWatermark(JPATH_SITE . '/' . $this->_medias->file_url);
             }
             // Add a link to the product if the SKU is specified
             if (isset($this->product_sku)) {
                 $this->_product_medias->virtuemart_media_id = $this->_medias->virtuemart_media_id;
                 $this->_product_medias->virtuemart_product_id = $this->helper->getProductId();
                 if (!$this->_product_medias->check()) {
                     if ($this->_product_medias->store()) {
                         if ($this->queryResult() == 'UPDATE') {
                             $csvilog->AddStats('updated', JText::_('COM_CSVI_UPDATE_MEDIAXREF'));
                         } else {
                             $csvilog->AddStats('added', JText::_('COM_CSVI_ADD_MEDIAXREF'));
                         }
                     }
                 }
             }
         } else {
             $csvilog->AddStats('incorrect', JText::sprintf('COM_CSVI_MEDIAFILE_NOT_ADDED', $this->_medias->getError()));
         }
         // Store the debug message
         $csvilog->addDebug(JText::_('COM_CSVI_MEDIAFILE_QUERY'), true);
     }
     // Clean the tables
     $this->cleanTables();
 }
開發者ID:alesconti,項目名稱:FF_2015,代碼行數:75,代碼來源:mediaimport.php

示例2: _processMedia


//.........這裏部分代碼省略.........
                     if ($file_details['exists']) {
                         // Check if the image is an external image
                         if (substr($file_details['name'], 0, 4) == 'http') {
                             $csvilog->AddStats('incorrect', 'COM_CSVI_VM_NOSUPPORT_URL');
                         } else {
                             $title = isset($titles[$key]) ? $titles[$key] : $file_details['output_name'];
                             $description = isset($descriptions[$key]) ? $descriptions[$key] : '';
                             $meta = isset($metas[$key]) ? $metas[$key] : '';
                             $media = array();
                             $media['virtuemart_vendor_id'] = $this->virtuemart_vendor_id;
                             if ($template->get('autofill', 'image')) {
                                 $media['file_title'] = $file_details['output_name'];
                                 $media['file_description'] = $file_details['output_name'];
                                 $media['file_meta'] = $file_details['output_name'];
                             } else {
                                 $media['file_title'] = $title;
                                 $media['file_description'] = $description;
                                 $media['file_meta'] = $meta;
                             }
                             $media['file_mimetype'] = $file_details['mime_type'];
                             $media['file_type'] = 'product';
                             $media['file_is_product_image'] = 1;
                             $media['file_is_downloadable'] = 0;
                             $media['file_is_forSale'] = 0;
                             $media['file_url'] = empty($file_details['output_path']) ? $file_details['output_name'] : $file_details['output_path'] . $file_details['output_name'];
                             $media['published'] = $this->published;
                             // Create the thumbnail
                             if ($file_details['isimage']) {
                                 $thumb = isset($thumbs[$key]) ? $thumbs[$key] : null;
                                 if ($template->get('thumb_create', 'image')) {
                                     $thumb_sizes = getimagesize(JPATH_SITE . '/' . $media['file_url']);
                                     if (empty($thumb)) {
                                         $thumb = 'resized/' . basename($media['file_url']);
                                     }
                                     if ($thumb_sizes[0] < 1024 || $thumb_sizes[1] < 768) {
                                         $media['file_url_thumb'] = $imagehelper->createThumbnail($media['file_url'], $template->get('file_location_product_images', 'path'), $thumb);
                                     } else {
                                         $media['file_url_thumb'] = '';
                                     }
                                 } else {
                                     $media['file_url_thumb'] = empty($thumb) ? $media['file_url'] : $file_details['output_path'] . $thumb;
                                     if (substr($media['file_url_thumb'], 0, 4) == 'http') {
                                         $csvilog->addDebug(JText::sprintf('COM_CSVI_RESET_THUMB_NOHTTP', $media['file_url_thumb']));
                                         $media['file_url_thumb'] = '';
                                     }
                                 }
                             } else {
                                 $media['file_is_product_image'] = 0;
                                 $media['file_url_thumb'] = '';
                             }
                             // Bind the media data
                             $this->_medias->bind($media);
                             // Check if the media image already exists
                             $this->_medias->check();
                             // Store the media data
                             if ($this->_medias->store()) {
                                 if ($this->queryResult() == 'UPDATE') {
                                     $csvilog->AddStats('updated', JText::_('COM_CSVI_UPDATE_MEDIA'));
                                 } else {
                                     $csvilog->AddStats('added', JText::_('COM_CSVI_ADD_MEDIA'));
                                 }
                                 // Store the debug message
                                 $csvilog->addDebug('COM_CSVI_MEDIA_QUERY', true);
                                 // Watermark the image
                                 if ($template->get('full_watermark', 'image') && $file_details['isimage']) {
                                     $imagehelper->addWatermark(JPATH_SITE . '/' . $media['file_url']);
                                 }
                                 // Store the product image relation
                                 $data = array();
                                 $data['virtuemart_product_id'] = $this->virtuemart_product_id;
                                 $data['virtuemart_media_id'] = $this->_medias->virtuemart_media_id;
                                 $data['ordering'] = $ordering;
                                 $this->_product_medias->bind($data);
                                 if (!$this->_product_medias->check()) {
                                     if ($this->_product_medias->store()) {
                                         $csvilog->addDebug('COM_CSVI_STORE_PRODUCT_IMAGE_RELATION', true);
                                         $ordering++;
                                     }
                                 } else {
                                     $csvilog->addDebug('Product image relation already exists');
                                 }
                             } else {
                                 $csvilog->AddStats('incorrect', JText::sprintf('COM_CSVI_MEDIA_NOT_ADDED', $this->_medias->getError()));
                                 return false;
                             }
                             // Reset the product media table
                             $this->_medias->reset();
                             $this->_product_medias->reset();
                         }
                         // else
                     }
                     // if
                 }
                 // if
             }
             // foreach
         }
         // if
     }
 }
開發者ID:srbsnkr,項目名稱:sellingonlinemadesimple,代碼行數:101,代碼來源:productimport.php

示例3: getProcessRecord

 /**
  * Process each record and store it in the database
  *
  * @copyright
  * @author 		RolandD
  * @todo
  * @see
  * @access 		public
  * @param
  * @return
  * @since 		5.8
  */
 public function getProcessRecord()
 {
     $db = JFactory::getDbo();
     $jinput = JFactory::getApplication()->input;
     $csvilog = $jinput->get('csvilog', null, null);
     $template = $jinput->get('template', null, null);
     // Find the media ID, we only use the image name
     $this->_images->fname = basename($this->fname);
     $this->_images->check();
     $this->id = $this->_images->id;
     // Do we need to delete a media file?
     if ($this->image_delete == 'Y') {
         if ($this->id) {
             $this->_deleteImage();
         } else {
             $csvilog->AddStats('information', JText::_('COM_CSVI_NO_IMAGE_ID'));
         }
     } else {
         // Find the property ID
         $based_on = $template->get('update_based_on', 'property', 'id');
         if ($based_on != 'id') {
             // Find the property ID
             $db = JFactory::getDbo();
             $propid = $this->propid;
             $query = $db->getQuery(true)->select($db->qn('id'))->from($db->qn('#__ezrealty'))->where($db->qn($based_on) . ' = ' . $db->q($propid));
             $db->setQuery($query);
             $this->propid = $db->loadResult();
             if (!$this->propid) {
                 $csvilog->AddStats('error', JText::sprintf('COM_CSVI_CANNOT_FIND_PROPERTY', $propid));
                 return false;
             }
         }
         // Process the image
         $this->_processMedia();
         // Bind all the data
         $this->_images->bind($this);
         // Store the data
         if ($this->_images->store()) {
             if ($this->queryResult() == 'UPDATE') {
                 $csvilog->AddStats('updated', JText::_('COM_CSVI_UPDATE_IMAGEFILE'));
             } else {
                 $csvilog->AddStats('added', JText::_('COM_CSVI_ADD_IMAGEFILE'));
             }
             // Watermark image if needed
             $imagehelper = new ImageHelper();
             if ($template->get('full_watermark', 'image')) {
                 $imagehelper->addWatermark(JPATH_SITE . '/' . $this->_images->fname);
             }
         } else {
             $csvilog->AddStats('incorrect', JText::sprintf('COM_CSVI_MEDIAFILE_NOT_ADDED', $this->_images->getError()));
         }
         // Store the debug message
         $csvilog->addDebug(JText::_('COM_CSVI_IMAGEFILE_QUERY'), true);
     }
     // Clean the tables
     $this->cleanTables();
 }
開發者ID:alesconti,項目名稱:FF_2015,代碼行數:69,代碼來源:imageimport.php


注:本文中的ImageHelper::addWatermark方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。