0

While using the img2pdf library I'm getting the above mentioned error, my code looks something like this, this is also the line of code that throws the above mentioned error

pdf = img2pdf.convert('maskedImage'+ filename + '.jpeg')

where filename is a string taken in from the user as form of a url while using flask.

And this is how masked image is being saved using opencv

cv2.imwrite("maskedImage" + filename + ".jpeg", maskedImage)
HansHirse
  • 18,010
  • 10
  • 38
  • 67
Nimish
  • 11
  • 4

1 Answers1

0

Actually you have to convert it to bytes. You can do it like this.

bytes = string.encode(encoding='UTF-8')

Also you can check it out the link for more information about that.

  • But that wont work as img2pdf requires an image path, But one can only enter image paths as string, so thats where I'm heavily confused as to why img2pdf keeps throwing this error. – Nimish Apr 10 '21 at 08:58