ExportByteArray[expr,"format"]
generates a ByteArray object corresponding to expr exported in the specified format.
ExportByteArray[exprs,elems]
generates a ByteArray object by treating exprs as elements specified by elems.
ExportByteArray
Listing of Formats »ExportByteArray[expr,"format"]
generates a ByteArray object corresponding to expr exported in the specified format.
ExportByteArray[exprs,elems]
generates a ByteArray object by treating exprs as elements specified by elems.
Details
- ExportByteArray generates a byte array corresponding to data exported in the specified format.
- ExportByteArray handles a large number of formats, each typically with many different possible elements. The possible formats are given in the list $ExportFormats and in the "Listing of All Formats".
- ExportByteArray works just like Export, with the same element specifications and options.
Examples
open all close allBasic Examples (2)
Export an image as a ByteArray object:
bytes = ExportByteArray[[image], "PNG"]Import the bytes to produce the original image:
ImportByteArray[bytes]Export an image as a ByteArray object:
bytes = ExportByteArray[[image], "PNG"]Write the bytes to a temporary file:
tmp = CreateFile[];
BinaryWrite[tmp, bytes];
Close[tmp];Verify the bytes were correctly written by importing the file:
Import[tmp]Scope (2)
Export a typeset mathematical formula as a ByteArray object:
formula = Integrate[Sqrt[x + Sqrt[x]], x] // TraditionalFormbytes = 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 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"]Applications (2)
Store an integer into a ByteArray:
ExportByteArray[1234, "Integer64"]Retrieve the number from the byte array:
ImportByteArray[%, "Integer64"]Store a big number into a "Base64" encoded ByteArray:
ExportByteArray[ToString[2 ^ 1234, InputForm], "Base64"]Retrieve the number from the byte array:
ToExpression[ImportByteArray[%, "Base64"]]% == 2 ^ 1234Properties & Relations (3)
ExportByteArray returns the same result as ExportString followed by StringToByteArray:
graphics = [image];ExportByteArray[graphics, "TIFF"] === StringToByteArray[ExportString[graphics, "TIFF"], "ISO8859-1"]ExportByteArray returns the same result as Export followed by ReadByteArray:
graphics = [image];ExportByteArray[graphics, "JPEG"] === ReadByteArray[Export[CreateFile[], graphics, "JPEG"]]If the export produces no data, an empty byte array is returned:
ExportByteArray["", "Text"]Related Guides
History
Text
Wolfram Research (2017), ExportByteArray, Wolfram Language function, https://reference.wolfram.com/language/ref/ExportByteArray.html.
CMS
Wolfram Language. 2017. "ExportByteArray." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ExportByteArray.html.
APA
Wolfram Language. (2017). ExportByteArray. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ExportByteArray.html
BibTeX
@misc{reference.wolfram_2026_exportbytearray, author="Wolfram Research", title="{ExportByteArray}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/ExportByteArray.html}", note=[Accessed: 15-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_exportbytearray, organization={Wolfram Research}, title={ExportByteArray}, year={2017}, url={https://reference.wolfram.com/language/ref/ExportByteArray.html}, note=[Accessed: 15-June-2026]}