Improve image quality - Upload Facebook API

0

I'm creating a Facebook post with a photo with the following code:

FB.api(
        '/me/photos',
        'POST',
        {"url": imagem,"message": texto_publicaco},
        function(response) {
            alert("Postagem criada");
        }
);

The variable imagem contains the URL to where I uploaded the site server I'm working on. The image is in JPG and the server loads normally.

But when I do the post on facebook the quality of the image drops a lot.

Is there any way to improve even a little the quality of the image that is loaded?

    
asked by anonymous 06.10.2017 / 22:03

1 answer

0

The answer I found was to decrease JPEG quality while uploading the image to my server before creating the Facebook post using the WideImage class for PHP with the following code:

 //Classe para manipular a qualidade da imagem
    require('WideImage/WideImage.php');

    $imagem = WideImage::load($tmpFile);
    $imagem->saveToFile(PASTA_UPLOAD . '/' . $_GET['filename'], 85);

Here I reduced the quality to 85% and managed to decrease the size and compression ratio during Facebook uploading.

    
19.10.2017 / 20:38