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

deskew method is not working as Imagemagick command line #467

Closed
tairen99 opened this issue Mar 10, 2020 · 2 comments
Closed

deskew method is not working as Imagemagick command line #467

tairen99 opened this issue Mar 10, 2020 · 2 comments
Labels
Milestone

Comments

@tairen99
Copy link

@tairen99 tairen99 commented Mar 10, 2020

Hi,
I am getting different results when I am trying to deskew a certain image using the Wand and using imageMagick command line.

The code for Wand is:

`       with Image(filename=test_img) as img:

            img.deskew(threshold=0.4)

            img.save(filename=outputfile)`


The command line using imageMagick is:

 `convert test_deskew.png  -deskew 40% deskewed.jpg`


  My os is: Ubuntu 18.04, 
  The Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114

 Please let me know how to use the Wand deskew method. I do not want to load images and save images to file using "convert".
 If you know how to use the "convert" command line to load image and export images to memory, please share it.
 Thank you very much!
@emcconville
Copy link
Owner

@emcconville emcconville commented Mar 11, 2020

Thanks for reporting this. I should be able to have this resolved shortly. In the meantime, use the following workaround.

with Image(filename=test_img) as img:
    img.deskew(threshold=0.4 * img.quantum_range)
    img.save(filename=outputfile)

@uday-felix
Copy link

@uday-felix uday-felix commented Feb 4, 2022

I am ending up with an error when I use the above code. A sample of my code is produced below. Please advise.

try:
     with skew(blob=img_png) as img_png_1:           
         img_png_1.deskew(0.5 * img_png_1.quantum_range)
         pil_image = Image.open(io.BytesIO(img_png_1.make_blob("png")))            
         img_png = image_to_byte_array(pil_image)            
     log.info("Corrected the Skewness for %s", file_name)
 except Exception as e:
     log.exception(f'Exception:{e} occured while Corrected the Skewness for {file_name}')
     pass

Error Message: wand.exceptions.WandRuntimeError: MagickReadImage returns false, but did not raise ImageMagick exception. This can occur when a delegate is missing, or returns EXIT_SUCCESS without generating a raster.

When I run this in local windows, I dont see any error, but failed in docker(linux). It keeps working for few images and fails for few. Please advice.

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

3 participants