mercredi 17 février 2021

Remove background image using remove.bg

I'm trying to use remove.bg to remove background image using this code.

Link : https://www.remove.bg/api

  $client = new \GuzzleHttp\Client();
    $res = $client->post('https://api.remove.bg/v1.0/removebg', [
        'multipart' => [
            [
                'name'     => 'image_file',
                'contents' => fopen('http://localhost:8000/download.jpg', 'r')
            ],
            [
                'name'     => 'size',
                'contents' => 'auto'
            ]
        
        ],
        'headers' => [
            'X-Api-Key' => 'XXXXXXXX'
        ]
    ]);
    $fp = fopen("result.jpg", "wb");
    fwrite($fp, $res->getBody());
    fclose($fp); 

getting this error :

fopen(http://localhost:8000/download.jpg): failed to open stream: HTTP request failed!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire