{"action":"created","issue":{"url":"https://api.github.com/repos/rk700/PyMuPDF/issues/192","repository_url":"https://api.github.com/repos/rk700/PyMuPDF","labels_url":"https://api.github.com/repos/rk700/PyMuPDF/issues/192/labels{/name}","comments_url":"https://api.github.com/repos/rk700/PyMuPDF/issues/192/comments","events_url":"https://api.github.com/repos/rk700/PyMuPDF/issues/192/events","html_url":"https://github.com/rk700/PyMuPDF/issues/192","id":346348111,"node_id":"MDU6SXNzdWUzNDYzNDgxMTE=","number":192,"title":"Cant extract image from pdf","user":{"login":"manish59","id":15991796,"node_id":"MDQ6VXNlcjE1OTkxNzk2","avatar_url":"https://avatars0.githubusercontent.com/u/15991796?v=4","gravatar_id":"","url":"https://api.github.com/users/manish59","html_url":"https://github.com/manish59","followers_url":"https://api.github.com/users/manish59/followers","following_url":"https://api.github.com/users/manish59/following{/other_user}","gists_url":"https://api.github.com/users/manish59/gists{/gist_id}","starred_url":"https://api.github.com/users/manish59/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manish59/subscriptions","organizations_url":"https://api.github.com/users/manish59/orgs","repos_url":"https://api.github.com/users/manish59/repos","events_url":"https://api.github.com/users/manish59/events{/privacy}","received_events_url":"https://api.github.com/users/manish59/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-07-31T20:35:35Z","updated_at":"2018-08-02T18:38:20Z","closed_at":null,"author_association":"NONE","body":"doc = fitz.open(\"file.pdf\")\r\nfor i in range(len(doc)):\r\n    for img in doc.getPageImageList(i):\r\n        xref = img[0]\r\n        pix = fitz.Pixmap(doc, xref)\r\n        if pix.n < 5:       # this is GRAY or RGB\r\n            pix.writePNG(\"p%s-%s.png\" % (i, xref))\r\n        else:               # CMYK: convert to RGB first\r\n            pix1 = fitz.Pixmap(fitz.csRGB, pix)\r\n            pix1.writePNG(\"p%s-%s.png\" % (i, xref))\r\n            pix1 = None\r\n        pix = None\r\nI used this code to extract images from the pdf. I was sucessful for some pdfs but I was not able to do it for some pdfs. I was getting errors like\r\n'NoneType' object has no attribute 'n'\r\nDeviceCMYK not supported for png. Please let me know how to fix this and extract images from the pdf"},"comment":{"url":"https://api.github.com/repos/rk700/PyMuPDF/issues/comments/410026793","html_url":"https://github.com/rk700/PyMuPDF/issues/192#issuecomment-410026793","issue_url":"https://api.github.com/repos/rk700/PyMuPDF/issues/192","id":410026793,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMDAyNjc5Mw==","user":{"login":"manish59","id":15991796,"node_id":"MDQ6VXNlcjE1OTkxNzk2","avatar_url":"https://avatars0.githubusercontent.com/u/15991796?v=4","gravatar_id":"","url":"https://api.github.com/users/manish59","html_url":"https://github.com/manish59","followers_url":"https://api.github.com/users/manish59/followers","following_url":"https://api.github.com/users/manish59/following{/other_user}","gists_url":"https://api.github.com/users/manish59/gists{/gist_id}","starred_url":"https://api.github.com/users/manish59/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manish59/subscriptions","organizations_url":"https://api.github.com/users/manish59/orgs","repos_url":"https://api.github.com/users/manish59/repos","events_url":"https://api.github.com/users/manish59/events{/privacy}","received_events_url":"https://api.github.com/users/manish59/received_events","type":"User","site_admin":false},"created_at":"2018-08-02T18:38:20Z","updated_at":"2018-08-02T18:38:20Z","author_association":"NONE","body":"Im sorry if I didnt explained correctly. For example I have a scanned pdf which contains 4 images as 4 pages. When I extract the images the extracted images orientation is distorted. I dont know why. I try but I dont know. Can you help me to identity the rotation of the page not the pdf."}}
{"actor":{"display_login":"manish59"}}