NOTE: This service has not been fully tested

@param File $file
@param int $rotation Degrees to rotate image clockwise, One value: 90, 180, 270

@throws UsageException
@return bool
978425
public function rotate( File $file, $rotation ) {
		$params = [
			'rotation' => $rotation,
			'token' => $this->api->getToken(),
		];

		if ( !is_null( $file->getPageIdentifier()->getTitle() ) ) {
			$params['titles'] = $file->getPageIdentifier()->getTitle()->getText();
		} else {
			$params['pageids'] = $file->getPageIdentifier()->getId();
		}

		$result = $this->api->postRequest( new SimpleRequest( 'imagerotate', $params ) );

		// This module sometimes gives odd errors so deal with them..
		if ( array_key_exists( 'imagerotate', $result ) ) {
			$imageRotate = array_pop( $result['imagerotate'] );
			if ( array_key_exists( 'result', $imageRotate ) &&
				$imageRotate['result'] == 'Failure'
			) {
				throw new UsageException(
					'imagerotate-Failure',
					$imageRotate['errormessage'],
					$result
				);
			}
		}

		return true;
	}
307720
private function rotationConvertFromDegree($degree, $asianFont)
    {
        switch ($degree) {
            case 90:
                if ($asianFont) {
                    return 5;
                }
                return 1;
            case 180:
                if ($asianFont) {
                    return 6;
                }
                return 2;
            case 270:
                if ($asianFont) {
                    return 7;
                }
                return 3;
            case 0:
                if ($asianFont) {
                    return 4;
                }
                return 0;
            default:
                throw ExceptionCommand::invalidDegree($degree);
        }

    }
408330
function photos_transform_rotate($photo_id, $degrees)
    {
        /** http://www.flickr.com/services/api/flickr.photos.transform.rotate.html */
        $this->request("flickr.photos.transform.rotate", array("photo_id" => $photo_id, "degrees" => $degrees), TRUE);
        return $this->parsed_response ? true : false;
    }
823862
public function correctOrientation()
    {
        try {
            $exif = exif_read_data($this->file);
        } catch (\Exception $e) {
            return $this;
        }
        if (!empty($exif['Orientation'])) {
            switch ($exif['Orientation']) {
                case 8:
                    $this->image = imagerotate($this->image, 90, 0);
                    break;
                case 3:
                    $this->image = imagerotate($this->image, 180, 0);
                    break;
                case 6:
                    $this->image = imagerotate($this->image, -90, 0);
                    break;
            }
        }
        return $this;
    }
726775
protected function rotateFiles()
	{
		$file=$this->getLogPath().DIRECTORY_SEPARATOR.$this->getLogFile();
		$max=$this->getMaxLogFiles();
		for($i=$max;$i>0;--$i)
		{
			$rotateFile=$file.'.'.$i;
			if(is_file($rotateFile))
			{
				// suppress errors because it's possible multiple processes enter into this section
				if($i===$max)
					@unlink($rotateFile);
				else
					@rename($rotateFile,$file.'.'.($i+1));
			}
		}
		if(is_file($file))
		{
			// suppress errors because it's possible multiple processes enter into this section
			if($this->rotateByCopy)
			{
				@copy($file,$file.'.1');
				if($fp=@fopen($file,'a'))
				{
					@ftruncate($fp,0);
					@fclose($fp);
				}
			}
			else
				@rename($file,$file.'.1');
		}
		// clear stat cache after moving files so later file size check is not cached
		clearstatcache();
	}
714507
protected function rotate($dir)
    {
        $files = Folder::files($dir);

        rsort($files);

        array_splice($files, 0, 20);

        return File::delete($files);
    }
930297
public function rotate($value = 90, $bgColor = 'transparent')
		# Author:     Jarrod Oberto
		# Date:       07-05-2011
		# Purpose:    Rotate image
		# Param in:   (mixed) $degrees: (int) number of degress to rotate image
		#               (str) param "left": rotate left
		#               (str) param "right": rotate right
		#               (str) param "upside": upside-down image
		# Param out:
		# Reference:
		# Notes:    The default direction of imageRotate() is counter clockwise.
		#
	{
		if ($this->imageResized)
		{

			if (is_integer($value))
			{
				$degrees = $value;
			}

			// *** Convert color
			$rgbArray = $this->formatColor($bgColor);
			$r = $rgbArray['r'];
			$g = $rgbArray['g'];
			$b = $rgbArray['b'];
			if (isset($rgbArray['a']))
			{
				$a = $rgbArray['a'];
			}

			if (is_string($value))
			{

				$value = fix_strtolower($value);

				switch ($value)
				{
					case 'left':
						$degrees = 90;
						break;
					case 'right':
						$degrees = 270;
						break;
					case 'upside':
						$degrees = 180;
						break;
					default:
						break;
				}

			}

			// *** The default direction of imageRotate() is counter clockwise
			//   * This makes it clockwise
			$degrees = 360 - $degrees;

			// *** Create background color
			$bg = ImageColorAllocateAlpha($this->imageResized, $r, $g, $b, $a);

			// *** Fill with background
			ImageFill($this->imageResized, 0, 0, $bg);

			// *** Rotate
			$this->imageResized = imagerotate($this->imageResized, $degrees, $bg); // Rotate 45 degrees and allocated the transparent colour as the one to make transparent (obviously)

			// Ensure alpha transparency
			ImageSaveAlpha($this->imageResized, true);

		}
	}
917829
public function transform(File $file, $self = false) {
        $config = $this->getConfig();
        $baseWidth = $file->width();
        $baseHeight = $file->height();
        $width = $config['width'];
        $height = $config['height'];

        if (is_numeric($width) && !$height) {
            $height = round(($baseHeight / $baseWidth) * $width);

        } else if (is_numeric($height) && !$width) {
            $width = round(($baseWidth / $baseHeight) * $height);

        } else if (!is_numeric($height) && !is_numeric($width)) {
            throw new InvalidArgumentException('Invalid width and height for crop');
        }

        $location = $config['location'];
        $widthScale = $baseWidth / $width;
        $heightScale = $baseHeight / $height;
        $src_x = 0;
        $src_y = 0;
        $src_w = $baseWidth;
        $src_h = $baseHeight;

        // If an array is passed, use those dimensions
        if (is_array($location)) {
            list($src_x, $src_y, $src_w, $src_h) = $location;

        // Source width is larger, use height scale as the base
        } else {
            if ($widthScale > $heightScale) {
                $src_w = $width * $heightScale;

                // Position horizontally in the middle
                if ($location === self::CENTER) {
                    $src_x = ($baseWidth / 2) - (($width / 2) * $heightScale);

                // Position at the far right
                } else if ($location === self::RIGHT || $location === self::BOTTOM) {
                    $src_x = $baseWidth - $src_w;
                }

            // Source height is larger, use width scale as the base
            } else {
                $src_h = $height * $widthScale;

                // Position vertically in the middle
                if ($location === self::CENTER) {
                    $src_y = ($baseHeight / 2) - (($height / 2) * $widthScale);

                // Position at the bottom
                } else if ($location === self::RIGHT || $location === self::BOTTOM) {
                    $src_y = $baseHeight - $src_h;
                }
            }
        }

        return $this->_process($file, array(
            'dest_w'    => $width,
            'dest_h'    => $height,
            'source_x'  => $src_x,
            'source_y'  => $src_y,
            'source_w'  => $src_w,
            'source_h'  => $src_h,
            'quality'   => $config['quality'],
            'overwrite' => $self
        ));
    }
1109838
static function maxLogrotateFiles()
    {
        $maxLogrotateFiles =& $GLOBALS['eZMaxLogrotateFiles'];
        if ( isset( $maxLogrotateFiles ) )
        {
            return $maxLogrotateFiles;
        }
        else if ( defined( 'CUSTOM_LOG_ROTATE_FILES' ) )
        {
            self::setLogrotateFiles( (int)CUSTOM_LOG_ROTATE_FILES );
            return (int)CUSTOM_LOG_ROTATE_FILES;
        }
        return self::MAX_LOGROTATE_FILES;
    }
1331469
public function transform(File $file, $self = false) {
        $config = $this->getConfig();

        if (empty($config['percent']) || !is_numeric($config['percent'])) {
            throw new InvalidArgumentException('Invalid percent for scaling');
        }

        $width = $file->width() * $config['percent'];
        $height = $file->height() * $config['percent'];

        return $this->_process($file, array(
            'dest_w'    => $width,
            'dest_h'    => $height,
            'quality'   => $config['quality'],
            'overwrite' => $self
        ));
    }
604710
public static void rotate(Image image, int degree, File outFile) throws IORuntimeException {
		write(rotate(image, degree), outFile);
	}
391582
public function execute($image)
    {
        $angle = $this->argument(0)->type('numeric')->required()->value();
        $color = $this->argument(1)->value();
        $color = new Color($color);

        // restrict rotations beyond 360 degrees, since the end result is the same
        $angle %= 360;

        // rotate image
        $image->setCore(imagerotate($image->getCore(), $angle, $color->getInt()));

        return true;
    }
1332608
public static function getExifRotation($source)
    {
        if (!Kwf_Registry::get('config')->image->autoExifRotate) {
            return 0;
        }

        $handle = fopen($source, 'rb'); // b for windows compatibility
        // Check if image is jpg file
        if (fread($handle, 2) != chr(0xFF).chr(0xD8)) {
            fclose($handle);
            return 0;
        }

        $fileSize = filesize($source);
        $count = 0;
        $rotation = 0;
        while ($count < 3) { // Run through marker
            $count++;
            $marker = fread($handle, 2);
            // Marks start of stream (SOS)
            if ($marker == chr(0xFF).chr(0xDA)) break;

            $size = self::_generateIntValue(fread($handle, 1), fread($handle, 1), false);
            if ($marker == chr(0xFF).chr(0xE1)) { // Start of exif-data-block
                if (fread($handle, 6) != 'Exif'.chr(0).chr(0)) break;

                $tiffHeaderBytes = fread($handle, 4); // should be 0x49492A00 or 0x4D4D002A
                if ($tiffHeaderBytes == 'II'.chr(0x2A).chr(0x00)) { // Motorola
                    $reversed = true;
                } else if ($tiffHeaderBytes == 'MM'.chr(0x00).chr(0x2A)) { // Intel
                    $reversed = false;
                } else { // this case should not exist
                    break;
                }

                $count = 0;
                while ($count < 5) {
                    $count++;
                    // IFD = Image File Directory => Image properties
                    // check offset from tiffHeader-Start to IFD's, if 0 end of all IFD-Blocks
                    if (fread($handle, 4) == chr(0x00).chr(0x00).chr(0x00).chr(0x00)) break 2;

                    $ifdCount = self::_generateIntValue(fread($handle, 1), fread($handle, 1), $reversed);
                    if ($fileSize < ftell($handle) + $ifdCount * 12 + 6) break 2; // check to handle eof
                    if ($ifdCount > 100) break 2; // check if ifdCount is a possible value
                    for ($i = 0; $i < $ifdCount; $i++) {
                        $ifdBytes = fread($handle, 12);
                        $tag = self::_generateIntValue($ifdBytes[0], $ifdBytes[1], $reversed);
                        if ($tag == 0x0112) {
                            // reversed saved in this form: 00 06 | 00 00 should be 00 00 | 00 06
                            // normally saved in this form: 06 00 | 00 00
                            $highBytes = self::_generateIntValue($ifdBytes[10], $ifdBytes[11], $reversed);
                            $lowBytes = self::_generateIntValue($ifdBytes[8], $ifdBytes[9], $reversed);
                            $exifOrientation = $highBytes * pow(16, 4) + $lowBytes;
                            switch ($exifOrientation) {
                                case 1:
                                    $rotation = 0;
                                    break;
                                case 8: //Left_Bottom
                                    $rotation = -90;
                                    break;
                                case 3:
                                    $rotation = 180;
                                    break;
                                case 6: //Right_Top
                                    $rotation = 90;
                                    break;
                            }
                            break 3;
                        }
                    }
                }

            } else { // Any other marker (e.g. JFIF-0xFFE0, Photoshop-Stuff), not supported. Set file-pointer to end of marker-data
                fseek($handle, $size -2, SEEK_CUR);
            }
        }
        fclose($handle);
        return $rotation;
    }
175936
public function rotate( $angle, $type = NULL )
	{
		if( !$this->sourceUri )
			throw new RuntimeException( 'No source image set' );

#		if( function_exists( 'imageantialias' ) )
#			imageantialias( $this->target, TRUE );

		$this->target	= imagerotate( $this->source, $angle, 0 );
		if( $this->targetUri )
			return $this->saveImage( $type );
		return TRUE;
	}
1289123
protected function rotateLogFile()
    {
        if (file_exists($this->logFileUrl . '.lock')) {
            return;
        } else {
            touch($this->logFileUrl . '.lock');
        }

        if ($this->logFilesToKeep === 0) {
            unlink($this->logFileUrl);
        } else {
            for ($logFileCount = $this->logFilesToKeep; $logFileCount > 0; --$logFileCount) {
                $rotatedLogFileUrl =  $this->logFileUrl . '.' . $logFileCount;
                if (file_exists($rotatedLogFileUrl)) {
                    if ($logFileCount == $this->logFilesToKeep) {
                        unlink($rotatedLogFileUrl);
                    } else {
                        rename($rotatedLogFileUrl, $this->logFileUrl . '.' . ($logFileCount + 1));
                    }
                }
            }
            rename($this->logFileUrl, $this->logFileUrl . '.1');
        }

        unlink($this->logFileUrl . '.lock');
    }
158755
public function mustRotate()
    {
        if (!file_exists($this->file_path)) return false;

        if ($this->flag & self::ROTATE_FILESIZE) {
            $s = @filesize($this->file_path);
            return (bool) (@is_readable($this->file_path) && $s > $this->options['max_filesize'] * 1024);
        } else {
            if (empty($this->file_mtime)) {
                $this->file_mtime = filemtime($this->file_path);
            }
            $now = date('ymdHis', (time()-$this->options['period_duration']));
            return (bool) (@is_readable($this->file_path) && date('ymdHis', $this->file_mtime) <= $now);
        }
    }
225562
public function rotate($degrees, $background = null, $random = false)
    {
        if ($background) {
            $background = trim($background);
        } else {
            $background = "ffffff";
        }

        if ($random) {
            $deg = abs((float) $degrees);
            $degrees = rand(-1 * $deg, $deg);
        }

        $this->image->rotate($degrees, $background);
    }