I need to convert uploaded PDF to images.
I'm using pdf2image function convert_from_path() to convert the image but am getting an error Unable to get page count.
My code looks somewhat like this:
pages = convert_from_path(request.FILES['file'].read())
And the error:
UnboundLocalError at /
local variable ‘err’ referenced before assignment
489. "Unable to get page count.\n%s" % err.decode("utf8", "ignore" )
Local vars
Variable Value
command ['pdfinfo', b'S$PDF-1.4\r%\xe2\xe3\xcf\xd3\r\n8 0 obj\r<</Linearized 1/L 2454824/0 10/E 120' b'5294/N 2/T 2454545/H [ 436 148]>>\rendobj\r \r\nxref\r\n8 7\r\n0' b'000000016 00000 n\r\n0000000584 00000 n\r\n0000000644 00000 n\r\n000000078' b'9 00000 n\r\n0000000854 00000 n\r\n0000000970 00000 n\r\n0000000436 00000 ' b' n\r\ntrailer\r\n<</Size 15/Root 9 0 R/Info 7 0 R/ID[<D4E1141A6A6CEAOFDD796E7 ' le QM NAAR A AA Ae -—A NAA Mme A SFr A Frese AR MM ARPMAAMTNA FA FHA ABTA A 4A ew 2a im manmrmarare = A or !
Is there a better way to do this?