PHP code example of daavelar / php-runware-sdk

1. Go to this page and download the library: Download daavelar/php-runware-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

daavelar / php-runware-sdk example snippets


use Runware\Runware;

$runware = new Runware('your_api_key');

$imageUrl = $runware
    ->withHeight(768)
    ->withWidth(1024)
    ->model('runware:realistic')
    ->withSteps(30)
    ->withCFGScale(8.5)
    ->withNumberResults(4)
    ->withOutputType('URL')
    ->withOutputFormat('PNG')
    ->withNegativePrompt('low quality, blurred')
    ->textToImage('A beautiful sunset over a calm ocean');

$transformedImageUrl = $runware
    ->withHeight(512)
    ->withWidth(512)
    ->withSteps(25)
    ->imageToImage(
        'A beautiful sunset over a calm ocean', 
        'https://url-da-imagem-original.jpg',
        0.7
    );

$inpaintedImageUrl = $runware
    ->inpainting(
        'A beautiful sunset over a calm ocean',
        'https://url-da-imagem-original.jpg',
        'https://url-da-mascara.jpg',
        0.8
    );

$outpaintedImageUrl = $runware
    ->outpainting(
        'A beautiful sunset over a calm ocean',
        'https://url-da-imagem-original.jpg',
        [
            'top' => 256,
            'right' => 256,
            'bottom' => 0,
            'left' => 0
        ],
        0.8
    );
bash
composer