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

wand.image.Image.export_pixel() width, height = right, top #413

Closed
CoffeeKing68 opened this issue May 20, 2019 · 4 comments
Closed

wand.image.Image.export_pixel() width, height = right, top #413

CoffeeKing68 opened this issue May 20, 2019 · 4 comments
Assignees
Labels
Milestone

Comments

@CoffeeKing68
Copy link

Hi
Wand 0.5.4
In wand.image.Image.export_pixel(), the width and height variables are treated like they are right and top variables respectively.
This the calculation for the rectangle to export in image.py export_pixels()@3651

total_pixels = (width - x) * (height - y)

Here is some code to test this claim and comments above each line are the errors I got:
from wand.image import Image
from wand.color import Color

with Image(width=50, height=50, background=Color("Green")) as image:
    x = 10
    y = 10
    width = 20
    height = 10

    # [1]    86502 segmentation fault
    # export = image.export_pixels(x=x, y=y, width=width, height=height)

    # No issue here
    # export = image.export_pixels(x=x, y=y, width=width + x, height=height + y)

    """
    python3(86545,0x7fff6b0635c0) malloc: Incorrect checksum for freed object 0x10401ea00: probably modified after being freed.
    Corrupt value: 0xff008000ff008000
    python3(86545,0x7fff6b0635c0) malloc: *** set a breakpoint in malloc_error_break to debug
    [1]    86545 abort      python3 testing/wand_test.py
    """
    # export = image.export_pixels(x=10, y=10, width=30, height=30)
    # export = image.export_pixels(x=5, y=5, width=20, height=50)
    """
    I can't remember how I got this one
    Assertion failed: (image->cache != (Cache) NULL), function DestroyImagePixels, file MagickCore/cache.c, line 907.
    [1]    86171 abort      python3 testing/wand_test.py
    """
@emcconville
Copy link
Owner

Great work!

I'll have this resolved & create some additional unit tests to cover this. Probably in the next few hours.

I can't remember how I got this one

No worries - just post a new Issue if you recreate it. Pretty sure the last one is an expected exception for authenticated pixels. The fix for the previous error should clean up the failed assertion.

@emcconville emcconville added this to the Wand 0.5.4 milestone May 21, 2019
@emcconville emcconville self-assigned this May 21, 2019
@emcconville
Copy link
Owner

Hey,

Please verify the master branch -- if you can. The Image.import_pixels() method also suffered from the same bug, so that might be worth checking out too.

To run this issue's unit-test, just run the following statement...

$ pytest -k 413

@CoffeeKing68
Copy link
Author

CoffeeKing68 commented May 21, 2019

Hi again,
I re-cloned the repo, ran git log and got:
commit ac5faa3 (HEAD -> master, origin/master, origin/HEAD)
Author: E. McConville
Date: Mon May 20 20:42:51 2019 -0500

Fixed #413 - import / export memory calc
  • Ran the test and it passed.
  • No, issues with my pasted code above
  • And problem I originally is no longer there

Problem solved :)
Thanks emcconville
CoffeeKing

@emcconville
Copy link
Owner

Great!. Thanks for testing the fix -- It really helps.

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

No branches or pull requests

2 participants