how to upload png with transparent background to cloudinary

adityapadekar
adityapadekar Member Posts: 1
edited January 8 in Developer APIs

I am trying to upload a png image with transparent background to cloudinary using nodejs application

The image is in png format i.e. logo.png. I am using multer to get the image convert into buffer before uploading the image.

But when I upload the image the transparent background changes to a white background.

The response I am getting is : https://res.cloudinary.com/dscycqmhw/image/upload/<stuff>/pbbbybdfxzyxcm51qb2t.png

The code is as follows :

module.exports.uploadBufferDataToCloudinary = async (buffer, folder) => {

    const uploadResult = await new Promise((resolve, reject) => {

        cloudinary.uploader

            .upload_stream(

                {

                    upload_preset: "Codefeast",

                    folder: `Codefeast/${folder}`,

                },

                (error, uploadResult) => {

                    if (error) return reject(error);

                    return resolve(uploadResult);

                }

            )

            .end(buffer);

    });

    return uploadResult;

};

Answers