Fax image processing (needs to be fast)

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
adam7288
Posts: 1
Joined: 2018-09-15T19:13:46-07:00
Authentication code: 1152

Fax image processing (needs to be fast)

Post by adam7288 » 2018-09-15T19:19:16-07:00

Hello! Thank you for the great information. There are some posts on the non-php side of things about processing photos for faxes. However they are in CLI format and also seems to be very resource intensive. As of now I have gone down two paths:

quantizeImage(2, Imagick::COLORSPACE_GRAY, 2, TRUE, FALSE)
This had good results for photos but text especially handwriting became thin and illegible

$max = $image->getQuantumRange();
$max = $max["quantumRangeLong"];
$image->thresholdImage(0.77 * $max);
This produces great results for documents, but photos look horrible. They mostly turn out black.

Anybody have any other suggestions? A fax has 1 bit color depth. Dithering is certainly an option.

Thank you in advance!

User avatar
fmw42
Posts: 23653
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Fax image processing (needs to be fast)

Post by fmw42 » 2018-09-15T19:41:33-07:00

Try -monochrome

See https://www.imagemagick.org/Usage/quantize/#monochrome

But I don't know if it is included with Imagick. Otherwise, you may be able to achieve that with dithering of a grayscale image then threshold it.

Post Reply