6 require_once getShopBasePath() .
"core/utils/oxpicgenerator.php";
18 protected $_aImageTypes = array(
"GIF" => IMAGETYPE_GIF,
"JPG" => IMAGETYPE_JPEG,
"PNG" => IMAGETYPE_PNG,
"JPEG" => IMAGETYPE_JPEG);
50 public function resizeImage( $sSrc, $sTarget, $iDesiredWidth, $iDesiredHeight )
55 if ( ( $iUseGDVersion = getGdVersion() ) && function_exists(
'imagecreate' ) &&
56 file_exists( $sSrc ) && ( $aImageInfo = @getimagesize( $sSrc ) ) ) {
59 list( $iWidth, $iHeight ) = calcImageSize( $iDesiredWidth, $iDesiredHeight, $aImageInfo[0], $aImageInfo[1] );
60 $blResize = $this->
_resize( $aImageInfo, $sSrc, null, $sTarget, $iWidth, $iHeight, $iUseGDVersion,
$myConfig->getConfigParam(
'blDisableTouch' ),
$myConfig->getConfigParam(
'sDefaultImageQuality' ) );
98 if ( !
$myConfig->isDemoShop() && ( strpos( $sPicName,
'nopic.jpg' ) ===
false ||
99 strpos( $sPicName,
'nopic_ico.jpg' ) === false ) ) {
101 $sFile =
"$sAbsDynImageDir/$sPicName";
103 if ( file_exists( $sFile ) && is_file( $sFile ) ) {
104 $blDeleted = unlink( $sFile );
107 if ( !
$myConfig->getConfigParam(
'sAltImageUrl' ) ) {
109 $sGenPath = str_replace(
'/master/',
'/generated/', $sAbsDynImageDir );
110 $aFiles = glob(
"{$sGenPath}*/{$sPicName}" );
111 if ( is_array($aFiles) ) {
112 foreach ( $aFiles as $sFile ) {
113 $blDeleted = unlink( $sFile );
134 if ( !$sPicName || strpos( $sPicName,
'nopic.jpg' ) !==
false || strpos( $sPicName,
'nopic_ico.jpg' ) !==
false ) {
139 $iCountUsed = $oDb->getOne(
"select count(*) from $sTable where $sField = ".$oDb->quote( $sPicName ).
" group by $sField ",
false,
false);
140 return $iCountUsed > 1 ?
false :
true;
156 public function overwritePic( $oObject, $sPicTable, $sPicField, $sPicType, $sPicDir, $aParams, $sAbsDynImageDir )
159 $sPic = $sPicTable.
'__'.$sPicField;
160 if ( isset( $oObject->{$sPic} ) &&
161 ( $_FILES[
'myfile'][
'size'][$sPicType.
'@'.$sPic] > 0 || $aParams[$sPic] != $oObject->{$sPic}->value ) ) {
163 $sImgDir = $sAbsDynImageDir .
oxRegistry::get(
"oxUtilsFile")->getImageDirByType($sPicType);
164 $blDelete = $this->safePictureDelete($oObject->{$sPic}->value, $sImgDir, $sPicTable, $sPicField );
184 protected function _resizeGif( $sSrc, $sTarget, $iNewWidth, $iNewHeight, $iOriginalWidth, $iOriginalHeigth, $iGDVer, $blDisableTouch )
186 return resizeGif( $sSrc, $sTarget, $iNewWidth, $iNewHeight, $iOriginalWidth, $iOriginalHeigth, $iGDVer, $blDisableTouch );
204 protected function _resize( $aImageInfo, $sSrc, $hDestinationImage, $sTarget, $iNewWidth, $iNewHeight, $iGdVer, $blDisableTouch, $iDefQuality )
206 startProfile(
"PICTURE_RESIZE");
209 switch ( $aImageInfo[2] ) {
210 case ( $this->_aImageTypes[
"GIF"] ):
212 if ( function_exists(
"imagegif" ) ) {
213 $blSuccess = resizeGif( $sSrc, $sTarget, $iNewWidth, $iNewHeight, $aImageInfo[0], $aImageInfo[1], $iGdVer );
216 case ( $this->_aImageTypes[
"JPEG"] ):
217 case ( $this->_aImageTypes[
"JPG"] ):
218 $blSuccess = resizeJpeg( $sSrc, $sTarget, $iNewWidth, $iNewHeight, $aImageInfo, $iGdVer, $hDestinationImage, $iDefQuality );
220 case ( $this->_aImageTypes[
"PNG"] ):
221 $blSuccess = resizePng( $sSrc, $sTarget, $iNewWidth, $iNewHeight, $aImageInfo, $iGdVer, $hDestinationImage );
225 if ( $blSuccess && !$blDisableTouch ) {
229 stopProfile(
"PICTURE_RESIZE");
248 protected function _copyAlteredImage( $sDestinationImage, $sSourceImage, $iNewWidth, $iNewHeight, $aImageInfo, $sTarget, $iGdVer, $blDisableTouch )
250 $blSuccess = copyAlteredImage( $sDestinationImage, $sSourceImage, $iNewWidth, $iNewHeight, $aImageInfo, $sTarget, $iGdVer );
251 if ( !$blDisableTouch && $blSuccess ) {