({{, (RefLink[ImportByteArray, paclet:ref/ImportByteArray])[ba,"format"] 
imports data in the specified format from a (RefLink[ByteArray, paclet:ref/ByteArray]) object.}, {, (RefLink[ImportByteArray, paclet:ref/ImportByteArray])[ba,elements]
imports the specified elements.}, {, (RefLink[ImportByteArray, paclet:ref/ImportByteArray])[ba]
attempts to determine the format automatically.}})

OpenersNotesSection(Spacer1)Details

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

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

OpenersPrimaryExamplesSection(Spacer1)Examples  (5)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

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

bytes=ExportByteArray[,"PNG"]

Import the bytes to produce the original image:

ImportByteArray[bytes]

Import an element from the bytes:

ImportByteArray[bytes,"ImageSize"]

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"]

Import a color map and corresponding raw data from a (RefLink[ByteArray, paclet:ref/ByteArray]):

{map,data}===ImportByteArray[bytes,{{"ColorMap","RawData"}}]

OpenersExampleSection3(Spacer1)Properties & Relations  (1)

(RefLink[ImportByteArray, paclet:ref/ImportByteArray]) returns the same result as (RefLink[ByteArrayToString, paclet:ref/ByteArrayToString]) followed by (RefLink[ImportString, paclet:ref/ImportString]):

bytes=ExportByteArray[,"TIFF"];

ImportByteArray[bytes]===ImportString[ByteArrayToString[bytes,"ISO8859-1"]]

OpenersExampleSection4(Spacer1)Possible Issues  (1)

A list of bytes is returned when (RefLink[ImportByteArray, paclet:ref/ImportByteArray]) cannot automatically determine the format:

ImportByteArray[ExportByteArray["aα","Text"]]

Specify the format to get a string result:

ImportByteArray[ExportByteArray["aα","Text"], "Text"]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[ExportByteArray, paclet:ref/ExportByteArray])  ▪  (RefLink[ByteArrayToString, paclet:ref/ByteArrayToString])  ▪  (RefLink[ReadByteArray, paclet:ref/ReadByteArray])  ▪  (RefLink[ImportString, paclet:ref/ImportString])  ▪  (RefLink[ByteArray, paclet:ref/ByteArray])  ▪  (RefLink[Import, paclet:ref/Import])  ▪  (RefLink[NotebookImport, paclet:ref/NotebookImport])}})}})

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