image icon indicating copy to clipboard operation
image copied to clipboard

Black image issue

Open PinalPatel160 opened this issue 7 years ago • 4 comments

I've created webp image using image/intervention. It's working perfectly on my local server but it's not working in the live server(ubuntu 160.04). But when I try to open that image it shows a blank transparent image with correct Content-Type: image/webp and file-size.

Blank image return like this: https://imgur.com/a/CMx6tsU I'm using following code to generate webp image from png/jpg:

$path = "path_of_original_png/jpg_image"; $webp_path= "path_to_save_webp_image"; $webp = Image::make($path); $webp->save($webp_path, 75);

PinalPatel160 avatar Aug 02 '18 09:08 PinalPatel160

@PatelPinal1415160 I have the same issue

Kostyaval avatar Sep 08 '19 17:09 Kostyaval

@Kostyaval I've not found the solution to this problem. So I'm switching to use a "libwebp". I'm using "cwebp" to encode/decode image into WEBP. It's a wonderful tool for WEBP format which is provided by Google.

Reference link

PinalPatel160 avatar Sep 09 '19 03:09 PinalPatel160

I still have the same problem - does anyone know how to fix this?

aoderinde avatar Oct 02 '20 09:10 aoderinde

Found the solution: Reference

"Need to check if the frame length is even. If this is not the case, we append a zero byte to the end of the frame".

if (filesize($pathToFile) % 2 == 1) {
    file_put_contents($pathToFile, "\0", FILE_APPEND);
}

Or just update libwebp-dev to latest version. I have this problem on 0.4.4-1, but 0.6.1-2 on local machine works fine.

escral avatar Oct 20 '21 11:10 escral