Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TIFF files with “packbits compression” cannot be converted to PDF files #2320

Closed
leo20160311 opened this issue Apr 4, 2023 · 18 comments
Closed

Comments

@leo20160311
Copy link

leo20160311 commented Apr 4, 2023

mydoc = fitz.open(stream=tiff_bytes, filetype=‘tif’)

mydoc = mydoc.convert_to_pdf()
mydoc = fitz.open('pdf', mydoc)

outdoc = fitz.open()
outdoc.insert_pdf(mydoc)
outdoc.save(outpdfpath)

Can someone help ? generated file content is incorrect

@JorjMcKie
Copy link
Collaborator

Please provide a file to reproduce.

@JorjMcKie
Copy link
Collaborator

If you can open the TIFF as a Pixmap, you can still insert it as an image in a PDF page of suitable size:

tif = "file.tif"
pix = fitz.Pixmap(tif)
doc=fitz.open()
page=doc.new_page(width=pix.width, height=pix.height)
page.insert_image(page.rect, filename=tif)
doc.save("file.pdf",deflate=True)

@leo20160311
Copy link
Author

@JorjMcKie Thank you!

I tested more than ten TIFF files, but none of them could be converted to the correct PDF. The content of the converted PDF file is black.

Additionally, I am unable to upload files on Github and have already uploaded them to Gitee:
https://gitee.com/liudg2012/tiff.git

@leo20160311
Copy link
Author

@JorjMcKie Thank You!
Additionally, in practical use, my TIFF file is multi page and using pixmap is not very convenient

@JorjMcKie
Copy link
Collaborator

Additionally, I am unable to upload files on Github and have already uploaded them to Gitee

Sorry cannot find any graphic file there. Please use a conventional ZIP of at least one TIFF.
BTW: if the error can be confirmed, it will be a MUPDF problem ... but anyway, we need an example.

@JorjMcKie
Copy link
Collaborator

Reminder: this issue cannot be processed if you don't provide an example TIFF.

@leo20160311
Copy link
Author

i found your email address:[jorj.x.mckie@outlook.de],and I am now sending it to you via email. Thank you
Look forward to your reply

@JorjMcKie
Copy link
Collaborator

Thanks for submitting the image. It is a very small image. I was able to convert it to PDF. The result is not black but looks like so:
grafik
Don't know if this is correct or not ...

@leo20160311
Copy link
Author

I'm very sorry, I provided you with an incorrect example
Yes, you are right. After zooming in on this TIFF file, I found that it matches the converted PDF file. I thought it was the same as what I tested on a virtual computer, but now it's not a pure black block.

I finally found the appropriate TIFF file and sent you a new email containing the TIFF file and my test results. Please help, thank you very much

@JorjMcKie
Copy link
Collaborator

Thanks for the new files. I tested them with the new PyMuPDF version coming out soon.
Good news: only one of the example files has problems (convered to black): gray.packbits.u2.tif, all the others work correctly.

@leo20160311
Copy link
Author

Thanks for the new files. I tested them with the new PyMuPDF version coming out soon. Good news: only one of the example files has problems (convered to black): gray.packbits.u2.tif, all the others work correctly.

Thank you very much for your patient response. I am looking forward to the final result

@leo20160311
Copy link
Author

@JorjMcKie @radarher
Wow, is Radarrhere and JorjMcKie on the same team? First of all, thank you to the two enthusiastic technical experts

python-pillow/Pillow#7084
This issue was also submitted by me. I tried some wrapping solutions, but I couldn't solve any problems, haha
My focus is: I have a bunch of images and documents in various formats, and I need to merge them into one PDF I haven't been able to achieve it yet, I need help, thank you very much

@leo20160311
Copy link
Author

leo20160311 commented Apr 13, 2023 via email

@leo20160311
Copy link
Author

Thanks for the new files. I tested them with the new PyMuPDF version coming out soon. Good news: only one of the example files has problems (convered to black): gray.packbits.u2.tif, all the others work correctly.

I just checked this file<gray.packbits.u2.tif> and realized that the content itself is black. Could it be that I misled you? However, it may be necessary to note that this file has two pages, both of which are black

@JorjMcKie
Copy link
Collaborator

According to our e-mail conversation, this issue can be closed with the new version, right?

@leo20160311
Copy link
Author

I would like to test it with the new version so that it can be confirmed, thanks

@JorjMcKie
Copy link
Collaborator

I would like to test it with the new version so that it can be confirmed, thanks

Ok, sure. Then please install the new version, test it and let us know your findings.
Thank you!

@leo20160311
Copy link
Author

Thank you very much for your reply. You have completely resolved my issue through version 1.22.0. Thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants