Stack Overflow in MagickWriteImage after deskew - fixed

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
User avatar
foxyshadis
Posts: 15
Joined: 2010-04-29T19:29:46-07:00
Authentication code: 8675308
Location: Fresno, California

Stack Overflow in MagickWriteImage after deskew - fixed

Post by foxyshadis »

I'm loading an image, reading the properties, deskewing, and saving. I've extended sickos' PyMagickWand to work with the current version and I haven't had any trouble on previous IM-using projects up until I tried to use Deskew. Here's my results, please let me know if I'm doing something wrong:

Code: Select all

b'TIFF'
2550x3300
(300.0, 300.0)
12
Traceback (most recent call last):
  File "scanfix.py", line 34, in <module>
    img.save(view_image)
  File "C:\dev\Python31\x86\lib\site-packages\python_magickwand-0.2sickos-py3.1.egg\magickwand\image.py", line 139, in save
    self._check_wand_error(api.MagickWriteImage(self._wand, file))
WindowsError: exception: stack overflow

Code: Select all

img = Image(infile)
print(img.format)
print(str(img.width)+'x'+str(img.height))
print(img.resolution)
print(img.compression)
img.deskew()
img.save(view_image)
And the API code:

Code: Select all

    def deskew(self):
        ''' Deskews the image.'''
        self._check_wand_error(api.MagickDeskewImage(self._wand,0.1)) # also tried 10.0
    def _check_wand_error(self, func):
        wand._check_wand_error(self._wand, func)
    def save(self, file=None):
        ''' Saves the image to a file.  If no file is specified, the file is
            saved with the original filename.'''
        self._check_wand_error(api.MagickWriteImage(self._wand, file))

Code: Select all

def _check_wand_error(wand, func):
    if not func:
        severity = api.ExceptionType()
        description = api.MagickGetException(wand, severity)
        raise Exception(description)

Code: Select all

MagickDeskewImage = _wandlib.MagickDeskewImage
MagickDeskewImage.restype = MagickBooleanType
MagickDeskewImage.argtypes = [POINTER(MagickWand), c_double]
Am I doing it right, or horribly wrong? Let me know if more info is needed, I can attach everything.
Last edited by foxyshadis on 2010-12-29T22:12:28-07:00, edited 2 times in total.
User avatar
foxyshadis
Posts: 15
Joined: 2010-04-29T19:29:46-07:00
Authentication code: 8675308
Location: Fresno, California

Re: Stock Overflow in MagickWriteImage after deskew

Post by foxyshadis »

Well, it turns out that this was because there was another, older, set of IM dlls in my path. By dynamically setting the correct IM path to be FIRST instead of last, it turns out that it works fine. Sorry about that.
Post Reply