Wrong rect of Document when open "bmp" of "png" files by fitz.open() #1969
-
Please provide all mandatory information! Describe the bug (mandatory)Open bmp or png files (maybe also other kind of pictures) by fitz.open(file_adress) will return a Document with wrong rect. Which is small than what it should be with a ratio of 0.75. To Reproduce (mandatory)import fitz you may see the x_zoom == y_zoom == (768/1024) == (576/768) == 0.75And it does not relate to the size of the picture. No matter what picture, the zoom is always 0.75Your configuration (mandatory)
For example, the output of Additional context (optional)Add any other context about the problem here. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 5 replies
-
This is no bug, but a misconception about how page sizes of Images are computed when opened as a document. |
Beta Was this translation helpful? Give feedback.
-
I will transfer the issue to a |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Sorry, I was not in front of the screen. that is helpful. So actually it’s happened because the default DPI has been set to 96x96?
It is kind of tricky cause when I try to transfer the pdf document to png and do manipulation and transfer them back, I realized the whole document become smaller than before.
获取 Outlook for iOS<https://aka.ms/o0ukef>
…________________________________
发件人: Jorj X. McKie ***@***.***>
发送时间: Sunday, October 16, 2022 5:30:22 PM
收件人: pymupdf/PyMuPDF ***@***.***>
抄送: Jianpeng-teng ***@***.***>; Author ***@***.***>
主题: Re: [pymupdf/PyMuPDF] Wrong rect of Document when open "bmp" of "png" files by fitz.open() (Discussion #1969)
Thanks for asking ... this may be confusing, but has a simple explanation.
For example take this image:
Its dimension is 607 x 741 pixels, its DPI is 120 x 120.
[grafik]<https://user-images.githubusercontent.com/8290722/196023365-265ef192-955a-44b8-838c-ef7dcc688b2f.png>
When opened as a document, the corresponding page size is:
page.rect
Rect(0.0, 0.0, 364.20001220703125, 444.6000061035156)
The computation works as follows, taking rect.width as an example:
(img width in pixels) / (x-dpi) * (points per inch) = page.rect.width
607 / 120 * 72 = 364.2
Or conversely:
page.rect.width * 120 / 72
607.0000203450521
# the original image x-pixels
―
Reply to this email directly, view it on GitHub<#1969 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AOLKXQKDA2YEP65USMY6XNLWDOVI5ANCNFSM6AAAAAARGHTEWM>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Okay, so all you want is making the visible part of some page smaller? If this is true, then using pixmaps and images simply is the wrong idea! All you need to do is adjusting its CropBox via |
Beta Was this translation helpful? Give feedback.
Thanks for asking ... this may be confusing, but has a simple explanation.
For example take this image:
Its dimension is 607 x 741 pixels, its DPI is 120 x 120.
When opened as a document, the corresponding page size is:
The computation works as follows, taking
rect.width
as an example:Or conversely: