({{, (RefLink[ExportByteArray, paclet:ref/ExportByteArray])[expr,"format"]
generates a (RefLink[ByteArray, paclet:ref/ByteArray]) object corresponding to expr exported in the specified format. }, {, (RefLink[ExportByteArray, paclet:ref/ExportByteArray])[exprs,elems]
generates a (RefLink[ByteArray, paclet:ref/ByteArray]) object by treating exprs as elements specified by elems.}})

OpenersNotesSection(Spacer1)Details

(RefLink[ExportByteArray, paclet:ref/ExportByteArray]) handles a large number of formats, each typically with many different possible elements. The possible formats are given in the list (RefLink[$ExportFormats, paclet:ref/$ExportFormats]) and in the "Listing of All Formats".

(RefLink[ExportByteArray, paclet:ref/ExportByteArray]) works just like (RefLink[Export, paclet:ref/Export]), with the same element specifications and options.

OpenersPrimaryExamplesSection(Spacer1)Examples  (6)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Export an image as a (RefLink[ByteArray, paclet:ref/ByteArray]) object:

bytes=ExportByteArray[,"PNG"]

Import the bytes to produce the original image:

ImportByteArray[bytes]

Export an image as a (RefLink[ByteArray, paclet:ref/ByteArray]) object:

bytes=ExportByteArray[,"PNG"]

Write the bytes to a temporary file:

tmp=CreateTemporary[];
BinaryWrite[tmp,bytes];
Close[tmp];

Verify the bytes were correctly written by importing the file:

Import[tmp]

OpenersExampleSection1(Spacer1)Scope  (2)

Export a typeset mathematical formula as a (RefLink[ByteArray, paclet:ref/ByteArray]) object:

formula=Integrate[Sqrt[x+Sqrt[x]],x] // TraditionalForm

bytes=ExportByteArray[formula,"PDF"]

Import the bytes to produce a resolution-independent version of the formula:

ImportByteArray[bytes][[1]]

Export a color map and corresponding raw data as a (RefLink[ByteArray, paclet:ref/ByteArray]) object:

{map,data}=Import["ExampleData/wave.gif",{{"ColorMap","RawData"}}];

bytes=ExportByteArray[{"ColorMap"->map, "RawData"->data},{"GIF", "Rules"}]

Import the bytes to produce the original animated GIF image:

ImportByteArray[bytes,"Animation"]

OpenersExampleSection3(Spacer1)Properties & Relations  (1)

(RefLink[ExportByteArray, paclet:ref/ExportByteArray]) returns the same result as (RefLink[ExportString, paclet:ref/ExportString]) followed by (RefLink[StringToByteArray, paclet:ref/StringToByteArray]):

graphics=;

ExportByteArray[graphics,"TIFF"]===StringToByteArray[ExportString[graphics,"TIFF"],"ISO8859-1"]

OpenersExampleSection4(Spacer1)Possible Issues  (1)

If the export produces no data, an empty list is returned:

ExportByteArray["","Text"]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[ImportByteArray, paclet:ref/ImportByteArray])  ▪  (RefLink[StringToByteArray, paclet:ref/StringToByteArray])  ▪  (RefLink[ExportString, paclet:ref/ExportString])  ▪  (RefLink[ByteArray, paclet:ref/ByteArray])  ▪  (RefLink[Export, paclet:ref/Export])  ▪  (RefLink[FunctionCompileExportByteArray, paclet:ref/FunctionCompileExportByteArray])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Importing and Exporting, paclet:guide/ImportingAndExporting])}, {▪(RefLinkPlain[Network Programming, paclet:guide/NetworkProgramming])}, {▪(RefLinkPlain[Importing & Exporting Database Formats, paclet:guide/ImportingAndExportingDatabaseFormats])}, {▪(RefLinkPlain[Binary Data, paclet:guide/BinaryData])}, {▪(RefLinkPlain[Character Operations, paclet:guide/CharacterOperations])}})}})