Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php rotate image


After some INet searches and personal try-and-failures I succeed to rotate PNG images with preserving alpha channel transparency (semi transparency).

<?php
    $filename = 'YourFile.png';
    $rotang = 20; // Rotation angle
    $source = imagecreatefrompng($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/png');
    imagepng($rotation);
    imagedestroy($source);
    imagedestroy($rotation);
?>

Comment

PREVIOUS NEXT
Code Example
Php :: php preg match space or start of string 
Php :: phpmyadmin username password check 
Php :: get_the_category() 
Php :: readfile in php 
Php :: cache an array 
Php :: php new object 
Php :: codeigniter form validation datetime 
Php :: laravel migration remove nullable 
Php :: php file download from url 
Php :: laravel check if item is in collection 
Php :: file could not be downloaded: Unable to find the wrap per "https" - did you forget to enable it when you configured PHP? failed to open stream: No such file or directory 
Php :: how to get public folder path in laravel 
Php :: add options page advanced custom fields 
Php :: get custom post type taxonomy value 
Php :: DateTime and Timestamps 
Php :: php strftime datetime 
Php :: php session variables 
Php :: how to add custom field in comment form in wordpress 
Php :: for else laravel 
Php :: run schedule laravel 
Php :: return two variables php 
Php :: Laravel stop on first validation error 
Php :: withdefault laravel 
Php :: laravel value eloquent 
Php :: laravel validation double 
Php :: php .= 
Php :: php get first character of each word 
Php :: removing index.php in codeigniter 
Php :: php.hello 
Php :: laravel maximum execution time of 30 seconds exceeded 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =