OpenersPrimaryExamplesSection(Spacer1)Examples  (24)

OpenersExampleSection0(Spacer1)Basic Examples  (4)

Import a WebP file:

Import["ExampleData/flowers.webp"]

Summary of an image:

Import["ExampleData/flowers.webp","Summary"]

Export an image to WebP:

Export["image.webp",]

Export arbitrary inline graphics to WebP:

Export["plot.webp",(Legended[, (LineLegend[sin(x), cos(x)])])]

OpenersExampleSection1(Spacer1)Scope  (2)

Export a Wolfram Language expression as a raster to WebP:

str=ExportString[NestList[Subsuperscript[#,#,#]&,o,4],"WebP"];

ImportString[str]

Export arbitrary inline graphics to WebP:

Export["plot.webp",(Legended[, (LineLegend[sin(x), cos(x)])])]

OpenersExampleSection2(Spacer1)Import Elements  (13)

OpenersExampleSubsection0(Spacer1)Available Elements  (3)

List of available elements:

Import["ExampleData/flowers.webp","Elements"]

Get image-related information as a list of rules:

Import["ExampleData/flowers.webp","Rules"]//Short

Import some image options:

Import["ExampleData/flowers.webp","Options"]

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

Import["ExampleData/flowers.webp"]//Options

OpenersExampleSubsection1(Spacer1)Data Representation  (4)

OpenersExampleSubsubsection0(Spacer1)"Data"  (1)

Import the image data:

data=Import["ExampleData/flowers.webp","Data"]

Construct images of the proper type:

Image[data, "Byte"]

OpenersExampleSubsubsection1(Spacer1)"Graphics"  (1)

Import as a (RefLink[Graphics, paclet:ref/Graphics]) object:

Import["ExampleData/flowers.webp","Graphics"]

Head[%]

OpenersExampleSubsubsection2(Spacer1)"Image"  (1)

Import as an (RefLink[Image, paclet:ref/Image]) object:

Import["ExampleData/flowers.webp","Image"]

Head[%]

This is the default import element for WebP:

Import["ExampleData/flowers.webp"]//Head

OpenersExampleSubsubsection3(Spacer1)"Thumbnail"  (1)

Import thumbnail of an image:

Import["ExampleData/flowers.webp","Thumbnail"]

Show the elements that can be imported from this file:

Import["ExampleData/flowers.webp", "Elements"]

Get the "BitDepth" and "ImageSize" elements:

Import["ExampleData/flowers.webp", {{"BitDepth","ImageSize"}}]

OpenersExampleSubsection2(Spacer1)Metadata  (6)

OpenersExampleSubsubsection4(Spacer1)"BitDepth"  (1)

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

Import["ExampleData/flowers.webp","BitDepth"]

OpenersExampleSubsubsection5(Spacer1)"Channels"  (1)

Get the color encoding used on export:

Import["ExampleData/flowers.webp","Channels"]

OpenersExampleSubsubsection6(Spacer1)"ColorProfileData"  (1)

Get the embedded color profile, given as a (RefLink[ColorProfileData, paclet:ref/ColorProfileData]) object:

Import["ExampleData/flowers.webp","ColorProfileData"]

OpenersExampleSubsubsection7(Spacer1)"ColorSpace"  (1)

Get the color encoding used on export:

Import["ExampleData/flowers.webp","ColorSpace"]

Use (RefLink[ImageColorSpace, paclet:ref/ImageColorSpace]) to get the color space of an imported image:

Import["ExampleData/flowers.webp"]//ImageColorSpace

OpenersExampleSubsubsection8(Spacer1)"ImageSize"  (1)

Get the dimensions of the image stored in the file:

Import["ExampleData/flowers.webp","ImageSize"]

Use (RefLink[ImageDimensions, paclet:ref/ImageDimensions]) on an imported image gives the same result:

Import["ExampleData/flowers.webp"]//ImageDimensions

OpenersExampleSubsubsection9(Spacer1)"Summary"  (1)

Get the image summary:

Import["ExampleData/flowers.webp","Summary"]

OpenersExampleSection4(Spacer1)Import Options  (2)

OpenersExampleSubsection3(Spacer1)ImageSize  (1)

By default, images are imported in their full resolution:

Import["ExampleData/flowers.webp"]

ImageDimensions[%]

Specify the raster size of the imported WebP image:

Import["ExampleData/flowers.webp",ImageSize->50]

ImageDimensions[%]

OpenersExampleSubsection4(Spacer1)"ImageTopOrientation"  (1)

By default, images are imported with the top orientation:

Import["ExampleData/flowers.webp"]

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

Import["ExampleData/flowers.webp","ImageTopOrientation"->Left]

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

ImageRotate[Import["ExampleData/flowers.webp","ImageTopOrientation"->Left],Top->Left]

OpenersExampleSection5(Spacer1)Export Options  (3)

OpenersExampleSubsection5(Spacer1)"CompressionLevel"  (1)

By default, no compression is used during export:

i=;

Export["image.webp",i]

i===Import["image.webp"]

Larger "CompressionLevel" can decrease the file size:

Export["image2.webp",i,"CompressionLevel"->1]

FileByteCount/@{"image.webp","image2.webp"}

Notice decreased quality of the exported image:

Import["image2.webp"]

OpenersExampleSubsection6(Spacer1)ImageSize  (1)

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

i=;

ImageDimensions[i]

Export["test.webp",i]

Import[%,"ImageSize"]

Specify the raster size of the exported image:

Export["test.webp",i , ImageSize-> 47]

Import[%,"ImageSize"]

OpenersExampleSubsection7(Spacer1)"ImageTopOrientation"  (1)

By default, the upright image is exported using "ImageTopOrientation"->(RefLink[Top, paclet:ref/Top]):

i=;

Export["test.webp", i]

Import[%]

Specify the raster size of the exported image:

Export["test.webp",i, "ImageTopOrientation"->Left]

Import[%]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {Related Formats:  (RefLink[PNG, paclet:ref/format/PNG])  ▪  (RefLink[GIF, paclet:ref/format/GIF])  ▪  (RefLink[JPEG, paclet:ref/format/JPEG])  ▪  (RefLink[BMP, paclet:ref/format/BMP])  ▪  (RefLink[PBM, paclet:ref/format/PBM])  ▪  (RefLink[TIFF, paclet:ref/format/TIFF])  ▪  (RefLink[ICC, paclet:ref/format/ICC])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Importing Graphics and Sounds, paclet:tutorial/ImportingGraphicsAndSounds])}, {▪(RefLinkPlain[Exporting Graphics and Sounds, paclet:tutorial/ExportingGraphicsAndSounds])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Graphics Importing & Exporting, paclet:guide/GraphicsImportingAndExporting])}, {▪(RefLinkPlain[Image Processing, paclet:guide/ImageProcessing])}, {▪(RefLinkPlain[Importing & Exporting, paclet:guide/ImportingAndExporting])}, {▪(RefLinkPlain[Listing of All Formats, paclet:guide/ListingOfAllFormats])}, {▪(RefLinkPlain[Raster Image Formats, paclet:guide/RasterImageFormats])}})}})