use Aspose\Imaging\Configuration;
use Aspose\Imaging\ImagingApi;
use Aspose\Imaging\Model\Requests\ConvertImageRequest;
use Aspose\Imaging\Model\Requests\CreateConvertedImageRequest;
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.svg";
$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);

/**
* Export an image to another format.
*/
public function ConvertImageFromStorage()
{
    $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/#convert
    // for possible output formats
    $format = "pdf";
    $folder = $this->CloudFolder; // Input file is saved at the desired folder in the storage
    $storage = null; // Cloud Storage name

    $request = new ConvertImageRequest($this->ImageFileName, $format, $folder, $storage);
    $convertedImage = self::$imagingApi->convertImage($request);

    // Save the image file to output folder
    $convertedImageName = substr($this->ImageFileName, 0, strrpos($this->ImageFileName, ".") + 1) . "pdf"; 
    $path = $this-> OutputFolder . DIRECTORY_SEPARATOR . $convertedImageName;
    file_put_contents($path, $convertedImage);
}

/**
* Convert an image to another format. Image data is passed in a request stream.
*/
public function CreateConvertedImageFromRequest()
{
    // Please refer to https://docs.aspose.cloud/imaging/supported-file-formats/#convert
    // for possible output formats
    $format = "pdf";
    $outPath = null; // Path to updated file (if this is empty, response contains streamed image)
    $storage = null; // Cloud Storage name

    $inputStream = file_get_contents($this->ImagesFolder . DIRECTORY_SEPARATOR . $this->ImageFileName);
    $request = new CreateConvertedImageRequest($inputStream, $format, $outPath, $storage); 
    $convertdImage = self::$imagingApi->createConvertedImage($request);

    // Save the image file to output folder
    $convertedImageName = substr($this->ImageFileName, 0, strrpos($this->ImageFileName, ".") + 1) . "pdf"; 
    $path = $this-> OutputFolder . DIRECTORY_SEPARATOR . $convertedImageName;
    file_put_contents($path, $convertedImage);
}