0

I am trying to export/save some cimg arrays as tiff images in R using the package imager.

However, the output is not in the correct format. How to fix this ?

library(imager)
library(tiff)

tifftest <- imager::load.image(file = system.file("img", "Rlogo.tiff", package="tiff"))
plot(tifftest)

enter image description here

imager::save.image(im = tifftest, file = "test.tiff", quality = 1)

enter image description here

The link to the raw tiff file in the above example is below.

https://github.com/s-u/tiff/raw/master/inst/img/Rlogo.tiff

Crops
  • 5,024
  • 5
  • 38
  • 65
  • You tagged with `cimg` the C++ library. I don’t know how it is related to R? – Cris Luengo Mar 24 '23 at 13:44
  • @CrisLuengo `Imager` is an `R` add-on package which is wrapper for `cimg` `C++` library. – Crops Apr 03 '23 at 05:28
  • Your code reads and writes TIFF images, but you have posted 2 PNG images? Please add links to your TIFFs - use Dropbox or Google Drive or somesuch. Thank you. And what do you mean by *"not in the correct format"* - do you mean you asked for a TIFF but got a PNG? And why `quality=1` that's rather low, isn't it? – Mark Setchell May 06 '23 at 20:38
  • @MarkSetchell I have added the link to the original tiff file. The first image is the ouput of the plot command which is a png. The second image is the output tiff file which when uploaded to SO got converted to png. – Crops May 09 '23 at 10:53
  • @MarkSetchell By "not in the correct format" I meant that the output image is a tiff file but does not look anything like the source file. `quality=1` is a jpeg only option. It is ignored for tiff (https://rdrr.io/cran/imager/man/save.image.html). – Crops May 09 '23 at 10:55

0 Answers0