# saving image in binary

**URL:** https://discourse.paraview.org/t/saving-image-in-binary/7808
**Category:** ParaView Support
**Created:** [August 12, 2021, 1:44pm UTC](https://discourse.paraview.org/t/saving-image-in-binary/7808 "2021-08-12T13:44:59Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![HeshamFS](https://discourse.paraview.org/user_avatar/discourse.paraview.org/heshamfs/32/6960_2.png) [@HeshamFS](https://discourse.paraview.org/u/HeshamFS)
#### Post date: [August 12, 2021, 1:44pm UTC](https://discourse.paraview.org/t/saving-image-in-binary/7808/1 "2021-08-12T13:44:59Z")

</div>

Dear community members,

I do not want to save the entire screenshot of my sliced microstructure.

Is there a way to save only the sliced microstructure as binary image using pvpython?

I hope I will find my answer here.

Thank you for the great support

Best regards,  
Hesham Salama

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [August 12, 2021, 1:48pm UTC](https://discourse.paraview.org/t/saving-image-in-binary/7808/2 "2021-08-12T13:48:11Z")

</div>

This is unclear. Please add a screenshot of what you are trying to do.

---

<div class="post-metadata">

### Author: ![HeshamFS](https://discourse.paraview.org/user_avatar/discourse.paraview.org/heshamfs/32/6960_2.png) [@HeshamFS](https://discourse.paraview.org/u/HeshamFS)
#### Post date: [August 12, 2021, 1:52pm UTC](https://discourse.paraview.org/t/saving-image-in-binary/7808/3 "2021-08-12T13:52:40Z")

</div>

![image](https://discourse.paraview.org/uploads/default/original/2X/f/fc6d66c42231884aea2003a7e4e38bf088c1751a.jpeg)

Here is the sliced microstructure, how to save this as a binary image without the background, just the microstructure?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [August 12, 2021, 1:58pm UTC](https://discourse.paraview.org/t/saving-image-in-binary/7808/4 "2021-08-12T13:58:12Z")

</div>

File → Save Data → PNG

---

<div class="post-metadata">

### Author: ![HeshamFS](https://discourse.paraview.org/user_avatar/discourse.paraview.org/heshamfs/32/6960_2.png) [@HeshamFS](https://discourse.paraview.org/u/HeshamFS)
#### Post date: [August 12, 2021, 2:02pm UTC](https://discourse.paraview.org/t/saving-image-in-binary/7808/5 "2021-08-12T14:02:19Z")

</div>

There is no PNG or any other image format in save data

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [August 12, 2021, 2:09pm UTC](https://discourse.paraview.org/t/saving-image-in-binary/7808/6 "2021-08-12T14:09:38Z")

</div>

Good point, you can’t save a polydata as a .png. I’m not sure this is possible without a custom filter.

---

<div class="post-metadata">

### Author: ![HeshamFS](https://discourse.paraview.org/user_avatar/discourse.paraview.org/heshamfs/32/6960_2.png) [@HeshamFS](https://discourse.paraview.org/u/HeshamFS)
#### Post date: [August 12, 2021, 2:22pm UTC](https://discourse.paraview.org/t/saving-image-in-binary/7808/7 "2021-08-12T14:22:07Z")

</div>

So, according to your answer, there is no way to save the image as data but only as a screenshot and then crop it by any other means. Is that correct?

---

<div class="post-metadata">

### Author: ![Kenneth\_Moreland](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kenneth_moreland/32/15033_2.png) [@Kenneth\_Moreland](https://discourse.paraview.org/u/Kenneth_Moreland)
#### Post date: [August 12, 2021, 3:40pm UTC](https://discourse.paraview.org/t/saving-image-in-binary/7808/8 "2021-08-12T15:40:38Z")

</div>

It would be technically possible to use `Resample To Image` to resample your polydata to a 2D image (make the 3rd dimension size 1). From there you could theoretically save as a PNG.

But the PNG file format is pretty limited. It can only accept certain types of data, so there is a good chance the save will fail anyway. It may take some custom processing to get the field data to a form that is acceptable to PNG.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [August 12, 2021, 3:41pm UTC](https://discourse.paraview.org/t/saving-image-in-binary/7808/9 "2021-08-12T15:41:32Z")

</div>

@Kenneth_Moreland : I’ve never been able to use RessampleToImage with a slice. I’m planning to open an issue at some point but more investigation is needed.

---

<div class="post-metadata">

### Author: ![Kenneth\_Moreland](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kenneth_moreland/32/15033_2.png) [@Kenneth\_Moreland](https://discourse.paraview.org/u/Kenneth_Moreland)
#### Post date: [August 12, 2021, 3:55pm UTC](https://discourse.paraview.org/t/saving-image-in-binary/7808/10 "2021-08-12T15:55:30Z")

</div>

Oh, yeah. There is that floating point issue of the sample points lying exactly in the plane of the polygons. I think it works out OK if you have a slice exactly in the x-y plane (z=0), but fails if you move the slice up or down.
