ImportByteArray[ba,"format"]
imports data in the specified format from a ByteArray object.
ImportByteArray[ba,elements]
imports the specified elements.
ImportByteArray[ba]
attempts to determine the format automatically.
ImportByteArray
Listing of Formats »ImportByteArray[ba,"format"]
imports data in the specified format from a ByteArray object.
ImportByteArray[ba,elements]
imports the specified elements.
ImportByteArray[ba]
attempts to determine the format automatically.
Details
- ImportByteArray imports data in the specified format from a byte array.
- ImportByteArray handles a large number of formats, each typically with many different possible elements. The possible formats are given in the list $ImportFormats and in the "Listing of All Formats".
- ImportByteArray works just like Import, with the same element specifications and options.
Examples
open all close allBasic Examples (1)
Export an image as a ByteArray object:
bytes = ExportByteArray[[image], "PNG"]Import the bytes to produce the original image:
ImportByteArray[bytes]Import an element from the bytes:
ImportByteArray[bytes, "ImageSize"]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"]Import a color map and corresponding raw data from a ByteArray:
{map, data} === ImportByteArray[bytes, {{"ColorMap", "RawData"}}]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 (2)
ImportByteArray returns the same result as ByteArrayToString followed by ImportString:
bytes = ExportByteArray[[image], "TIFF"];ImportByteArray[bytes] === ImportString[ByteArrayToString[bytes, "ISO8859-1"]]Import can be viewed as a combination of ReadByteArray and ImportByteArray:
file = Export[CreateFile[], [image], "JPEG"];Import[file, "JPEG"] === ImportByteArray[ReadByteArray[file], "JPEG"]Possible Issues (1)
A list of bytes is returned when ImportByteArray cannot automatically determine the format:
ImportByteArray[ExportByteArray["aα", "Text"]]Specify the format to get a string result:
ImportByteArray[ExportByteArray["aα", "Text"], "Text"]See Also
ExportByteArray ByteArrayToString ReadByteArray ImportString ByteArrayFormat FileFormatProperties SetFileFormatProperties ByteArray Import NotebookImport
Function Repository: ReadPNG
Related Guides
History
Text
Wolfram Research (2017), ImportByteArray, Wolfram Language function, https://reference.wolfram.com/language/ref/ImportByteArray.html.
CMS
Wolfram Language. 2017. "ImportByteArray." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ImportByteArray.html.
APA
Wolfram Language. (2017). ImportByteArray. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ImportByteArray.html
BibTeX
@misc{reference.wolfram_2026_importbytearray, author="Wolfram Research", title="{ImportByteArray}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/ImportByteArray.html}", note=[Accessed: 15-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_importbytearray, organization={Wolfram Research}, title={ImportByteArray}, year={2017}, url={https://reference.wolfram.com/language/ref/ImportByteArray.html}, note=[Accessed: 15-June-2026]}