IMAGE ROTATION CONCEPT USING PHP

In this tutorial i am explain about how to rotate image using php by giving the degree of rotation. This is one of the simple concept using this concept you can rotate your image how you want.

This image rotation concept is most useful in gallery pages. You can able to fix the image where you want. you can able rotate image yourself in different ways.

image-rotation-concept

Image rotation Concept : 

index.php

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>image-rotation-concept using php</title>
</head>

<body>

<?php
    $filename = 'image-rotation-concept.jpg';
    $rotang = 60; // Rotation angle
    $source = imagecreatefromjpeg($filename) or die('Error opening file '.$filename);
    imagealphablending($source, false);
    imagesavealpha($source, true);

    $rotation = imagerotate($source, $rotang, imageColorAllocateAlpha($source, 0, 0, 0, 127));
    imagealphablending($rotation, false);
    imagesavealpha($rotation, true);

    header('Content-type: image/jpeg');
    imagepng($rotation);
    imagedestroy($source);
    imagedestroy($rotation);
?>


</body>
</html>


Download code


Post a Comment

0 Comments