I am makin form which taking photos from my database "ready to print" on A4 paper. Some photos are orientated on height eg: 800x600 & some are eg 600x800. I need some php script which automaticly rotate horizontal photo to vertical & vertaly photos keep in their orientation.
Asked
Active
Viewed 79 times
0
-
See this: http://stackoverflow.com/questions/3657023/how-to-detect-shot-angle-of-photo-and-auto-rotate-for-website-display-like-desk – Huey Dec 16 '13 at 09:32
2 Answers
0
you can use imagerotate with php.. http://www.php.net/manual/fr/function.imagerotate.php

Mazeltov
- 541
- 5
- 18
0
you need something like this:
$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);
}
You might do some adjustments and testing. are busy at work atm so dont have time to test it.
Greetings

Merijndk
- 1,674
- 3
- 18
- 35
-
I receied this: Notice: Undefined variable: degrees in /home/doprava/www/dano/foto.php on line 70 Warning: file_put_contents(): supplied resource is not a valid stream resource in /new/index.php on line 73 – WanderRook Dec 16 '13 at 13:19
-