This is the original pdf, ie my input.pdf (please notice that resolution is 120x120):
https://drive.google.com/open?id=1Ppw79 ... NtD3bIqYOn_
When I give the above pdf to Twilio, this is how they convert it (which is very impressive): https://drive.google.com/open?id=1YdC9e ... EJ-4URsS8P
Using the below code, I achieved something close to Twilio's one, but mine is getting a bit blurry (whereas Twilio's one is crystal sharp).
The output pdf: https://drive.google.com/file/d/1bZhUuq ... sp=sharing
Code: Select all
 $imagick = new \Imagick();
 $imagick->readImage($path);
 $imagick->resizeImage(595, 842, \Imagick::FILTER_CATROM, 1, true);
 $imagick->setBackgroundColor(new \ImagickPixel('white'));
 $imagick->quantizeImage(255, \Imagick::COLORSPACE_GRAY, 1, TRUE, FALSE);
 $imagick->orderedPosterizeImage('o8x8');
 $w = $imagick->getImageWidth();
 $h = $imagick->getImageHeight();
 $imagick->extentImage ( 595 , 843 , ($w-595)/2, ($h-843)/2 );
 $imagick->setImageFormat('pdf');
 $imagick->writeImage($endpath);