Improve image quality - Upload Facebook API

Asked

Viewed 28 times

0

I’m performing the creation of 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 which I uploaded to the server of the site I am working on. The image is in JPG and the server loads normally.

But when I post on facebook the image quality is VERY low.

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

1 answer

0

The answer I found was to decrease the 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 greatly decrease the size and compression rate while uploading from Facebook.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.