mikehaertl\wkhtmlto\Image::setOptions PHP Method

setOptions() public method

Set options
public setOptions ( array $options = [] ) : static
$options array list of image options to set as name/value pairs
return static the Image instance for method chaining
    public function setOptions($options = array())
    {
        foreach ($options as $key => $val) {
            if (is_int($key)) {
                $this->_options[] = $val;
            } elseif ($key[0] !== '_' && property_exists($this, $key)) {
                $this->{$key} = $val;
            } else {
                $this->_options[$key] = $val;
            }
        }
        return $this;
    }

Usage Example

Example #1
0
 public function testCanSetOptions()
 {
     $inFile = $this->getHtmlAsset();
     $outFile = $this->getOutFile('png');
     $binary = $this->getBinary();
     $image = new Image();
     $image->setOptions(array('binary' => $binary, 'type' => 'png', 'transparent', 'width' => 800, 'allow' => array('/tmp', '/test')));
     $this->assertInstanceOf('mikehaertl\\wkhtmlto\\Image', $image->setPage($inFile));
     $this->assertTrue($image->saveAs($outFile));
     $tmpFile = $image->getimageFilename();
     $this->assertFileExists($outFile);
     $this->assertEquals("{$binary} --transparent --width '800' --allow '/tmp' --allow '/test' '{$inFile}' '{$tmpFile}'", (string) $image->getCommand());
     unlink($outFile);
 }
All Usage Examples Of mikehaertl\wkhtmlto\Image::setOptions