WebP (.webp)

Background & Context

    • Registered MIME type: image/webp
    • WebP raster image format.
    • Binary format.
    • Stores a single image.
    • Stores color bitmaps at a resolution of 8 bits per channel.
    • Supports alpha channels.
    • Introduced in 2010 by Google to provide both lossy and lossless compression of images on the web.

Import & Export

  • Import["file.webp"] imports a WebP file as an image.
  • Import["file.webp",elem] imports the specified element from a WebP file.
  • The import format can be specified with Import["file","WebP"] or Import["file",{"WebP",elem,}].
  • Export["file.webp",expr] exports an image, graphics, or any other expression as a raster image to WebP.
  • When exporting Wolfram Language graphics or arbitrary expressions to WebP, the resulting image has the same raster size as its displayed form.
  • Image objects are by default exported at their raster size.
  • Because WebP is a raster image format, all fonts are rasterized on export.
  • See the reference pages for full general information on Import and Export.
  • ImportString and ExportString support the WebP format.

Import Elements

  • General Import elements:
  • "Elements" list of elements and options available in this file
    "Rules"full list of rules for each element and option
    "Options"list of rules for options, properties, and settings
  • Data representation elements:
  • "Data"array of color values
    "Graphics"Graphics object representing an image
    "Image"raster image, given as an Image object
    {"Thumbnail",size}thumbnail of a given size (default size = Small)
  • Import and Export by default use the "Image" element for WebP files.
  • Advanced Import elements:
  • "BitDepth"bits used to represent each color channel in the file
    "Channels"the number of color channels used in the file
    "ColorProfileData"embedded color profile, given as a ColorProfileData object
    "ColorSpace"color encoding used in the file
    "ImageSize"raster dimensions
    "Summary"summary of the file



open allclose all

Basic Examples  (4)

Import a WebP file:

Summary of an image:

Export an image to WebP:

Export arbitrary inline graphics to WebP:

Scope  (3)

Import the image as a graphic:

Export a Wolfram Language expression as a raster to WebP:

Export arbitrary inline graphics to WebP:

Import Elements  (13)

Available Elements  (3)

List of available elements:

Get image-related information as a list of rules:

Import some image options:

The "Options" element does not return all options that are present in the imported image:

Data Representation  (4)

"Data"  (1)

Import the image data:

Construct images of the proper type:

"Graphics"  (1)

Import as a Graphics object:

"Image"  (1)

Import as an Image object:

This is the default import element for WebP:

"Thumbnail"  (1)

Import thumbnail of an image:

Show the elements that can be imported from this file:

Get the "BitDepth" and "ImageSize" elements:

Metadata  (6)

"BitDepth"  (1)

Get the number of bits used for representing each color channel:

"Channels"  (1)

Get the color encoding used on export:

"ColorProfileData"  (1)

Get the embedded color profile, given as a ColorProfileData object:

"ColorSpace"  (1)

Get the color encoding used on export:

Use ImageColorSpace to get the color space of an imported image:

"ImageSize"  (1)

Get the dimensions of the image stored in the file:

Use ImageDimensions on an imported image gives the same result:

"Summary"  (1)

Get the image summary:

Import Options  (2)

ImageSize  (1)

By default, images are imported in their full resolution:

Specify the raster size of the imported WebP image:

"ImageTopOrientation"  (1)

By default, images are imported with the top orientation:

Specify the side that is supposed to be on the top:

The correct orientation can also be achieved by rotating the image to be upright:

Export Options  (3)

CompressionLevel  (1)

By default, no compression is used during export:

A larger CompressionLevel can decrease the file size:

Notice the decreased quality of the exported image:

Compare the change in file size and quality difference using different compression levels:

ImageSize  (1)

By default, the image is exported in the full resolution:

Specify the raster size of the exported image:

"ImageTopOrientation"  (1)

By default, the upright image is exported using "ImageTopOrientation"->Top:

Specify the raster size of the exported image: