CSS形式的照片方向


Orientation of photos in CSS form

我正在制作一张表格,从我的数据库中拍摄照片,并在A4纸上"准备打印"。一些照片是按高度定向的,例如:800x600&有些是例如600x800。我需要一些php脚本,自动旋转水平照片到垂直&vertaly照片保持其方向。

您可以将imagerotate与php一起使用。。http://www.php.net/manual/fr/function.imagerotate.php

您需要这样的东西:

$filename="image.jpg";

// get the width and height from the image
list($width, $height, $type, $attr) = getimagesize($filename);
//if image width is bigger then the height it will execute the following script
if ($width > height){
 // Load the image
$source = imagecreatefromjpeg($filename);
// Rotate
$rotate = imagerotate($source, $degrees, 0);
//and save it on your server...
file_put_contents("myNEWimage.jpg",$rotate);
}

你可以做一些调整和测试。正在忙于atm工作,所以没有时间测试它。

问候