/** * Calculates and returns the properties (width/height) of a thumbail/scaled image. * * Return value is an array containing calculated width/height and extension. * * @param sfFilebasePluginImage $fileinfo * @param integer $new_width * @param integer $new_height * @throws sfFilebasePluginException * @return array $thumbnail_properties */ public function getScaledImageData(sfFilebasePluginImage $image, array $dimensions) { $width = 0; $height = 0; $new_width = null; $new_height = null; // @todo, den check mach ich auch beim copyResampled. Hier nur gebraucht für filename isset($dimensions[0]) && ($dimensions['width'] = $dimensions[0]); isset($dimensions[1]) && ($dimensions['height'] = $dimensions[1]); isset($dimensions['width']) && (int) $dimensions['width'] > 0 && ($new_width = $dimensions['width']); isset($dimensions['height']) && (int) $dimensions['height'] > 0 && ($new_height = $dimensions['height']); if ($new_width === null && $new_height === null) { throw new sfFilebasePluginException('Dimensions are not properly set.'); } $extension = $image->getExtension(); list($width, $height) = $image->getImagesize(); if ($new_height === null) { $new_height = round($height * $new_width / $width); } elseif ($new_width === null) { $new_width = round($width * $new_height / $height); } return array('orig_width' => $width, 'orig_height' => $height, 'new_width' => $new_width, 'new_height' => $new_height, 'extension' => $extension, 'mime' => sfFilebasePluginUtil::getMimeType($image)); }