what is best way to rotate an image using php or convert command?
Asked
Active
Viewed 1,883 times
-4
-
Hi there. We rather prefer questions that have been researched here, so I am downvoting. How to rotate an image using `convert` is in the IM manual. – halfer May 14 '15 at 07:00
3 Answers
2
With Imagick, use rotateImage
<?php
$image = new Imagick("source.kpg");
$image->rotateImage ( 'white', 90.0 );

emcconville
- 23,800
- 4
- 50
- 66
1
You can do this with ImageMagick. The following command will rotate the image:
convert original_file.jpg -rotate 90 new_file.jpg

dlemstra
- 7,813
- 2
- 27
- 43

ashkufaraz
- 5,179
- 6
- 51
- 82
1
Use the PHP function imagerotate
http://php.net/manual/en/function.imagerotate.php
Example:
<?php
// File and rotation
$filename = 'test.jpg';
$degrees = 180;
// Content type
header('Content-type: image/jpeg');
// Load
$source = imagecreatefromjpeg($filename);
// Rotate
$rotate = imagerotate($source, $degrees, 0);
// Output
imagejpeg($rotate);
// Free the memory
imagedestroy($source);
imagedestroy($rotate);
?>

ollierexx
- 511
- 1
- 5
- 15