2013-12-16 21 views
0

我是從我的數據庫中「準備打印」A4紙上照片的金手指形式。 有些照片是以高度爲導向的,例如:800x600 &有些照片是例如600x800。我需要一些PHP腳本,自動旋轉水平照片垂直&垂直照片保持其方向。以CSS格式表示照片的方向

+0

看到這個:http://stackoverflow.com/questions/3657023/how-to-detect-shot-angle-of-photo-and-auto-rotate-for-website-display-like -desk – Huey

回答

0

你需要的東西是這樣的:

$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,所以沒有時間去測試它。

問候

+0

我喜歡這裏:注意:未定義的變量:第70行中的/home/doprava/www/dano/foto.php中的度數 警告:file_put_contents():提供的資源不是/ new/index中的有效流資源73線上的.php – WanderRook

+0

hmm使得$ degree = 90;它輸出的是什麼? –

相關問題