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

Resolution rounding #444

Closed
andrey-hider opened this issue Dec 2, 2019 · 2 comments
Closed

Resolution rounding #444

andrey-hider opened this issue Dec 2, 2019 · 2 comments
Assignees
Labels
bug
Milestone

Comments

@andrey-hider
Copy link

@andrey-hider andrey-hider commented Dec 2, 2019

Is there any possibility to open image with selected units parameter?
Or, at least, return resolution value without rounding?

I tried to open image with selected units parameter:

from wand.image import Image as Wand_Image
f = open('path_to_image/Test_adobe.png', 'rb')
image = Wand_Image(blob=f, units='pixelsperinch')

But as a result, resolution didn't changed and units became 'pixelsperinch':

print(image.resolution)  # returns (28, 28)
print(image.units)  # returns 'pixelsperinch'

From Photoshop dpi is exactly 72 (or 28,346 in Pixel/Centimiter)
Screenshot 2019-12-02 at 13 06 16
Screenshot 2019-12-02 at 13 06 04

On other hand, I couldn't use convert formula from Centimiters to Inches because in resolution() function there is rounding of value - in my example it's 2.54 * 28 = 71.12 - far away from expected 72 dpi (link to commit Wand resolution ):

def resolution(self):
    """(:class:`tuple`) Resolution of this image.

    .. versionadded:: 0.3.0

    """
    x = ctypes.c_double()
    y = ctypes.c_double()
    r = library.MagickGetImageResolution(self.wand, x, y)
    if not r:  # pragma: no cover
        self.raise_exception()
    return int(x.value), int(y.value)

Example of test image:
Test_adobe.png.zip

Shell ImageMagick command 'identify -verbose path_to_image/Test_adobe.png' returns:
Resolution: 28.35x28.35

Thank you!

@emcconville

This comment has been minimized.

Copy link
Owner

@emcconville emcconville commented Dec 3, 2019

Thanks for sharing this. I'll take a look.

@emcconville emcconville self-assigned this Dec 3, 2019
@emcconville emcconville added the bug label Dec 3, 2019
@emcconville emcconville added this to the Wand 0.5.8 milestone Dec 3, 2019
@emcconville

This comment has been minimized.

Copy link
Owner

@emcconville emcconville commented Dec 3, 2019

Fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.