i did the cropping on my own - that means: calculate the resize in PHP and then decide which area you have to cut off from your image. here's the function that i wrote for that, maybe you find it useful.
//------------------------------------------------------------
// FUNCTION resize
//------------------------------------------------------------
/**
* @iFile - Die Input Bilddatei
* @oFile - Die Output Bilddatei
* @ox, oy - Grösse der Output Bilddatei
* @crop - Wenn true, wird Bild beschnitten. Wenn false ist ein
* Rand sichtbar.
* @bw - borderWidth, Pixelbreite des Rahmens, wenn 0: kein Rahmen.
*/
function resize($iFile,$oFile,$oX,$oY,$crop, $bW=0 )
{
// ImageMagick Command Strings
$cStr = ""; // crop
$gStr = ""; // geometry
$qStr = ""; // quality
$bStr = ""; // border
// Image border
$bColor = "#cccccc";
// Get information on input
$info = $this->getInfo($iFile);
if($info == false){
return false;
}
$iType = $info[type];
$iX = $info[x];
$iY = $info[y];
// Fit image into border
if($bW > 0){
if($oX > 0){ $oX -= 2*$bW; }
if($oY > 0){ $oY -= 2*$bW; }
// create BORDER command
$bStr = '-bordercolor "'.$bColor.'" -border '.$bW.'x'.$bW;
}
// Extract extension from output-file
$pInfo = pathinfo($oFile);
$oType = strtolower($pInfo[extension]);
// Shrink to Image Size if smaller than output size
if($iX < $oX){ $oX = $iX; }
if($iY < $oY){ $oY = $iY; }
$nX = $oX;
$nY = $oY;
// scaled x,y
if($oX > 0){ $sY = ceil($iY/($iX/$oX)); }
if($oY > 0){ $sX = ceil($iX/($iY/$oY)); }
$sMode = "No Scaling";
// Choose type of scaling, cropping
if($oX > 0 && $oY == 0){
// Scale Y Only
$sMode = "Scale Y only";
$nX = $oX;
$nY = $sY;
}
else if($oX == 0 && $oY > 0){
// Scale X Only
$sMode = "Scale X only";
$nX = $sX;
$nY = $oY;
}
else if($oX > 0 && $oY > 0){
// Scale both
if($crop){
// Scale and Crop
// Choose scale with less crop area
if($sY < $oY){
// Crop X
$sMode = "Scale Both, Crop X";
$nX = $sX;
$nY = $oY;
$cX = ceil(($sX-$oX)/2);
$cY = 0;
}
else{
// Crop Y
$sMode = "Scale Both, Crop Y";
$nX = $oX;
$nY = $sY;
$cX = 0;
$cY = ceil(($sY-$oY)/2);
}
// Create CROP command
$cStr = "-crop ".$oX."x".$oY."+$cX+$cY";
}
else{
// Scale both, No crop
$sMode = "Scale Both, No Crop";
$nX = $oX;
$nY = $sY;
if($nY > $oY){
// Rescale to fit size
$sMode = "Scale Both (resized), No Crop ";
$nX = ceil($nX/($nY/$oY));
$nY = $oY;
}
}
}
// Create GEOMETRY command
$gStr = "-geometry ".$nX."x".$nY;
// Create QUALITY command for specified type
// Check if quality is set
if( !strlen($this->quality) )
{
// Default settings
switch($oType){
case "jpg":
case "jpeg":
$qStr = "-quality 50";
break;
case "png":
$qStr = "-quality 1 -colors 16";
break;
}
}
else
$qStr = $this->quality;
// Create ImageMagick Execution String
$execStr = IMAGEMAGICK_DIR."convert $gStr $cStr $bStr $qStr $iFile +profile \"*\" $oFile";
// create thumbnail image
exec( $execStr, $systemOutput, $systemReturn );
// return report on success
if( $systemReturn != 0 )
{
return false;
}
else
{
$pInfo = pathinfo($iFile);
$report[Input_File] = $pInfo['basename'];
$report[Input_Type] = $iType;
$report[Input_Size] = "$iX x $iY";
$report[Scale_Mode] = $sMode;
$pInfo = pathinfo($oFile);
$report[Output_File] = $pInfo[basename];
$report[Output_Type] = $oType;
$fInfo = $this->getInfo($oFile);
$report[Output_Width] = $fInfo[x];
$report[Output_Height] = $fInfo[y];
$report[Output_Crop] = "Left:$cX Top:$cY";
return $report;
}
}