slickR icon indicating copy to clipboard operation
slickR copied to clipboard

problems with SVG images

Open dan-reznik opened this issue 6 years ago • 7 comments

I am trying to create a simple caroussel with slickR and a few SVG images but I get this error after the call to slickR::slickR(...)

Error in checkStandalone(fL) : SVG not standalone

The thing is my SVG is perfectly "standalone". Indeed, its first few lines are:

<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="801pt" height="552pt" viewBox="0 0 801 552" version="1.1">
<defs>
<g>
<symbol overflow="visible" id="glyph0-0">
<path style="stroke:none;" d="M 1.25 0 L 1.25 -15.996094 L 8.75 -15.996094 L 8.75 0 Z M 2.5 -1.25 L 7.5 -1.25 L 7.5 -14.746094 L 2.5 -14.746094 Z "/>
</symbol>

Checkin on your code under readImage.R, the above error seems to be produced by a line which attempts to locate the string "xmlns" on the first line of the SVG. notice above this is found on the SECOND LINE. Should this function be relaxed to find "xmlns" on any few first lines of the .svg?

checkStandalone <- function(x){
  if(!grepl("xmlns", readLines(x, n = 1))){
    stop('SVG not standalone')
  }else{
    TRUE
  } 
}

dan-reznik avatar Feb 27 '20 14:02 dan-reznik

you are welcome to PR an update. I do not know if i will get to a patch today

yonicd avatar Feb 27 '20 16:02 yonicd

Can you please attach an example of a svg you are using so I can test on it?

Thanks

yonicd avatar Feb 28 '20 11:02 yonicd

Try this patch. https://github.com/metrumresearchgroup/slickR/commit/43a6a4e75e30e7b9b6a61993ae789410e1b89475

yonicd avatar Feb 28 '20 11:02 yonicd

I tried it but GitHub didn't let me. Here it is in this email

On Fri, Feb 28, 2020 at 8:17 AM yonicd [email protected] wrote:

Can you please attach an example of a svg you are using so I can test on it?

Thanks

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/metrumresearchgroup/slickR/issues/39?email_source=notifications&email_token=AD32VFSZPRA4UZITPYU5FJTRFDXFNA5CNFSM4K44XRRKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENIF3WQ#issuecomment-592469466, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD32VFR7TLIICQZ5OMRKMU3RFDXFNANCNFSM4K44XRRA .

dan-reznik avatar Feb 28 '20 11:02 dan-reznik

I didn't get an email.

can you cat(readLines(PATH_TO_FILE)) and paste in the output

thanks

yonicd avatar Feb 28 '20 14:02 yonicd

you can use this commit (https://github.com/metrumresearchgroup/slickR/commit/e8d3e0e7d2278eebe56ff528e5b6204d6d957da5) to test your file. it solves the problem a different way that is more robust

remotes::install_github('metrumresearchgroup/slickR@e8d3e0e')

ht @dmi3kno

yonicd avatar Feb 28 '20 14:02 yonicd

Hi. I'm having this problem, and the commit you referenced fixes it.

Can this be added into the master branch?

dcaud avatar Dec 03 '21 17:12 dcaud