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

CoffeeKing68 opened this issue May 20, 2019 · 4 comments


None yet
2 participants
Copy link

commented May 20, 2019

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 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/
    # 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/

This comment has been minimized.

Copy link

commented May 21, 2019

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 the bug label May 21, 2019

@emcconville emcconville added this to the Wand 0.5.4 milestone May 21, 2019

@emcconville emcconville self-assigned this May 21, 2019


This comment has been minimized.

Copy link

commented May 21, 2019


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

This comment has been minimized.

Copy link

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


This comment has been minimized.

Copy link

commented May 21, 2019

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
You can’t perform that action at this time.