Setting options in phpwkhtmltoimage

347 Views Asked by At

I am trying to reduce the file size of images outputted from phpwkhtmltoimage (php wrapper for wkhtmltopdf)

The image is being saved fine, but the image outputted is exactly the same as having no options set. I am guessing that I am doing something wrong here.

$options = array(
'--dpi 300',
'no-outline',
'--image-quality 10',);

$image = new Image('http://bl.ocks.org/mbostock/raw/7555321/', $options);
$image->saveAs('output.png');

Cheers

2

There are 2 best solutions below

0
On BEST ANSWER

Turns out there is no dpi setting for phpwkhtmltoimage nor image-quality. Instead it uses quality.

array('quality' => 20);
0
On

Try setting the options like this:

$options = [
  'dpi' => 300,
  'no-outline' => true,
  'image-quality' => 10
];