Create WebP images

    Note: Because support for lossless and transparent WebPimages is only available in Android 4.3 and higher, yourproject must declare a of 18 or higher to createlossless or transparent WebP images using Android Studio.

    For more information about the WebP image format, see the . For more information aboutselecting the correct image format to improve download speed, see Reduce imagedownload sizes.

    Android Studio can convert PNG, JPG, BMP, or static GIF images to WebP format.You can convert individual images or folders of images. To convert an image orfolder of images, proceed as follows:

    • Select either lossy or lossless encoding. Lossless encoding is only available if your is set to 18 or higher. If you select lossy encoding, set the encoding quality, and choose whether or not to view a preview of each converted image before saving.

      You can also choose to skip converting any files where the encoded version would be larger than the original, or any files with transparency or an alpha channel. Because Android Studio only allows you to create transparent WebP images if your minSdkVersion is set to 18 or higher, the Skip images with transparency/alpha channel checkbox is automatically selected if your is lower than 18.

    Note: 9-patch files cannot be converted to WebP images. The converter tool always automatically skips 9-patch images.

    If you selected lossless conversion above, the conversion happens immediately. Your images are converted in place in their original location. If you selected lossy conversion, continue on to the next step.

    • Figure 2 shows the original JPG image on the left and the lossy encoded WebP image on the right. The dialog shows the file size for the original and the converted image. You can drag the slider left or right to change the quality setting and immediately see the effect on the encoded image and the file size.

      The middle area shows the pixels that differ between the original and the encoded image. In figure 2, with the quality set to 75%, there's almost no difference between the two images. Figure 3 shows the same image encoded with the quality set to 0%.

      Figure 3. Converting a JPG to WebP format at 0% quality

    Note: If you set the quality to 100% and the minSdkVersion is set to 18 or higher, Android Studio automatically switches to lossless encoding instead.

    Select a quality setting for each image you review. If you are converting more than one image, click Next to advance to the next image.

    • Click Finish. Your images are converted in place in their original location.

    Convert WebP images to PNG

    • A dialog appears, asking if you would like to convert the image to PNG,deleting the original WebP file, or keep the original WebP file as well asthe new PNG file. Click Yes to delete the original WebP file, or Noto retain the WebP file in addition to the PNG file. Your image is convertedimmediately.