Giter VIP home page Giter VIP logo

ijtiff's Introduction

ijtiff

R-CMD-check

Project Status: Inactive – The project has reached a stable, usable state but is no longer being actively developed; support/maintenance will be provided as time allows.

CRAN_Status_Badge RStudio CRAN downloads RStudio CRAN monthly downloads

DOI

Introduction

This is a general purpose TIFF I/O utility for R. The tiff package already exists for this purpose but ijtiff adds some functionality and overcomes some bugs therein.

  • ijtiff can write TIFF files whose pixel values are real (floating-point) numbers; tiff cannot.
  • ijtiff can read and write text images; tiff cannot.
  • tiff struggles to interpret channel information and gives cryptic errors when reading TIFF files written by the ImageJ software; ijtiff works smoothly with these images.

To learn about ijtiff and how to use it, visit the package website at https://docs.ropensci.org/ijtiff/.

Installation

libtiff

ijtiff requires you to have the libtiff C library installed. To install libtiff:

  • On Debian Linux, try sudo apt-get install libtiff-dev libbz2-dev libdeflate-dev liblzma-dev libwebp-dev libzstd-dev zlib1g-dev.
  • On Fedora Linux, try sudo yum install libtiff-devel libbz2-devel libdeflate-devel liblzma-devel libwebp-devel libzstd-devel zlib-devel.
  • On Mac, you need Homebrew. Then in the terminal, run brew install libtiff.
  • On Windows, no setup is required.

Installing the release version of the ijtiff R package

You can install ijtiff from CRAN (recommended) with:

install.packages("ijtiff")

Installing the development version of the ijtiff R package

You can install the development version from GitHub with:

devtools::install_github("ropensci/ijtiff")

Acknowledgement

This package uses a lot of code from the original tiff package by Simon Urbanek.

Contribution

Contributions to this package are welcome. The preferred method of contribution is through a github pull request. Feel free to contact me by creating an issue. Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

ropensci_footer

ijtiff's People

Contributors

jeroen avatar maelle avatar muschellij2 avatar rorynolan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ijtiff's Issues

`path` argument for tif_write

Hi,

It seems that contrary to what doc mentions , it is not possible to use path = raw(0)
So as to export image to raw vecotr rather than writing to file.

Fails to install in Fedora

I see the following:

Found pkg-config! 
Found pkg-config cflags and/or libs for libtiff! 
Using PKG_CFLAGS= 
Using PKG_LIBS=-ltiff -lwebp -lzstd -ljpeg -lz -lm 
** finished configure for package 'ijtiff'
** libs
gcc -m64 -I"/usr/include/R" -DNDEBUG   -I/usr/local/include   -fpic  -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64  -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection  -c common.c -o common.o
In file included from common.c:1:
common.h:26:32: error: conflicting types for 'uint64_t'; have 'long long unsigned int'
   26 | typedef unsigned long long int uint64_t;
      |                                ^~~~~~~~
In file included from /usr/include/stdint.h:37,
                 from /usr/lib/gcc/x86_64-redhat-linux/11/include/stdint.h:9,
                 from /usr/include/tiffconf-64.h:13,
                 from /usr/include/tiffconf.h:9,
                 from /usr/include/tiff.h:28,
                 from common.h:5,
                 from common.c:1:
/usr/include/bits/stdint-uintn.h:27:20: note: previous declaration of 'uint64_t' with type 'uint64_t' {aka 'long unsigned int'}
   27 | typedef __uint64_t uint64_t;
      |                    ^~~~~~~~
make: *** [/usr/lib64/R/etc/Makeconf:168: common.o] Error 1
ERROR: compilation failed for package 'ijtiff'

See the complete log here

Installing from source on Windows 10 64-bit fails

Hi! I wanted to reuse the src/makefile.win and tools/winlibs.R in my package, but ran into a problem testing ijtiff itself.

install.packages("ijtiff", type = "source")

Using that command in Windows 10 64-bit, installation of ijtiff fails with missing file errors, like tiffio.h (i can post a full error log if it'd help).

Is this expected? The binary version installs perfectly fine.

Thanks!

Repo topics

👋 again!

I've added a few repo topics see below

image

Feel free to edit ("r" and "rstats" might seem useless but popular R package repos actually use them so I've added them to all ropensci packages)!

Ubuntu installation error

I have some problems to install the last version of ijtiff package in ubuntu 22.04.1 version (R 4.2.2). I get the same error both in R in terminal or in Rstudio: /usr/bin/ld: cannot find -lwebp: No such file or directory
I don't find any help in internet about this error.

sudo apt-get install libtiff5-dev

in terminal. No problem during installation.

Then in R:
install.packages("ijtiff")

Installation du package dans ‘/usr/local/lib/R/site-library’
(car ‘lib’ n'est pas spécifié)
essai de l'URL 'https://cloud.r-project.org/src/contrib/ijtiff_2.2.9.tar.gz'
Content type 'application/x-gzip' length 2433782 bytes (2.3 MB)

downloaded 2.3 MB

  • installing source package ‘ijtiff’ ...
    ** package ‘ijtiff’ correctement décompressé et sommes MD5 vérifiées
    ** using staged installation
    ** preparing to configure package 'ijtiff' ...
    Found pkg-config!
    Found pkg-config cflags and/or libs for libtiff!
    Using PKG_CFLAGS=-I/usr/include/x86_64-linux-gnu
    Using PKG_LIBS=-ltiff -lwebp -lzstd -llzma -ljpeg -ldeflate -lz -lm
    ** finished configure for package 'ijtiff'
    ** libs
    gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -fpic -g -O2 -ffile-prefix-map=/build/r-base-anRV6o/r-base-4.2.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c common.c -o common.o
    gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -fpic -g -O2 -ffile-prefix-map=/build/r-base-anRV6o/r-base-4.2.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c init.c -o init.o
    gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -fpic -g -O2 -ffile-prefix-map=/build/r-base-anRV6o/r-base-4.2.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c read.c -o read.o
    gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -fpic -g -O2 -ffile-prefix-map=/build/r-base-anRV6o/r-base-4.2.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c utils.c -o utils.o
    gcc -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -fpic -g -O2 -ffile-prefix-map=/build/r-base-anRV6o/r-base-4.2.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c write.c -o write.o
    gcc -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro -o ijtiff.so common.o init.o read.o utils.o write.o -ltiff -lwebp -lzstd -llzma -ljpeg -ldeflate -lz -lm -L/usr/lib/R/lib -lR
    /usr/bin/ld: cannot find -lwebp: No such file or directory
    collect2: error: ld returned 1 exit status
    make: *** [/usr/share/R/share/make/shlib.mk:10: ijtiff.so] Error 1
    ERROR: compilation failed for package ‘ijtiff’
  • removing ‘/usr/local/lib/R/site-library/ijtiff’
  • restoring previous ‘/usr/local/lib/R/site-library/ijtiff’

Les packages source téléchargés sont dans
‘/tmp/RtmpMuUequ/downloaded_packages’
Message d'avis :
Dans install.packages("ijtiff") :
l'installation du package ‘ijtiff’ a eu un statut de sortie non nul

#############
Same output with
devtools::install_github("ropensci/ijtiff")

#################

R.version
_
platform x86_64-pc-linux-gnu
arch x86_64
os linux-gnu
system x86_64, linux-gnu
status
major 4
minor 2.2
year 2022
month 10
day 31
svn rev 83211
language R
version.string R version 4.2.2 (2022-10-31)
nickname Innocent and Trusting

############
Ubuntu 22.04.1
############

sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.1 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0

locale:
[1] LC_CTYPE=fr_FR.UTF-8 LC_NUMERIC=C
[3] LC_TIME=fr_FR.UTF-8 LC_COLLATE=fr_FR.UTF-8
[5] LC_MONETARY=fr_FR.UTF-8 LC_MESSAGES=fr_FR.UTF-8
[7] LC_PAPER=fr_FR.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached):
[1] Rcpp_1.0.9 compiler_4.2.2 later_1.3.0 urlchecker_1.0.1
[5] prettyunits_1.1.1 profvis_0.3.7 remotes_2.4.2 tools_4.2.2
[9] digest_0.6.30 pkgbuild_1.3.1 pkgload_1.3.1 memoise_2.0.1
[13] lifecycle_1.0.3 rlang_1.0.6 shiny_1.7.3 cli_3.4.1
[17] curl_4.3.3 fastmap_1.1.0 withr_2.5.0 stringr_1.4.1
[21] fs_1.5.2 htmlwidgets_1.5.4 devtools_2.4.5 rprojroot_2.0.3
[25] glue_1.6.2 R6_2.5.1 processx_3.8.0 sessioninfo_1.2.2
[29] callr_3.7.3 purrr_0.3.5 magrittr_2.0.3 ps_1.7.2
[33] promises_1.2.0.1 ellipsis_0.3.2 htmltools_0.5.3 usethis_2.1.6
[37] mime_0.12 xtable_1.8-4 httpuv_1.6.6 stringi_1.7.8
[41] miniUI_0.1.1.1 cachem_1.0.6 crayon_1.5.2

SystemRequirements best practice

👋 @rorynolan!

As part of the consolidation of our guidance for package developers I've added a paragraph about system dependencies to https://ropensci.github.io/dev_guide/building.html#package-dependencies I see your package depends on libtiff.

Could you:

Please ask me any question you might have! This part of the guide is brand-new, and sysreqsdb README was just updated, so they can certainly be improved. Thank you!

Failing to install on redhat 7

Hi,

This package is failing for me when installing on Redhat 7.5.

First attempt at installing told us to install libtiff-devel. See below.

install.packages("/data/software/r_packages/ijtiff_1.5.1.tar.gz", lib="/usr/lib64/R/library")
inferring 'repos = NULL' from 'pkgs'
* installing *source* package ‘ijtiff’ ...
** package ‘ijtiff’ successfully unpacked and MD5 sums checked
** using staged installation
Package libtiff-4 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libtiff-4.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libtiff-4' found
Using PKG_CFLAGS=
Using PKG_LIBS=-ltiff -ljpeg -lz
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libtiff-4 was not found. Try installing:
 * deb: libtiff-dev (Debian, Ubuntu, etc)
 * rpm: libtiff-devel (Fedora, EPEL)
 * brew: libtiff (OSX)
If libtiff-4 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libtiff-4.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
ERROR: configuration failed for package ‘ijtiff’
* removing ‘/usr/lib64/R/library/ijtiff’
Warning message:
In install.packages("/data/software/r_packages/ijtiff_1.5.1.tar.gz",  :

Installed that fine and now getting the following error.

install.packages("/data/software/r_packages/ijtiff_1.5.1.tar.gz", lib="/usr/lib64/R/library")
inferring 'repos = NULL' from 'pkgs'
* installing *source* package ‘ijtiff’ ...
** package ‘ijtiff’ successfully unpacked and MD5 sums checked
** using staged installation
Found pkg-config cflags and libs!
Using PKG_CFLAGS=
Using PKG_LIBS=-ltiff -ljbig -ljpeg -lz
** libs
g++ -m64 -std=gnu++11 -I"/usr/include/R" -DNDEBUG  -I"/usr/lib64/R/library/Rcpp/include" -I/usr/local/include  -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c RcppExports.cpp -o RcppExports.o
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG  -I"/usr/lib64/R/library/Rcpp/include" -I/usr/local/include  -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c common.c -o common.o
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG  -I"/usr/lib64/R/library/Rcpp/include" -I/usr/local/include  -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c read.c -o read.o
g++ -m64 -std=gnu++11 -I"/usr/include/R" -DNDEBUG  -I"/usr/lib64/R/library/Rcpp/include" -I/usr/local/include  -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c utils.cpp -o utils.o
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG  -I"/usr/lib64/R/library/Rcpp/include" -I/usr/local/include  -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c write.c -o write.o
g++ -m64 -std=gnu++11 -shared -L/usr/lib64/R/lib -Wl,-z,relro -o ijtiff.so RcppExports.o common.o read.o utils.o write.o -ltiff -ljbig -ljpeg -lz -L/usr/lib64/R/lib -lR
/usr/bin/ld: cannot find -ljbig
collect2: error: ld returned 1 exit status
make: *** [ijtiff.so] Error 1
ERROR: compilation failed for package ‘ijtiff’
* removing ‘/usr/lib64/R/library/ijtiff’
Warning message:
In install.packages("/data/software/r_packages/ijtiff_1.5.1.tar.gz",  :

The installation page says to install libtiff5-dev but not sure that package exists on Fedora/Redhat? Can only see libtiff-devel unless that is the same.

On Fedora Linux, try sudo yum install libtiff5-dev, or if that doesn’t work, try
sudo yum install libtiff4-dev.

Any advice on installing would be appreciated.

Thanks

Test failure with dev waldo

ljtiff tests fails with dev waldo because it now (correctly) distinguishes between NaN and NA:

── Failure ('test-io.R:124:3'): Float (real-numbered) TIFF I/O works ───────────
as.vector(in_tif) (`actual`) not equal to as.vector(a2345) (`expected`).

  `actual[6:12]`: 42 86 94 NaN 20 4 38
`expected[6:12]`: 42 86 94  NA 20 4 38

I couldn't get your package to compile so I couldn't do a PR myself, but the fix should be straightforward.

problems with exporting 4-channel images and dropping them into imagej/fiji

Hello, i am having an issue with a particular set of images.

I constructed an array with 4 dimensions, holding 60x60 images, with 49 frames and 4 channels.

> dim(tiff.arrays[[1]])
[1] 60 60  4 49

When converting it to ijtiff i get:

> pic <- ijtiff::as_ijtiff_img(tiff.arrays[[1]])
> pic
60x60 pixel ijtiff_img with 4 channels and 49 frames.
Preview (top left of first channel of first frame):
     [,1] [,2] [,3] [,4] [,5] [,6]
[1,] 6487 6300 6429 6260 6335 6209
[2,] 6232 6405 6502 6419 6427 6464
[3,] 6403 6326 6405 6398 6430 6463
[4,] 6391 6211 6385 6349 6300 6495
[5,] 6376 6298 6468 6267 6531 6413
[6,] 6451 6352 6179 6381 6320 6324
── TIFF tags ──────────
>

The image was made from an array so there are no tags. Is this a problem?

I guessed that so far so good, so i save the tiff to a file:

  ijtiff::write_tif(pic, path = paste0("trabajo_final/imagenes/",i, ".tif"), 
                    overwrite = T, msg = F, bits_per_sample = 16)

Then i dragged and dropped it into imagej and got an weirdness:

image

  • A "EOF" Java exception message from imagej/fiji: java.io.EOFException
  • 3 channels instead of four
  • 39 frames instead of 49 frames
  • And this:

weird

The bioformats plugin, however, reads them just fine:

image

If I choose to export only three channels out of the 4 channels i have, there is no problem:

 pic <- ijtiff::as_ijtiff_img(tiff.arrays[[1]][,,1:3,])
 ijtiff::write_tif(pic, path = paste0("trabajo_final/imagenes/",i, ".tif"), 
                   overwrite = T, msg = F, bits_per_sample = 16)

weird2

I guess something is not right around RGB having 3 channels and my image having 4. Also that the number of frames is close to 3/4 of the original.

Do you know what might be going on?

Thanks!

Read only some frames of an image

Sometimes you don't need all of the images. Then, it would be nice to be able to select to read just the ones you want (for the sake of speed).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.