こんにちは、
中心を中心に円形の画像を回転させてから、側面を切り取ろうとしています。imagerotate機能が表示されますが、中心を中心に回転していないようです。
誰か提案がありますか?
ありがとうございました。
更新:円なので、エッジを切り取り、円を同じ寸法に保ちたいと思います。
私は次のコードでその問題にうまく直面しました
$width_before = imagesx($img1);
$height_before = imagesy($img1);
$img1 = imagerotate($img1, $angle, $mycolor);
//but imagerotate scales, so we clip to the original size
$img2 = @imagecreatetruecolor($width_before, $height_before);
$new_width = imagesx($img1); // whese dimensions are
$new_height = imagesy($img1);// the scaled ones (by imagerotate)
imagecopyresampled(
$img2, $img1,
0, 0,
($new_width-$width_before)/2,
($new_height-$height_before)/2,
$width_before,
$height_before,
$width_before,
$height_before
);
$img1 = $img2;
// now img1 is center rotated and maintains original size
それが役に立てば幸い。
さよなら
PHPのマニュアルimagerotate()ページによると:
回転の中心は画像の中心であり、回転した画像全体が目的の画像に収まるように、回転した画像が縮小されます。エッジはクリップされません。
おそらく、画像の目に見える中心は実際の中心ではありませんか?