ropensci / magick

Magic, madness, heaven, sin
https://docs.ropensci.org/magick
Other
462 stars 65 forks source link

Error in magick_image_readpath #287

Open kahlsr opened 4 years ago

kahlsr commented 4 years ago

Hello, any idea how to work around this issue? I'm trying out magick package with tesseract in R but I can't seem to make it work due to this error.

Code: `library(magick) img <- image_read(file.choose())

Output image

img

OCR

ocr_text <- image_ocr(img, language = "eng") cat(ocr_text)`

image

jeroen commented 4 years ago

If you want to read pdf files you have to install ghostscript, or alternatively, use image_read_pdf() which is based on the R package pdftools.

kahlsr commented 4 years ago

Hello, thanks for the advice. However, this error appears even when just trying to read .jpeg files.

jeroen commented 4 years ago

I doubt that. Does your file have a proper file extension? Can you just pass a jpg path to image_read() directly, instead of file.choose()

jeroen commented 4 years ago

Can you please try to make a complete reproducible example including an example image for me to test the problem?

yvonnearandela commented 4 years ago

Hi, I also experienced the same error. It worked when I tried using image_read_pdf() and image_read_svg() for pdf and svg files, but when reading postscript files, the same error appears. Are postscript files readable in magick package?

jeroen commented 4 years ago

Reading postscript files requires ghostscript installed on your system.

yvonnearandela commented 4 years ago

I already installed ghostscript version 9.53.3, but same error still appears.

jeroen commented 4 years ago

Are you using the latest version of magick? Can you show your sessionInfo() please?

yvonnearandela commented 4 years ago

Yes, I'm using magick version 2.5.2

sessionInfo() R version 4.0.3 (2020-10-10) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19041)

Matrix products: default

locale: [1] LC_COLLATE=English_Philippines.1252 LC_CTYPE=English_Philippines.1252 LC_MONETARY=English_Philippines.1252 [4] LC_NUMERIC=C LC_TIME=English_Philippines.1252

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

other attached packages: [1] magick_2.5.2

loaded via a namespace (and not attached): [1] compiler_4.0.3 magrittr_1.5 tools_4.0.3 curl_4.3 Rcpp_1.0.5 tinytex_0.27 xfun_0.19

jeroen commented 4 years ago

And do you have ghostscript installed? What do you see for:

Sys.which("gs")
system("gs --version")
yvonnearandela commented 4 years ago

I already installed ghostscript on the system and here's the output for the code:

Sys.which("gs") gs "" system("gs --version") [1] 127