2

How can I create a TIFF image file in R that can be opened by Photoshop?

Previously, I used the following code to create TIFF files that readily opened by an old version of Photoshop (5.x). However, the same files do not open in the new version of Photoshop (23.0.0 20211013.r.36 623993d x64). It returns an error message:

could not complete your request because it is not the right kind of document

Other file formats (JPEG, PDF) created in R, using similar code, open readily in this version of Photoshop. The files are not corrupted as they can be opened in Window's "Photos".

Code:

x <- 1:10
y <- 1:10
gdata <- data.frame(x,y)

library(ggplot2)
ggplot(aes(x, y), data = gdata) + geom_point()

ggsave("GraphTest.tiff", units="cm", width=17, height=21, dpi=300, compression = 'lzw')
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Ido Tsurim
  • 21
  • 2
  • 1
    Hmm - I'm not convinced that closing this question as "not about programming" was the correct call. @IdoTsurim - I would suggest you edit the question to be more clearly about the R part of the problem than the photshop end, then perhaps this can be re-opened. I.e. change it to "How can I create an image tiff file in R that can be opened by photoshop". The question body would also need some improvement - i.e. a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) of some code that generates an image you can't open. – dww Feb 11 '22 at 15:48
  • @dww If the files open just fine in older versions of Photoshop, then the problem very likely isn't with the code, but with Photoshop, which makes this not a programming question. – Mark Rotteveel Feb 13 '22 at 09:14
  • Mark is probably right, but it is also possible that there is a programming solution to bypass this problem and allow R users to produce Tiff files that open in the new photoshop – Ido Tsurim Feb 13 '22 at 11:48
  • It is highly likely that there is a programming solution. ggsave can send tiff output to a variety of devices, depending on what you have available. @IdoTsurim - while we wait for another reopen vote, can you post the output of `capabilities("cairo")` and `isTRUE(require('ragg'))` into your question, to aid with diagnostics. You could also try printing using the base `tiff` function and specifying the `type` argument. – dww Feb 13 '22 at 13:32
  • another thought - can you try without the compression argument (or a different one) – dww Feb 13 '22 at 13:47
  • Try running `exiftool` on an *"unhappy"* image that will not load into Photoshop, i.e. `exiftool -v UNHAPPY.TIF` and edit the output into your question. Likewise `tiffinfo` or **ImageMagick** `magick identify -verbose UNHAPPY.TIF` – Mark Setchell Feb 13 '22 at 23:42
  • @dww - 1) removing the compression argument did not help. 2) using the base tiff function did not help. 3) capabilities("cairo") resulted in cairo TRUE. 3) as for running isTRUE(require('ragg')) - do you mean to install the package and then run it ? – Ido Tsurim Feb 14 '22 at 10:37

0 Answers0