registerHandlers(); // make sure to call it only once! before the first usage, no need to call it every time * $sTranscodedImageUrl = $oTranscoder->getFileUrl('my_dog.jpg'); // the name of file, in the case of 'Folder' storage type this is file name * echo 'My dog : '; // transcoded(resized and/or grayscaled) image will be shown, according to the specified filters * @endcode * */ class BxDolTranscoderImage extends BxDolTranscoder implements iBxDolFactoryObject { protected function __construct($aObject, $oStorage) { parent::__construct($aObject, $oStorage); $this->_oDb = new BxDolTranscoderImageQuery($aObject, false); $this->_sQueueTable = $this->_oDb->getQueueTable(); } /** * Get file url when file isn't transcoded yet */ public function getFileUrlNotReady($mixedHandler) { return BX_DOL_URL_ROOT . 'image_transcoder.php?o=' . $this->_aObject['object'] . '&h=' . $mixedHandler . '&dpx=' . $this->getDevicePixelRatio() . '&t=' . time(); } protected function applyFilter_Grayscale ($sFile, $aParams) { bx_import ('BxDolImageResize'); $o = BxDolImageResize::getInstance(); $o->removeCropOptions (); $this->_checkForceType ($o, $aParams); if (IMAGE_ERROR_SUCCESS == $o->grayscale($sFile)) return true; return false; } protected function applyFilter_Resize ($sFile, $aParams) { bx_import ('BxDolImageResize'); $o = BxDolImageResize::getInstance(); $o->removeCropOptions (); if (isset($aParams['w']) && isset($aParams['h'])) $o->setSize ($aParams['w'] * $this->getDevicePixelRatio(), $aParams['h'] * $this->getDevicePixelRatio()); if (isset($aParams['crop_resize']) && $aParams['crop_resize']) { $o->setAutoCrop (true); } elseif (isset($aParams['square_resize']) && $aParams['square_resize']) { $o->setSquareResize (true); } else { $o->setSquareResize (false); } $this->_checkForceType ($o, $aParams); if (IMAGE_ERROR_SUCCESS == $o->resize($sFile)) return true; return false; } protected function _checkForceType ($oImageProcessor, $aParams) { if (empty($aParams['force_type'])) $aParams['force_type'] = false; switch ($aParams['force_type']) { case 'jpeg': case 'jpg': $oImageProcessor->setOutputType(IMAGE_TYPE_JPG); break; case 'png': $oImageProcessor->setOutputType(IMAGE_TYPE_PNG); break; case 'gif': $oImageProcessor->setOutputType(IMAGE_TYPE_GIF); break; default: $oImageProcessor->setOutputType(false); break; } } } /** @} */