0

I'm attempting to use the magick R package to do some image editing. However, I am unable to read in GeoTIFF files. When I try this:

magick::image_read(RGBFile)

I get the following error message:

Error in magick_image_readpath(path, density, depth, strip) : 
  Magick: Unknown field with tag 34737 (0x87b1) encountered. 
`TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/912

After doing some research, I've concluded that the GeoTIFF tags are the issue.

I've written to the package maintainer to see if an update to the package might allow GeoTIFFs to be read, but in the meantime, is anyone aware of a way of an way of removing GeoTIFF tags without re-copying the entire file? (Or any other efficient workaround for dealing with large >1 GB images)

Thanks!

lobati
  • 9,284
  • 5
  • 40
  • 61
Andrew Plowright
  • 455
  • 4
  • 11
  • 1
    In ImageMagick command line, you can avoid seeing TIFF tag warnings using -quiet. I do not know the Rmagick tool, so cannot say why it is failing. Typically in command line, it issues warnings about tags that it does not know, but still processes the image. So perhaps there is something else at issue. You can also strip all the meta data using -strip in command line. – fmw42 Jun 01 '18 at 19:14
  • 2
    It's common to have `libtiff` emit warnings, as the format can have various 3rd-party/vendor extensions (GeoTIFF as an example). Most are harmless to the image data, but I wonder why the R package converts the warnings to errors. – emcconville Jun 01 '18 at 19:17
  • 1
    You could use EXIFTOOL to strip all meta data or just the GeoTiff tags. – fmw42 Jun 01 '18 at 19:21
  • Yeah it's weird but in R the warnings become errors. I doesn't seem like EXIFTOOL will work either. GeoTIFF tags are possibly protected somehow? – Andrew Plowright Jun 01 '18 at 19:29
  • Can you post a small example tiff image with geotags? I am puzzled why exiftool cannot deal with them. Is there some setting in Rmagick that would also you to prevent warnings from becoming errors? – fmw42 Jun 01 '18 at 21:15
  • Have you tried using `magick_image_readpath(path, density, depth, strip)` to strip the meta data? What is your input image format? – fmw42 Jun 01 '18 at 21:16
  • The package maintainer has actually fixed this bug! If you're curious, here is a sample GeoTIFF that ran into the problem: https://drive.google.com/open?id=10qtrZFmud5aoLnu1fQ5-SBzOaOc6U_9Q – Andrew Plowright Jun 02 '18 at 00:06
  • 1
    EXIFTOOL does list geotiff tags for your image. So there is no reason to believe that it cannot be used to remove them. Nevertheless, if it is a fixed bug and you can wait or get it downloaded, then that is the way to go. – fmw42 Jun 02 '18 at 00:09

1 Answers1

0

I have contacted the package maintainer and this bug has been fixed! It hasn't made it onto CRAN as of this posting but in the meantime installing magick with devtools::install_github("ropensci/magick") should do the trick.

Andrew Plowright
  • 455
  • 4
  • 11