Index: t3lib/class.t3lib_stdgraphic.php =================================================================== --- t3lib/class.t3lib_stdgraphic.php (Revision 9371) +++ t3lib/class.t3lib_stdgraphic.php (Arbeitskopie) @@ -2331,6 +2331,13 @@ $data = $this->getImageScale($info,$w,$h,$options); $w=$data['origW']; $h=$data['origH']; + + // check if there is a specific resolution (DPI) set + $resolution = intval($options['resolution']); + $resolutionFactor = ($resolution > 35 ? $resolution / 72.0 : NULL); + + // check if original image is smaller than requested + $origImageIsSmaller = ($resolutionFactor && $info[0] <= intval($data[0] * $resolutionFactor) && $info[1] <= intval($data[1] * $resolutionFactor)); // if no conversion should be performed // this flag is true if the width / height does NOT dictate @@ -2339,7 +2346,8 @@ // dimensions or if the option to not scale the image is set) $noScale = (!$w && !$h) || ($data[0] == $info[0] && $data[1] == $info[1]) || $options['noScale']; - if ($noScale && !$data['crs'] && !$params && !$frame && $newExt == $info[2] && !$mustCreate) { + // return original image, if noScale is set OR if original image is smaller than requested (upscale doesnt make sense ...) + if (($noScale && !$data['crs'] && !$params && !$frame && $newExt == $info[2] && !$mustCreate) || $origImageIsSmaller) { // set the new width and height before returning, // if the noScale option is set if ($options['noScale']) { @@ -2364,11 +2372,25 @@ if (!$data['origH']) { $data['origH'] = $data[1]; } $offsetX = intval(($data[0] - $data['origW']) * ($data['cropH']+100)/200); $offsetY = intval(($data[1] - $data['origH']) * ($data['cropV']+100)/200); - $params .= ' -crop '.$data['origW'].'x'.$data['origH'].'+'.$offsetX.'+'.$offsetY.' '; + + // update the width and height, if the resolution is different + if ($resolutionFactor) { + $params .= ' -crop ' . ($data['origW'] * $resolutionFactor) . 'x' . ($data['origH'] * $resolutionFactor) . '+' . ($offsetX * $resolutionFactor) . '+' . ($offsetY) . ' '; + } else { + $params .= ' -crop ' . $data['origW'] . 'x' . $data['origH'] . '+' . $offsetX . '+' . $offsetY . ' '; + } } - $command = $this->scalecmd.' '.$info[0].'x'.$info[1].'! '.$params.' '; - $cropscale = ($data['crs'] ? 'crs-V'.$data['cropV'].'H'.$data['cropH'] : ''); + // if rendered in a different resolution, add an additional parameter + // and update the command to multiply with the resolution factor + if ($resolutionFactor) { + $params .= ' -density ' . $resolution . 'x' . $resolution . ' '; + $command = $this->scalecmd . ' ' . intval($info[0] * $resolutionFactor) . 'x' . intval($info[1] * $resolutionFactor) . '! ' . $params . ' '; + $cropscale = ($data['crs'] ? 'crs-V' . intval($data['cropV'] * $resolutionFactor) . 'H' . intval($data['cropH'] * $resolutionFactor) : ''); + } else { + $command = $this->scalecmd . ' ' . $info[0] . 'x' . $info[1] . '! ' . $params . ' '; + $cropscale = ($data['crs'] ? 'crs-V' . $data['cropV'] . 'H' . $data['cropH'] : ''); + } if ($this->alternativeOutputKey) { $theOutputName = t3lib_div::shortMD5($command.$cropscale.basename($imagefile).$this->alternativeOutputKey.'['.$frame.']'); @@ -2393,8 +2415,14 @@ if (file_exists($output)) { $info[3] = $output; $info[2] = $newExt; - if ($params) { // params could realisticly change some imagedata! - $info=$this->getImageDimensions($info[3]); + // params could realisticly change some imagedata! + if ($params) { + $info = $this->getImageDimensions($info[3]); + // update the width and height, if the resolution is different + if ($resolutionFactor) { + $info[0] = intval($info[0] / $resolutionFactor); + $info[1] = intval($info[1] / $resolutionFactor); + } } if ($info[2]==$this->gifExtension && !$this->dontCompress) { t3lib_div::gif_compress($info[3],''); // Compress with IM (lzw) or GD (rle) (Workaround for the absence of lzw-compression in GD) Index: typo3/sysext/cms/tslib/class.tslib_content.php =================================================================== --- typo3/sysext/cms/tslib/class.tslib_content.php (Revision 9371) +++ typo3/sysext/cms/tslib/class.tslib_content.php (Arbeitskopie) @@ -4753,6 +4753,7 @@ $fileArray['minW'] = intval($this->stdWrap($fileArray['minW'], $fileArray['minW.'])); $fileArray['minH'] = intval($this->stdWrap($fileArray['minH'], $fileArray['minH.'])); $fileArray['noScale'] = $this->stdWrap($fileArray['noScale'], $fileArray['noScale.']); + $fileArray['resolution'] = $this->stdWrap($fileArray['resolution'], $fileArray['resolution.']); $maskArray = $fileArray['m.']; $maskImages = array(); if (is_array($fileArray['m.'])) { // Must render mask images and include in hash-calculating - else we cannot be sure the filename is unique for the setup! @@ -4804,6 +4805,9 @@ if ($fileArray['noScale']) { $options['noScale'] = $fileArray['noScale']; } + if ($fileArray['resolution']) { + $options['resolution'] = $fileArray['resolution']; + } // checks to see if m (the mask array) is defined if (is_array($maskArray) && $GLOBALS['TYPO3_CONF_VARS']['GFX']['im']) {