# How can I export a text image?

**URL:** <https://community.wolfram.com/t/how-can-i-export-a-text-image/25323>\
**Category:** Questions\
**Tags:** image-processing\
**Created:** [April 1, 2025, 3:31am UTC](https://community.wolfram.com/t/how-can-i-export-a-text-image/25323 "2025-04-01T03:31:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hall9](https://avatars.discourse-cdn.com/v4/letter/h/f07891/32.png) [@hall9](https://community.wolfram.com/u/hall9)\
**Post date:** [April 1, 2025, 3:31am UTC](https://community.wolfram.com/t/how-can-i-export-a-text-image/25323/1 "2025-04-01T03:31:40Z")

</div>

I have what I hope is a very simple question. I’m working with a 50 pixel wide by 32 pixel high digital image and would like to learn how to export it as a TEXT image, i.e. 32 rows with 50 space-delimited Real32 numbers per row, ideally in scientific format and with NO formatting brackets.

Any suggestions would be greatly appreciated. Thanks much - Jim

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [April 1, 2025, 9:55am UTC](https://community.wolfram.com/t/how-can-i-export-a-text-image/25323/2 "2025-04-01T09:55:43Z")

</div>

Have you tried `ImageData`?

---

<div class="post-metadata">

**Author:** ![hall9](https://avatars.discourse-cdn.com/v4/letter/h/f07891/32.png) [@hall9](https://community.wolfram.com/u/hall9)\
**Post date:** [April 1, 2025, 5:45pm UTC](https://community.wolfram.com/t/how-can-i-export-a-text-image/25323/3 "2025-04-01T17:45:37Z")

</div>

Yes. I can use ImageData to generate an output text file, but it is littered with outer brackets, inner brackets, and extraneous descriptors that other image processing codes (e.g. ImageJ) don’t like. I would like to just dump 32 rows with 50 delimited numbers per row.

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [April 1, 2025, 6:15pm UTC](https://community.wolfram.com/t/how-can-i-export-a-text-image/25323/4 "2025-04-01T18:15:07Z")

</div>

I am no expert in image formats. You may try exporting to tsv, or something similar.

---

<div class="post-metadata">

**Author:** ![eric3](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/eric3/32/12760_2.png) [@eric3](https://community.wolfram.com/u/eric3)\
**Post date:** [April 1, 2025, 8:19pm UTC](https://community.wolfram.com/t/how-can-i-export-a-text-image/25323/5 "2025-04-01T20:19:16Z")

</div>

You could proceed like this:

```
image = RandomImage[{0, 1}, {5, 3}];(* Just test data *)

```

`ScientificForm ` allows you to format number using some version of scientific notation along with your own customizations.

```
ScientificForm[0.00962947, NumberFormat -> (StringJoin[#1, "*^", #3] & )]
(* 9.62947*^-3 *)

```

While the above looks like plain text, it’s actually a special front end “object”:

```
FullForm[ScientificForm[0.009629474952816963`, NumberFormat -> (StringJoin[#1, "*^", #3] & )]]
(* ScientificForm[0.009629474952816963`,Rule[NumberFormat,Function[StringJoin[Slot[1],"*^",Slot[3]]]]] *)

```

So, before exporting, you need to turn it into an actual string.

```
ToString[ScientificForm[0.009629474952816963`, NumberFormat -> (StringJoin[#1, "*^", #3] & )]]
(* "9.62947*^-3" *)

```

Now we can turn that into a function that process each pixel value of our `image`.

```
readyToExport =
  Map[ToString[ScientificForm[#, NumberFormat -> (StringJoin[#1, "*^", #3] & )]] &, ImageData[image], {-1}]
(* {{"5.80547*^-1", "7.10634*^-2", "1.66409*^-1", "7.99704*^-1", "7.71393*^-1"}, 
    {"1.45017*^-1", "2.94124*^-1", "5.34167*^-1", "8.0723*^-1", "6.22651*^-3"}, 
    {"1.41292*^-1", "9.58796*^-1", "3.46061*^-1", "3.44042*^-1", "8.9646*^-1"}} *)

```

Now we can export. I’ll use `ExportString` to demonstrate, but you can just use `Export` and supply a filename.

```
ExportString[readyToExport, "TSV", "IncludeQuotingCharacter" -> False]
(* 9.3502*^-1	4.1657*^-1	3.67851*^-1	3.34613*^-1	7.63106*^-1
   6.01477*^-1	6.27864*^-1	5.98659*^-1	3.99904*^-1	7.38507*^-1
   5.9335*^-1	3.01261*^-1	9.08788*^-1	9.16284*^-1	9.36047*^-1 *)

```

If you really need just spaces rather than tabs, then you’ll need to do a bit more preprocessing.

---

<div class="post-metadata">

**Author:** ![hall9](https://avatars.discourse-cdn.com/v4/letter/h/f07891/32.png) [@hall9](https://community.wolfram.com/u/hall9)\
**Post date:** [April 1, 2025, 9:58pm UTC](https://community.wolfram.com/t/how-can-i-export-a-text-image/25323/6 "2025-04-01T21:58:47Z")

</div>

Thanks for the suggestion, Eric! I’ll give this a try.
