6 require_once getShopBasePath() .
"core/utils/oxpicgenerator.php";
19 protected $_aImageTypes = array(
"GIF" => IMAGETYPE_GIF,
"JPG" => IMAGETYPE_JPEG,
"PNG" => IMAGETYPE_PNG,
"JPEG" => IMAGETYPE_JPEG);
31 public function resizeImage($sSrc, $sTarget, $iDesiredWidth, $iDesiredHeight)
36 if (($iUseGDVersion = getGdVersion()) && function_exists(
'imagecreate') &&
37 file_exists($sSrc) && ($aImageInfo = @getimagesize($sSrc))
41 list($iWidth, $iHeight) = calcImageSize($iDesiredWidth, $iDesiredHeight, $aImageInfo[0], $aImageInfo[1]);
42 $blResize = $this->
_resize($aImageInfo, $sSrc, null, $sTarget, $iWidth, $iHeight, $iUseGDVersion,
$myConfig->getConfigParam(
'blDisableTouch'),
$myConfig->getConfigParam(
'sDefaultImageQuality'));
82 if (!
$myConfig->isDemoShop() && (strpos($sPicName,
'nopic.jpg') ===
false ||
83 strpos($sPicName,
'nopic_ico.jpg') ===
false)
86 $sFile =
"$sAbsDynImageDir/$sPicName";
88 if (file_exists($sFile) && is_file($sFile)) {
89 $blDeleted = unlink($sFile);
92 if (!
$myConfig->getConfigParam(
'sAltImageUrl')) {
94 $sGenPath = str_replace(
'/master/',
'/generated/', $sAbsDynImageDir);
95 $aFiles = glob(
"{$sGenPath}*/{$sPicName}");
96 if (is_array($aFiles)) {
97 foreach ($aFiles as $sFile) {
98 $blDeleted = unlink($sFile);
120 if (!$sPicName || strpos($sPicName,
'nopic.jpg') !==
false || strpos($sPicName,
'nopic_ico.jpg') !==
false) {
125 $iCountUsed = $oDb->getOne(
"select count(*) from $sTable where $sField = " . $oDb->quote($sPicName) .
" group by $sField ",
false,
false);
127 return $iCountUsed > 1 ?
false :
true;
143 public function overwritePic($oObject, $sPicTable, $sPicField, $sPicType, $sPicDir, $aParams, $sAbsDynImageDir)
146 $sPic = $sPicTable .
'__' . $sPicField;
147 if (isset($oObject->{$sPic}) &&
148 ($_FILES[
'myfile'][
'size'][$sPicType .
'@' . $sPic] > 0 || $aParams[$sPic] != $oObject->{$sPic}->value)
151 $sImgDir = $sAbsDynImageDir .
oxRegistry::get(
"oxUtilsFile")->getImageDirByType($sPicType);
152 $blDelete = $this->safePictureDelete($oObject->{$sPic}->value, $sImgDir, $sPicTable, $sPicField);
172 protected function _resizeGif($sSrc, $sTarget, $iNewWidth, $iNewHeight, $iOriginalWidth, $iOriginalHeigth, $iGDVer, $blDisableTouch)
174 return resizeGif($sSrc, $sTarget, $iNewWidth, $iNewHeight, $iOriginalWidth, $iOriginalHeigth, $iGDVer, $blDisableTouch);
192 protected function _resize($aImageInfo, $sSrc, $hDestinationImage, $sTarget, $iNewWidth, $iNewHeight, $iGdVer, $blDisableTouch, $iDefQuality)
194 startProfile(
"PICTURE_RESIZE");
197 switch ($aImageInfo[2]) {
198 case ($this->_aImageTypes[
"GIF"]):
200 if (function_exists(
"imagegif")) {
201 $blSuccess = resizeGif($sSrc, $sTarget, $iNewWidth, $iNewHeight, $aImageInfo[0], $aImageInfo[1], $iGdVer);
204 case ($this->_aImageTypes[
"JPEG"]):
205 case ($this->_aImageTypes[
"JPG"]):
206 $blSuccess = resizeJpeg($sSrc, $sTarget, $iNewWidth, $iNewHeight, $aImageInfo, $iGdVer, $hDestinationImage, $iDefQuality);
208 case ($this->_aImageTypes[
"PNG"]):
209 $blSuccess = resizePng($sSrc, $sTarget, $iNewWidth, $iNewHeight, $aImageInfo, $iGdVer, $hDestinationImage);
213 if ($blSuccess && !$blDisableTouch) {
217 stopProfile(
"PICTURE_RESIZE");
236 protected function _copyAlteredImage($sDestinationImage, $sSourceImage, $iNewWidth, $iNewHeight, $aImageInfo, $sTarget, $iGdVer, $blDisableTouch)
238 $blSuccess = copyAlteredImage($sDestinationImage, $sSourceImage, $iNewWidth, $iNewHeight, $aImageInfo, $sTarget, $iGdVer);
239 if (!$blDisableTouch && $blSuccess) {