Method: Magick::Image#deskew
- Defined in:
- ext/RMagick/rmimage.cpp
#deskew(threshold = 0.40, auto_crop_width = nil) ⇒ Magick::Image
Straightens an image. A threshold of 40% works for most images.
5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 |
# File 'ext/RMagick/rmimage.cpp', line 5429
VALUE
Image_deskew(int argc, VALUE *argv, VALUE self)
{
Image *image, *new_image;
double threshold = 40.0 * QuantumRange / 100.0;
unsigned long width;
char auto_crop_width[20];
ExceptionInfo *exception;
image = rm_check_destroyed(self);
switch (argc)
{
case 2:
width = NUM2ULONG(argv[1]);
memset(auto_crop_width, 0, sizeof(auto_crop_width));
snprintf(auto_crop_width, sizeof(auto_crop_width), "%lu", width);
SetImageArtifact(image, "deskew:auto-crop", auto_crop_width);
case 1:
threshold = rm_percentage(argv[0], 1.0) * QuantumRange;
case 0:
break;
default:
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 2)", argc);
break;
}
exception = AcquireExceptionInfo();
GVL_STRUCT_TYPE(DeskewImage) args = { image, threshold, exception };
new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(DeskewImage), &args);
CHECK_EXCEPTION();
DestroyExceptionInfo(exception);
return rm_image_new(new_image);
}
|