コード例 #1
0
 /**
  * Get focus point information
  *
  * @param $uid
  *
  * @return array|FALSE|NULL
  */
 protected function getCurrentFocusPoint($uid)
 {
     $row = GlobalUtility::getDatabaseConnection()->exec_SELECTgetSingleRow('focus_point_x, focus_point_y', 'sys_file_metadata', 'uid=' . $uid);
     $row['focus_point_x'] = MathUtility::forceIntegerInRange((int) $row['focus_point_x'], -100, 100, 0);
     $row['focus_point_y'] = MathUtility::forceIntegerInRange((int) $row['focus_point_y'], -100, 100, 0);
     return $row;
 }
コード例 #2
0
ファイル: Group.php プロジェクト: mcmz/focuspoint
 /**
  * Set the point (between -100 and 100)
  *
  * @param int $x
  * @param int $y
  * @return void
  */
 public function setCurrentPoint($x, $y)
 {
     $connection = GlobalUtility::getDatabaseConnection();
     $row = $connection->exec_SELECTgetSingleRow('uid', self::TABLE, 'relative_file_path = ' . $connection->fullQuoteStr($this->getRelativeFilePath(), self::TABLE));
     $values = ['focus_point_x' => $x, 'focus_point_y' => $y, 'relative_file_path' => $this->getRelativeFilePath()];
     if ($row) {
         $connection->exec_UPDATEquery(self::TABLE, 'uid=' . $row['uid'], $values);
     } else {
         $connection->exec_INSERTquery(self::TABLE, $values);
     }
 }
コード例 #3
0
ファイル: FileReference.php プロジェクト: mcmz/focuspoint
 /**
  * Set the point (between -100 and 100)
  *
  * @param int $x
  * @param int $y
  * @return void
  */
 public function setCurrentPoint($x, $y)
 {
     $values = ['focus_point_x' => MathUtility::forceIntegerInRange($x, -100, 100, 0), 'focus_point_y' => MathUtility::forceIntegerInRange($y, -100, 100, 0)];
     GlobalUtility::getDatabaseConnection()->exec_UPDATEquery('sys_file_reference', 'uid=' . $this->getReferenceUid(), $values);
     // save also to the file
     $reference = ResourceFactory::getInstance()->getFileReferenceObject($this->getReferenceUid());
     $fileUid = $reference->getOriginalFile()->getUid();
     $row = GlobalUtility::getDatabaseConnection()->exec_SELECTgetSingleRow('*', 'sys_file_metadata', 'file=' . $fileUid);
     if ($row) {
         GlobalUtility::getDatabaseConnection()->exec_UPDATEquery('sys_file_metadata', 'uid=' . $row['uid'], $values);
     }
 }
コード例 #4
0
ファイル: File.php プロジェクト: mcmz/focuspoint
 /**
  * Set the point (between -100 and 100)
  *
  * @param int $x
  * @param int $y
  * @return void
  */
 public function setCurrentPoint($x, $y)
 {
     $values = ['focus_point_x' => MathUtility::forceIntegerInRange($x, -100, 100, 0), 'focus_point_y' => MathUtility::forceIntegerInRange($y, -100, 100, 0)];
     GlobalUtility::getDatabaseConnection()->exec_UPDATEquery('sys_file_metadata', 'uid=' . $this->getMataDataUid(), $values);
 }
コード例 #5
0
 /**
  * Get the meta data uid by file uid
  *
  * @param $fileUid
  *
  * @return int
  */
 protected function getMetaDataUidByFileUid($fileUid)
 {
     $row = GlobalUtility::getDatabaseConnection()->exec_SELECTgetSingleRow('uid', 'sys_file_metadata', 'file=' . (int) $fileUid);
     return isset($row['uid']) ? $row['uid'] : 0;
 }
コード例 #6
0
ファイル: FocusCropService.php プロジェクト: mcmz/focuspoint
 /**
  * Get the cropped image by src
  *
  * @param string $src Relative file name
  * @param string $ratio
  * @param int $x
  * @param int $y
  *
  * @return string The new filename
  */
 public function getCroppedImageSrcBySrc($src, $ratio, $x, $y)
 {
     $absoluteImageName = GeneralUtility::getFileAbsFileName($src);
     if (!is_file($absoluteImageName)) {
         return null;
     }
     $focusPointX = MathUtility::forceIntegerInRange((int) $x, -100, 100, 0);
     $focusPointY = MathUtility::forceIntegerInRange((int) $y, -100, 100, 0);
     if ($focusPointX === 0 && $focusPointY === 0) {
         $connection = GlobalUtility::getDatabaseConnection();
         $row = $connection->exec_SELECTgetSingleRow('uid,focus_point_x,focus_point_y', Group::TABLE, 'relative_file_path = ' . $connection->fullQuoteStr($src, Group::TABLE));
         if ($row) {
             $focusPointX = MathUtility::forceIntegerInRange((int) $row['focus_point_x'], -100, 100, 0);
             $focusPointY = MathUtility::forceIntegerInRange((int) $row['focus_point_y'], -100, 100, 0);
         }
     }
     $hash = function_exists('sha1_file') ? sha1_file($absoluteImageName) : md5_file($absoluteImageName);
     $tempImageFolder = 'typo3temp/focuscrop/';
     $tempImageName = $tempImageFolder . $hash . '-fp-' . preg_replace('/[^0-9]/', '-', $ratio) . '-' . $focusPointX . '-' . $focusPointY . '.' . PathUtility::pathinfo($absoluteImageName, PATHINFO_EXTENSION);
     $absoluteTempImageName = GeneralUtility::getFileAbsFileName($tempImageName);
     if (is_file($absoluteTempImageName)) {
         return $tempImageName;
     }
     $absoluteTempImageFolder = GeneralUtility::getFileAbsFileName($tempImageFolder);
     if (!is_dir($absoluteTempImageFolder)) {
         GeneralUtility::mkdir_deep($absoluteTempImageFolder);
     }
     $imageSizeInformation = getimagesize($absoluteImageName);
     $width = $imageSizeInformation[0];
     $height = $imageSizeInformation[1];
     // dimensions
     /** @var \HDNET\Focuspoint\Service\DimensionService $dimensionService */
     $dimensionService = GeneralUtility::makeInstance('HDNET\\Focuspoint\\Service\\DimensionService');
     list($focusWidth, $focusHeight) = $dimensionService->getFocusWidthAndHeight($width, $height, $ratio);
     $cropMode = $dimensionService->getCropMode($width, $height, $ratio);
     list($sourceX, $sourceY) = $dimensionService->calculateSourcePosition($cropMode, $width, $height, $focusWidth, $focusHeight, $focusPointX, $focusPointY);
     // generate image
     if (strtolower(PathUtility::pathinfo($absoluteImageName, PATHINFO_EXTENSION)) == 'png') {
         $this->createCropImageGifBuilder($absoluteImageName, $focusWidth, $focusHeight, $sourceX, $sourceY, $absoluteTempImageName);
     } else {
         $this->createCropImageGraphicalFunctions($absoluteImageName, $focusWidth, $focusHeight, $sourceX, $sourceY, $absoluteTempImageName);
     }
     return $tempImageName;
 }