Many medical journals and publishers require that images, whether photographs or line art, be submitted as high resolution .TIFF images. One option for R users is to produce an image in one format and to convert it to a .TIFF file using a second software program. My experience has been that this option often results in images of poorer quality, often with blurry contours, and a loss of resolution. A second and better option would be to make .TIFF files directly from the graphic output of R. I recently noticed that there is a library called "rtiff" that may be able to do this. However, I have not been able to get it to work, principally because I do not know how to install the required supporting software, libtiff and tiffio.h, correctly on my computer. I am running R 2.4.0 on a Windows XP machine. So far I have done the following: 1) Loaded the rtiff library 2) Downloaded and installed the TIFF library 3.8.2 (complete package and sources) from the following website: http://gnuwin32.sourceforge.net/packages/tiff.htm I would like to ask the R experts for help with the following things: 1) Where do I get the tiffio.h file? 2) Where do I install or relocate the tiffio.h and TIFF library to so that rtiff will work? Thanks for your help. Brant Inman Mayo Clinic
From: Inman, Brant A. M.D. [mailto:Inman.Brant at mayo.edu]>Many medical journals and publishers require that images, whether >photographs or line art, be submitted as high resolution .TIFF images. >One option for R users is to produce an image in one format and to >convert it to a .TIFF file using a second software program. My >experience has been that this option often results in images of poorer >quality, often with blurry contours, and a loss of resolution. A second >and better option would be to make .TIFF files directly from the graphic >output of R. > >I recently noticed that there is a library called "rtiff" that may be >able to do this. However, I have not been able to get it to work, >principally because I do not know how to install the required supporting >software, libtiff and tiffio.h, correctly on my computer. I am running R >2.4.0 on a Windows XP machine. So far I have done the following:If only. Sadly, rtiff only reads tiffs, and writes pixmap objects as tiffs. It does not create a rendering device for capturing plots to a tiff file, in the way that jpeg() does for jpegs. This very thought occurred to me a couple months ago, but I was skeptical that the effort would be worth it. I usually render to postscript and convert from there with high quality results...but this is a bit tedious and time consuming. Now that there are two of us in the universe who would like a tiff() rendering device for R, maybe it would be worth it. It would be especially worth it if there was someone else conversant in the non-tiff specific aspects of the task. If that would be the case I would be happy to code the TIFF I/O. Lacking that, I will need to look at the requirements some more to verify whether I have the requisite neurons to carry it off. To answer your installation question, all that is required for the windows binary to run is to copy the tiff related DLLs provided in the gnuwin binary package somewhere on your PATH (tiffio.h and other development files are not required unless you are going to build the package from source). -Eric (apologies for the legal notice that may appear here...beyond my control!) This email message, including any attachments, is for the so...{{dropped}}
Brant, On Jan 11, 2007, at 9:33 PM, Inman, Brant A. M.D. wrote:> Many medical journals and publishers require that images, whether > photographs or line art, be submitted as high resolution .TIFF images. > One option for R users is to produce an image in one format and to > convert it to a .TIFF file using a second software program. My > experience has been that this option often results in images of poorer > quality, often with blurry contours, and a loss of resolution. A > second > and better option would be to make .TIFF files directly from the > graphic > output of R. >[...] Have you tried bitmap()?. You might need to install ghostscript before it works on your system but the results are super. I use bitmap(blah, type = "png256", res = 1200) to make *.png files which are small and can be inserted in to an MS Word manuscript for review. When a TIFF is needed by the journal, bitmap(blah, type = "tifflzw", res = 1200) will do the trick. (If a color plot is being created, you can use something like type = "tiff24nc". The color files are huge but can be zipped to something reasonable.) Hope this helps, Stephen Rochester, Minnesota, USA
Kort, Eric wrote:> From: Inman, Brant A. M.D. [mailto:Inman.Brant at mayo.edu] > >> Many medical journals and publishers require that images, whether >> photographs or line art, be submitted as high resolution .TIFF images. >> One option for R users is to produce an image in one format and to >> convert it to a .TIFF file using a second software program. My >> experience has been that this option often results in images of poorer >> quality, often with blurry contours, and a loss of resolution. A second >> and better option would be to make .TIFF files directly from the graphic >> output of R. >> >> I recently noticed that there is a library called "rtiff" that may be >> able to do this. However, I have not been able to get it to work, >> principally because I do not know how to install the required supporting >> software, libtiff and tiffio.h, correctly on my computer. I am running R >> 2.4.0 on a Windows XP machine. So far I have done the following: > > If only. Sadly, rtiff only reads tiffs, and writes pixmap objects as tiffs. > It does not create a rendering device for capturing plots to a tiff file, in > the way that jpeg() does for jpegs. > > This very thought occurred to me a couple months ago, but I was skeptical > that the effort would be worth it. I usually render to postscript and > convert from there with high quality results...but this is a bit tedious and > time consuming. Now that there are two of us in the universe who would like > a tiff() rendering device for R, maybe it would be worth it. It would be > especially worth it if there was someone else conversant in the non-tiff > specific aspects of the task. If that would be the case I would be happy to > code the TIFF I/O. Lacking that, I will need to look at the requirements > some more to verify whether I have the requisite neurons to carry it off. > > To answer your installation question, all that is required for the windows > binary to run is to copy the tiff related DLLs provided in the gnuwin binary > package somewhere on your PATH (tiffio.h and other development files are > not required unless you are going to build the package from source). > > -EricSome journals are not really serious about the TIFF rule and will accept postscript or pdf anyway. -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University
Let us be clear that TIFF is not a format, it is a collection of formats and for example my camera's RAW images are TIFFs, as are Adobe's DNG files. (See e.g. http://en.wikipedia.org/wiki/TIFF.) So the journals concerned are misusing the term. It is very easy to convert either JPEGs or PNGs to a TIFF subformat with ImageMagick, PhotoShop or other tools, and the bitmap() driver can write several versions of TIFF by converting from postscript (transparently to the user). I think the complaints in this thread are a bit rich given how much R aleady provides. We thought about adding a few TIFF formats to PNG, JPEG and BMP but agreed it was not worth effort (especially given the vagueness with which 'TIFF' is used and stories about journals rejecting perfectly valid TIFF files). [I don't recall anyone ever writing to thank us for the PNG or JPEG or bitmap drivers, and lack of appreciation does play a part.] An 8-bit TIFF device is not going to produce better images than the PNG one, just larger files. (It could if you rendered HDR TIFF images, but the journal will not be able to cope with those.) On Thu, 11 Jan 2007, Inman, Brant A. M.D. wrote:> Many medical journals and publishers require that images, whether > photographs or line art, be submitted as high resolution .TIFF images. > One option for R users is to produce an image in one format and to > convert it to a .TIFF file using a second software program. My > experience has been that this option often results in images of poorer > quality, often with blurry contours, and a loss of resolution. A second > and better option would be to make .TIFF files directly from the graphic > output of R.As TIFF is collection of bitmap formats, the blurriness is intrinisic to the format. You are not telling us what you converted *from* (nor what sort of images these are nor what convertor you used): for most R applications PNG is the right image format to convert from and conversion from PNG to TIFF will be lossless. (PS/PDF are not image formats, but also good starting points for conversion.)> I recently noticed that there is a library called "rtiff" that may be > able to do this. However, I have not been able to get it to work, > principally because I do not know how to install the required supporting > software, libtiff and tiffio.h, correctly on my computer. I am running R > 2.4.0 on a Windows XP machine. So far I have done the following: > > 1) Loaded the rtiff libraryDo you mean 'package'? There is a precompiled Windows build: did you use that? What it needs is libtiff3.dll, which is in the software you downloaded: put it in R_HOME/rtiff/libs or somewhere on your PATH. (Sadly, the package is lacking adequate instructions.)> 2) Downloaded and installed the TIFF library 3.8.2 (complete package and > sources) from the following website: > http://gnuwin32.sourceforge.net/packages/tiff.htm > > I would like to ask the R experts for help with the following things: > > 1) Where do I get the tiffio.h file?It is part of the libtiff software you downloaded, but it says it is only needed to install from the sources.> 2) Where do I install or relocate the tiffio.h and TIFF library to so > that rtiff will work? > > Thanks for your help. > > Brant Inman > Mayo Clinic > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Thank you Peter Dalgaard. When I open a DOS box and type gswin32c, I do indeed get an error message saying that it can't find the program. I edited the Windows system environmental variable "Path" and the user environmental variable "PATH" (wasn't sure which to edit), to contain the follwing after a semicolon "C:\Program Files\gs\gs8.54\bin\". This effectively fixed the Dos box problem. I now get a GS prompt when I type gswin32c. When I restart R and use the following code, I no longer get an error message. --------> attach(cars) > bitmap(file='C:\\Documents and Settings\\m007704\\Desktop\\test.tif',+ type = "tifflzw", res = 1200)> plot(speed ~ dist)-------- Alas, if it was only that easy! When I look on my desktop (to which the file address above correctly refers to), there is no image file of any sort to be found. Any ideas as to what I am doing wrong? Brant Inman --------------------------------------------------------------------- It needs to be in your Path. If you open up a "DOS box" and type gswin32c, I bet you get the same error message. You can fix this by editing the Path (via My Computer/Properties/Advanced/Environment variables, as you seem to know). If you use the R_GSCMD route, you may get in trouble with the embedded space in "Program Files" ("dir/x c:" will tell you the equivalent space-free name). Also, remember that environment changes do not affect running programs so you may need to exit R and restart. -- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
Several R Helpers pointed out that I forgot to include the dev.off() statement in my code. This solved my problem with one caviat: the output file address cannot have any spaces in it (as pointed out by Chuck Cleland). For instance: ------------ # This file location works great bitmap(file='C:\\temp\\test.tif', type = "tifflzw", res = 1200) plot(speed ~ dist) dev.off() # This file location does not work, despite being accurate bitmap(file='C:\\Documents and Settings\\m007704\\Desktop\\test.tif', type = "tifflzw", res = 1200) plot(speed ~ dist) dev.off() ------------ For the benefit of those that may need to make TIFF files in the future and don't know how to do it, I will recapitulate below the steps required to produce a TIFF file using R on a Windows XP machine. 1) Download and install a current version of Ghostscript. You probably need GPL(GNU General Public License) version of Ghostscript. For Windows, the correct file to download is called: gs854w32-gpl.exe. To download this file, go to one of the following websites: http://www.cs.wisc.edu/~ghost/ http://sourceforge.net/projects/ghostscript/ 2) Add Ghostscript to a Windows environmental variable. Right click on the My Computer icon on your desktop. Select: Properties> Advanced > Environmental Variables. You will see 2 boxes, one foruser variables and one for system variables. In the user variables section, highlight the variable called "PATH" and then click edit. Click on the variable value box and go to the end of whatever is written there (don't erase it). Enter the following after the last bit of text: ";C:\Program Files\gs\gs8.54\bin\". This is the location on you computer where it can find the gswin32c.exe file that it needs to start Ghostscript. 3) Use the bitmap function to produce a TIFF Now you should be ready to make a TIFF. The following code is a simple example that you can use to see if everything is set up right on your PC. attach(cars) bitmap(file='C:\\temp\\test.tif', type = "tifflzw", res = 1200) plot(speed ~ dist) dev.off() This should produce a TIFF file called 'test.tif' in the 'temp' directory of your PC. If you do not have a directory of this name, substitute for one that exists (or create one). Note that the file argument does not seem to handle and spaces in the directory address, so select an address without spaces in it. Note also that, as pointed out by Ripley in this thread, there are different TIFF formats which can be made with R. My understanding is that the different formats have to do with different image compression algorithms, but you can read more about these details (and clues to why TIFF files seem to be prefered by some publishers and imaging software makers) at: http://en.wikipedia.org/wiki/Comparison_of_graphics_file_formats You can also type ?bitmap to see what R can output for you and read more about the TIFF file format at: http://en.wikipedia.org/wiki/Tiff I regret that I cannot comment on Unix or Mac computers as it has been nearly 15 years since I have used these types of machines and I therefore have no knowledge whatsoever that might be of use for users of these systems. Brant Inman
http://www.ebi.ac.uk/~osklyar/EBImage or http://bioconductor.org/packages/2.0/bioc/html/EBImage.html will read/write more than 90 formats including TIFF. Trivial to install and run on Windows. Regards, Oleg On 12/01/07, Inman, Brant A. M.D. <Inman.Brant@mayo.edu> wrote:> > Many medical journals and publishers require that images, whether > photographs or line art, be submitted as high resolution .TIFF images. > One option for R users is to produce an image in one format and to > convert it to a .TIFF file using a second software program. My > experience has been that this option often results in images of poorer > quality, often with blurry contours, and a loss of resolution. A second > and better option would be to make .TIFF files directly from the graphic > output of R. > > I recently noticed that there is a library called "rtiff" that may be > able to do this. However, I have not been able to get it to work, > principally because I do not know how to install the required supporting > software, libtiff and tiffio.h, correctly on my computer. I am running R > 2.4.0 on a Windows XP machine. So far I have done the following: > > 1) Loaded the rtiff library > > 2) Downloaded and installed the TIFF library 3.8.2 (complete package and > sources) from the following website: > http://gnuwin32.sourceforge.net/packages/tiff.htm > > I would like to ask the R experts for help with the following things: > > 1) Where do I get the tiffio.h file? > > 2) Where do I install or relocate the tiffio.h and TIFF library to so > that rtiff will work? > > Thanks for your help. > > Brant Inman > Mayo Clinic > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]