Page 1 of 1

Stack Overflow in MagickWriteImage after deskew - fixed

Posted: 2010-12-29T21:03:35-07:00
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.

Re: Stock Overflow in MagickWriteImage after deskew

Posted: 2010-12-29T22:11:21-07:00
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.