Why does the Google Images Service convert my WEBP images to JPG when serving them?

I have several PNG images with alpha that I converted to WEBP using XnConvert. The conversion itself is going well, and the alpha channel is supported until it is uploaded to the BlobStore

Before loading into blobstore, it looks like this:
before

and after that it looks like this:

after

It serves as a JPG using a serving URL, so the alpha channel is deleted. In the BlobStore viewer in the App Engine console, he set the content type to the application / octet stream, although the downloaded file had a .webp extension.

In accordance with the Image API Documentation, it must support WEBP.

I am not doing anything unusual when uploading images:

 List<BlobKey> blobs = blobstoreService.getUploads(req).get("file"); BlobKey blobKey = blobs.get(0); ImagesService imagesService = ImagesServiceFactory.getImagesService(); ServingUrlOptions servingOptions = ServingUrlOptions.Builder.withBlobKey(blobKey); String servingUrl = imagesService.getServingUrl(servingOptions); 

EDIT:

This is an example of a serving URL: an example of a serving URL

I tried to access it using Chrome , as well as through the android client. Here is the code used to access it in the Android client, although I do not think it is important:

  URL url = new URL(Assets.getServingUrl(resourceName)); URLConnection connection = url.openConnection(); connection.connect(); String contentType = connection.getContentType(); String fileExt; if(contentType.contains("webp")) fileExt = ".webp"; else if(contentType.contains("png")) fileExt = ".png"; else if(contentType.contains("jpeg") || contentType.contains("jpg")) fileExt = ".jpg"; // download the file InputStream input = new BufferedInputStream(url.openStream(),8192); OutputStream output = MyApp.getAppContext().openFileOutput(resourceName + fileExt,Activity.MODE_PRIVATE); byte data[] = new byte[1024]; int count; while ((count = input.read(data)) != -1) { output.write(data, 0, count); } output.flush(); output.close(); input.close(); 


I would like to serve images through the Google Image API because of how images can be modified on the fly.

Can someone help me point me in the right direction to solve this?

EDIT2:

I tried using blob directly through blobstore as follows: blobstoreService.serve(new BlobKey(assetEntity.blobKey), res); instead of the image service and then it works great. However, this is not an option due to the increase in the number of hours that would be required to service them in this way. But at least it narrows the problem down to image service.

+4
source share
1 answer

You can add the =-rw option to your url. So you will have something like

 http://lh3.ggpht.com/MvNZDvZcBaq_B2MuAj0-Y74sc24WAsOVIQiJzsowu1rVG-ACzGO80xxD9y5OI5dWSCa_Nt41aMmWSSYAbpFE8dW7BhxozH2ikcVLjw=s600-rw 

You got a jpeg thumbnail, since this is the default when using webp, as the format is not yet fully supported by all browsers.

+3
source

Source: https://habr.com/ru/post/1483959/


All Articles