use Aspose\Imaging\Configuration; use Aspose\Imaging\ImagingApi; use Aspose\Imaging\Model\Requests\CreateRotateFlippedImageRequest; use Aspose\Imaging\Model\Requests\RotateFlipImageRequest; use Exception; // Get ClientId and ClientSecret from https://dashboard.aspose.cloud/ // or use on-premise version (https://docs.aspose.cloud/imaging/getting-started/how-to-run-docker-container/) $ImageFileName = "example_image.apng"; $ImagesFolder = "ExampleImages"; $CloudFolder = "CloudImages"; $OutputFolder = "Output"; $clientSecret = null; $clientId = null; $baseUrl = "https://api.aspose.cloud"; $imagingConfig = new Configuration(); $imagingConfig->setClientSecret($clientSecret); $imagingConfig->setClientId($clientId); $imagingConfig->setBaseUrl($baseUrl); $imagingApi = new ImagingApi($imagingConfig); /** * Rotate and/or flip an image from cloud storage. */ public function RotateFlipImageFromStorage() { $this->UploadSampleImageToCloud(); $inputImage = file_get_contents($this->ImagesFolder . DIRECTORY_SEPARATOR . $this->ImageFileName); $request = new UploadFileRequest($this->CloudPath . DIRECTORY_SEPARATOR . $this->ImageName, $inputImage); $response = self::$imagingApi->uploadFile($request); if ($response->getErrors() != null && count($response->getErrors()) == 0) echo ("Uploading errors count: " . count($response->getErrors())); // Please refer to https://docs.aspose.cloud/imaging/supported-file-formats/#rotateflip for possible formats $format = "apng"; $method = "Rotate90FlipX"; // RotateFlip method $folder = $this->CloudFolder; // Input file is saved at the desired folder in the storage $storage = null; // We are using default Cloud Storage $request = new RotateFlipImageRequest($this->ImageFileName, $method, $format, $folder, $storage); $updatedImage = self::$imagingApi->rotateFlipImage($request); // Save the image file to output folder $updatedImageName = substr($this->ImageFileName, 0, strrpos($this->ImageFileName, ".") + 1) . "apng"; $path = $this-> OutputFolder . DIRECTORY_SEPARATOR . $updatedImageName; file_put_contents($path, $updatedImage); } /** * Rotate and/or flip an image. Image data is passed in a request stream. */ public function CreateRotateFlippedImageFromRequest() { // Please refer to https://docs.aspose.cloud/imaging/supported-file-formats/#rotateflip for possible formats $format = "apng"; $method = "Rotate90FlipX"; // RotateFlip method $outPath = null; // Path to updated file (if this is empty, response contains streamed image) $storage = null; // We are using default Cloud Storage $inputStream = file_get_contents($this->ImagesFolder . DIRECTORY_SEPARATOR . $this->ImageFileName); $request = new CreateRotateFlippedImageRequest($inputStream, $method, $format, $outPath, $storage); $updatedImage = self::$imagingApi->createRotateFlippedImage($request); // Save the image file to output folder $updatedImageName = substr($this->ImageFileName, 0, strrpos($this->ImageFileName, ".") + 1) . "apng"; $path = $this-> OutputFolder . DIRECTORY_SEPARATOR . $updatedImageName; file_put_contents($path, $updatedImage); }