export with palette

Typecommand
DictionaryLCS
LibraryLiveCode Script
Syntax
export <image> [with metadata <metadata>] to {file <filePath> | <container>} as {gif | png} with standard palette
export <image> [with metadata <metadata>] to {file <filePath> | <container>} as {gif | png} with optimized palette
export <image> [with metadata <metadata>] to {file <filePath> | <container>} as {gif | png} with <colorCount> color [optimized] palette
export <image> [with metadata <metadata>] to {file <filePath> | <container>} as {gif | png} with palette <colorList>
Summary

Exports the selected image as a PBM, JPEG, GIF, BMP or PNG file.

Introduced4.5
OSmac, windows, linux
Platformsdesktop
Parameters
NameTypeDescription
image

A reference to an image.

metadata

An array of metadata. Currently the only key supported is density with a value in pixels per inch (ppi).

filePath

The name and location of the file you want to export to. If you specify a name but not a location, the file is created in the defaultFolder.

container

A reference to a container, usually another image or a URL.

colorCount

An integer in the range zero to 256, or an expression evaluating to such an integer, and specifies the size of the palette to be generated.

colorList

A return-delimited list of up to 256 colors to be used as the palette.

Example
export image 1 to myVariable as png with standard palette
export image "Parachute" to myVariable as gif with 100 color palette
RelatedKeyword: as, file, image, paint, URL
Property: defaultFolder, JPEGQuality, selected
Command: export, export snapshot, import
Glossary: BMP, command, container, export, GIF, JPEG, PBM, PNG
Securitydisk
Description

Use the export with palette command to export an image to a file or container with color reduction.

The export with palette form exports an image in either PNG or GIF format with a specific size or type of palette.

If the standard palette form is used, then the image will be color-matched to the default 256 color LiveCode palette before export.

If the optimized palette form is used, then a palette with the colorCount colors will be generated that does its best to approximate all the colors present in the image. The image will be color-matched to this palette before export. If colorList is not specified, a 256 entry palette will be generated.

If the palette colorList form is used, the image will be color-matched to that palette before export.

If the image has any sort of transparency, then this will utilize one palette entry. In particular, if you ask for a 256 color palette with a transparent image, you may get only 255 colors.

In all cases, optional dithering will be performed as determined by its dontDither property.

Note: It is a (relatively) slow process to compute an optimized palette and then remap an image against it; it should not be considered a real-time operation except for very small images.

Note: There is no support for exporting a JPEG with a reduce palette as this format is for continuous-tone images and as such the notion of palette makes no sense.