plumber - png serializer - modify an image

Hello,

i have the following problem.

I have data (daten). I calculate via the sixsigma package a result. The result (

img <- process.capability(q1, spec.limits=c(UGW,OGW))

) makes a plot.

If i make an api call with "post" with this img row everything is working fine.

If i want to manipulate the plot via saving the file and then manipulate the file via the magick package, i will always get the message

"The device output file is missing. Did you produce an image?"

It seems to me, that i cannot return a specific image file via plumber, Is this correct or how could i avoid this behaviour?

Thanks for your help

#* Example of customizing graphical output
#* @serializer png list(width = 400, height = 500)
#* @param a daten for calculation
#* @parser json
#* @post /png_hans_json
function(req, a){
  
  daten <- c("16","23","20","21","21.5","19","19","20.4","18.3","19.9","18.7","18","17.7","19.1","19.7","18.1","18.4","17.5","18.9")  
  
  #daten <- unlist(a)
  
  laengedaten <- length(daten)
  werte<-as.numeric(daten)
  werte<- na.omit(werte)
  
  UGW<-werte[1]
  OGW<-werte[2]
  
  werte <- werte[3:laengedaten]
  q1= qcc(werte, type = "xbar", std.dev = sd(werte), plot=TRUE)
  
  #png(tempfile())
  img <- process.capability(q1, spec.limits=c(UGW,OGW))
  #dev.off()
  
  #The device output file is missing. Did you produce an image
  
}

When you use an image serializer, the output capture is started before entering the endpoint and stopped after exiting the endpoint. So, it is true that the device output does not exist yet.

You might want to use a different serializer like content-type to create and manipulate the png in the endpoint execution.

Thanks for the explanation.
Could you give me an advice or a short code how to do that?

Keep reading until Error Handling section.

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.