Hello,
I am trying to convert a pdf file created in R with multiple slides into one png file per slide. Of course, there are several packages providing functions for this. Unfortunately, the two I tried out (animation and TraMineRextras, both seem to rely on the magick package) do not work for me and I can´t figure out why.
Here is what I did:
library("magick")
library("animation")
library("TraMineRextras")#generate random x and y data from 1 to 100 to plot
set.seed(10)
x = runif(100,0,10)
y = runif(100,0,10)
m1 = lm(y ~ x)plot pdf
pdf('PLOT.pdf', width = 28, height = 18 ) #start png plotting device with graphical parameters
par(xpd = F, #ablines are underneath boxplot
mar = par()$mar + c(10,12,7,7), #margins
mgp = c(3,4,0)) #what does this?
par(mfrow=c(1,1)) #plots x rows and y columns of images into pdfplot(m1, lwd = 10) plot the data
box(lwd = 7) plot box around curvedev.off() #close plot device
im.convert('PLOT.pdf', output = "PLOT.png", extra.opts="-density 150")
convert.g(path = 'PLOT.pdf', fileroot= "*", from = "pdf",
to = "png", create.path = F, options = NULL)
Doing this, the PLOT.png is successfully put out in the working directory and consists of 4 slides. Now I want to get 4 pngs out of this. When executing the im.convert() function, the following error pops up:
Fehler in magick_image_readpath(path, density, depth, strip, defines) :
rsession.exe: FailedToExecuteCommand `"gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" "-sOutputFile=C:/Users/EIKE~1.KEE/AppData/Local/Temp/Rtmpyu1Spz/magick-muhTYmA_JJ-YaMaYF2Etrlb3r12mF6XD%d" "-fC:/Users/EIKE~1.KEE/AppData/Local/Temp/Rtmpyu1Spz/magick-lAZdNTCgb1AMcrQkMYLlfsmrojbxyRSK" "-fC:/Users/EIKE~1.KEE/AppData/Local/Temp/Rtmpyu1Spz/magick-DQ1QgPuB3gMHChgbzKLdb4p4gU6sYapP"' (Das System kann die angegebene Datei nicht finden. ) @ error/delegate.c/ExternalDelegateCommand/457
Aka “the system was not able to find the stated file”. I made sure that the png file exists within the working directory and tried to use the full file directory as the path Argumemnt.. When executing the convert.g function from the TraMineRextras package, I get the following error message:
Fehler in setwd(path) : kann Arbeitsverzeichnis nicht wechseln
Aka „was not able to change working directory”. Is it possible that these error are linked to a “ß” in my user directory? Even though I intentionally set the working directory to "C:/Test", to avoid this being an issue.
So, does anyone have a idea why I get these error messages? What am I not seeing here?
Thanks, br,
Eike