diff options
author | BlueRaja <BlueRaja.admin@gmail.com> | 2013-03-19 03:26:48 -0500 |
---|---|---|
committer | BlueRaja <BlueRaja.admin@gmail.com> | 2013-03-19 03:26:48 -0500 |
commit | b6680dd405fdf6cd2784facfe799742cfaf805ab (patch) | |
tree | e9cd81aebfc67c76053792583efb0a1fe942ff6c /images/marks/rotate.php | |
parent | a600bd24aa5272dfd3b9f178ef9e2c81ec0525b9 (diff) | |
parent | bc57b007dfa5e6e723946143671a9db68a82f348 (diff) | |
download | pathery-b6680dd405fdf6cd2784facfe799742cfaf805ab.tar.xz |
Merge branch 'master' of git.raylu.net:pathery
Conflicts:
globe.php
pages/login.php
Diffstat (limited to 'images/marks/rotate.php')
-rw-r--r-- | images/marks/rotate.php | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/images/marks/rotate.php b/images/marks/rotate.php new file mode 100644 index 0000000..41a203a --- /dev/null +++ b/images/marks/rotate.php @@ -0,0 +1,67 @@ +<?php
+// File and rotation
+$filename = 'OffsetStripesDiagonal_B.png';
+$rotate = $_GET['r'] * 1;
+//Probably not the best syntax.
+if (!is_int($rotate) OR !($rotate > 0) OR !($rotate < 4)) exit;
+
+$emblem = $_GET['emblem'];
+$degrees = $_GET['r'] * 90;
+
+// Content type
+header('Content-type: image/jpeg');
+//TODO Update Cache
+header("Cache-Control: private, max-age=10800, pre-check=10800");
+header("Pragma: private");
+header("Expires: " . date(DATE_RFC822,strtotime(" 2 day")));
+
+$simage = @imagecreatefrompng($emblem);
+if(!$simage) {
+ exit;
+}
+
+$background = imagecolorallocate($simage, 0, 0, 0);
+//$simage = rotateMaintain($simage, $degrees, $background);
+$simage = imagerotate($simage, $degrees, 0);
+// removing the black from the placeholder
+imagecolortransparent($simage, $background);
+// turning off alpha blending (to ensure alpha channel information
+// is preserved, rather than removed (blending with the rest of the
+// image in the form of black))
+imagealphablending($simage, false);
+// turning on alpha channel information saving (to ensure the full range
+// of transparency is preserved)
+imagesavealpha($simage, true);
+imagepng($simage);
+
+
+
+//Couldn't do this and maintain transparency ?
+function rotateMaintain($img1, $angle, $background) {
+ $width_before = imagesx($img1);
+
+ $height_before = imagesy($img1);
+ $img1 = imagerotate($img1, $angle, $background);
+
+ //but imagerotate scales, so we clip to the original size
+ $img2 = @imagecreatetruecolor($width_before, $height_before);
+ $new_width = imagesx($img1); // whese dimensions are
+ $new_height = imagesy($img1);// the scaled ones (by imagerotate)
+ imagecopyresampled(
+ $img2, $img1,
+ 0, 0,
+ ($new_width-$width_before)/2,
+ ($new_height-$height_before)/2,
+ $width_before,
+ $height_before,
+ $width_before,
+ $height_before
+ );
+ return $img2;
+}
+
+
+
+
+
+?>
\ No newline at end of file |