# Failing to open and write .tiff images

**URL:** <https://root-forum.cern.ch/t/failing-to-open-and-write-tiff-images/35719>\
**Category:** Newbie\
**Created:** [August 21, 2019, 8:29am UTC](https://root-forum.cern.ch/t/failing-to-open-and-write-tiff-images/35719 "2019-08-21T08:29:44Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xola](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/xola/32/23153_2.png) [@Xola](https://root-forum.cern.ch/u/Xola)\
**Post date:** [August 21, 2019, 8:29am UTC](https://root-forum.cern.ch/t/failing-to-open-and-write-tiff-images/35719/1 "2019-08-21T08:29:44Z")

</div>

Hi

When I try to convert a .jpg image to a .tiff file I get the following message:

```auto
TImage *img1 = TImage::Open("/Users/cashcrusaders/Documents/cluster/Archive/cluster.jpg");
    if (!img1) {
        printf("Could not create an image... exit\n");
    }
    img->WriteImage("cluster.tiff")

```

But I get the following message:

```auto
Error in <TASImage::WriteImage>: error writing file cluster.tiff

```

I also tried to open a sample .tiff image that I got from the net using the following:

```auto
 TImage *img = TImage::Open("FLAG_T24.tiff")
img->IsValid()

```

where IsValid() return false. Is there perhaps something wrong with the way I installed ROOT?

---

<div class="post-metadata">

**Author:** ![amadio](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/amadio/32/12562_2.png) [@amadio](https://root-forum.cern.ch/u/amadio)\
**Post date:** [August 21, 2019, 9:05am UTC](https://root-forum.cern.ch/t/failing-to-open-and-write-tiff-images/35719/2 "2019-08-21T09:05:52Z")

</div>

If LibAfterImage does not have support for TIFF, then ROOT may be unable to do the conversion. However, if you are just converting a JPEG to TIFF, I highly recommend using [ImageMagick’s convert](https://imagemagick.org/script/convert.php) tool, as it can convert from/to many other formats as well and is really easy to use. In your case, you can do `convert cluster.jpg cluster.tiff` and it should just work. Cheers,

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [August 21, 2019, 9:07am UTC](https://root-forum.cern.ch/t/failing-to-open-and-write-tiff-images/35719/3 "2019-08-21T09:07:08Z")

</div>

> [@amadio](#):
>
> If LibAfterImage does not have support for TIFF

I need to check. I think it does.

---

<div class="post-metadata">

**Author:** ![amadio](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/amadio/32/12562_2.png) [@amadio](https://root-forum.cern.ch/u/amadio)\
**Post date:** [August 21, 2019, 9:08am UTC](https://root-forum.cern.ch/t/failing-to-open-and-write-tiff-images/35719/4 "2019-08-21T09:08:27Z")

</div>

The support for TIFF in LibAfterImage is optional, so it may or may not be enabled.

---

<div class="post-metadata">

**Author:** ![Xola](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/xola/32/23153_2.png) [@Xola](https://root-forum.cern.ch/u/Xola)\
**Post date:** [August 21, 2019, 9:20am UTC](https://root-forum.cern.ch/t/failing-to-open-and-write-tiff-images/35719/5 "2019-08-21T09:20:33Z")

</div>

I thought that because since astiff is ON by default when building ROOT then I would be able to open TIFF files. How do I go about enabling TIFF support for LibAfterImage?

---

<div class="post-metadata">

**Author:** ![Xola](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/xola/32/23153_2.png) [@Xola](https://root-forum.cern.ch/u/Xola)\
**Post date:** [August 23, 2019, 8:25am UTC](https://root-forum.cern.ch/t/failing-to-open-and-write-tiff-images/35719/6 "2019-08-23T08:25:26Z")

</div>

Hi

So I tried recompiling libafterimage using the following commands in order to enable support for tiff in /graf2d/asimage/src/libAfterImage:

```auto
./configure --with-tiff-includes=/usr/local/include 
make -j4 

```

I then reinstalled ROOT but I get the following error:

````auto
Undefined symbols for architecture x86_64:
  "_XDisplayHeight", referenced from:
      _asim_asxml_var_init in libAfterImage.a(afterbase.o)
  "_XDisplayWidth", referenced from:
      _asim_asxml_var_init in libAfterImage.a(afterbase.o)
  "_XGetGeometry", referenced from:
      _asim_get_drawable_size in libAfterImage.a(afterbase.o)
  "_XLookupColor", referenced from:
      _asim_parse_argb_color in libAfterImage.a(afterbase.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)```
````

---

<div class="post-metadata">

**Author:** ![amadio](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/amadio/32/12562_2.png) [@amadio](https://root-forum.cern.ch/u/amadio)\
**Post date:** [August 23, 2019, 8:57am UTC](https://root-forum.cern.ch/t/failing-to-open-and-write-tiff-images/35719/7 "2019-08-23T08:57:20Z")

</div>

You can also try to use an external installation of libafterimage, by setting `-Dbuiltin_afterimage=OFF` and installing in your own OS the devel package for it. Most Linux distributions do have it. BTW, if you are on a Mac, have you tried simply using `brew install root` to get ROOT? It may just be enough for what you need.

---

<div class="post-metadata">

**Author:** ![Xola](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/xola/32/23153_2.png) [@Xola](https://root-forum.cern.ch/u/Xola)\
**Post date:** [August 27, 2019, 9:17am UTC](https://root-forum.cern.ch/t/failing-to-open-and-write-tiff-images/35719/8 "2019-08-27T09:17:39Z")

</div>

Hi I just installed ROOT using brew but I still can’t write tiff images. I have also tried loading the libtiff libraries using gSystem but that did not seem to work either. Might there might be something wrong with my code…?

---

<div class="post-metadata">

**Author:** ![Xola](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/xola/32/23153_2.png) [@Xola](https://root-forum.cern.ch/u/Xola)\
**Post date:** [August 27, 2019, 9:47am UTC](https://root-forum.cern.ch/t/failing-to-open-and-write-tiff-images/35719/9 "2019-08-27T09:47:52Z")

</div>

Sorry. I forgot to mention that I am using ROOT 6.18.0

---

<div class="post-metadata">

**Author:** ![amadio](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/amadio/32/12562_2.png) [@amadio](https://root-forum.cern.ch/u/amadio)\
**Post date:** [August 27, 2019, 10:28am UTC](https://root-forum.cern.ch/t/failing-to-open-and-write-tiff-images/35719/10 "2019-08-27T10:28:13Z")

</div>

> [@Xola](#):
>
> Hi I just installed ROOT using brew but I still can’t write tiff images.

That probably means that the libAfterImage shipped by Homebrew does not have support for TIFF. I really recommend to just write another format and convert to TIFF later with ImageMagick.

---

<div class="post-metadata">

**Author:** ![Xola](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/xola/32/23153_2.png) [@Xola](https://root-forum.cern.ch/u/Xola)\
**Post date:** [August 27, 2019, 10:38am UTC](https://root-forum.cern.ch/t/failing-to-open-and-write-tiff-images/35719/11 "2019-08-27T10:38:38Z")

</div>

Yeah maybe that would be the better option at this point. Thank you very much
