Eventviva\ImageResize::output PHP Method

output() public method

Outputs image to browser
public output ( string $image_type = null, integer $quality = null )
$image_type string
$quality integer
    public function output($image_type = null, $quality = null)
    {
        $image_type = $image_type ?: $this->source_type;
        header('Content-Type: ' . image_type_to_mime_type($image_type));
        $this->save(null, $image_type, $quality);
    }

Usage Example

コード例 #1
0
ファイル: Test.php プロジェクト: madisonmay/php-image-resize
 public function testOutputPng()
 {
     $image = $this->createImage(200, 100, 'png');
     $resize = new ImageResize($image);
     ob_start();
     // supressing header errors
     @$resize->output();
     $image_contents = ob_get_clean();
     $info = finfo_open();
     $type = finfo_buffer($info, $image_contents, FILEINFO_MIME_TYPE);
     $this->assertEquals('image/png', $type);
 }