original_string: public function stream($filename, $options = array())
      {
          if (headers_sent()) {
              die("Unable to stream image: headers already sent");
          }
  
          if (!isset($options["type"])) $options["type"] = "png";
          if (!isset($options["Attachment"])) $options["Attachment"] = true;
          $type = strtolower($options["type"]);
  
          switch ($type) {
              case "jpg":
              case "jpeg":
                  $contentType = "image/jpeg";
                  $extension = ".jpg";
                  break;
              case "png":
              default:
                  $contentType = "image/png";
                  $extension = ".png";
                  break;
          }
  
          header("Cache-Control: private");
          header("Content-Type: $contentType");
  
          $filename = str_replace(array("\n", "'"), "", basename($filename, ".$type")) . $extension;
          $attachment = $options["Attachment"] ? "attachment" : "inline";
          header(Helpers::buildContentDispositionHeader($attachment, $filename));
  
          $this->_output($options);
          flush();
      }
code: public function stream($filename, $options = array())
      {
          if (headers_sent()) {
              die("Unable to stream image: headers already sent");
          }
  
          if (!isset($options["type"])) $options["type"] = "png";
          if (!isset($options["Attachment"])) $options["Attachment"] = true;
          $type = strtolower($options["type"]);
  
          switch ($type) {
              case "jpg":
              case "jpeg":
                  $contentType = "image/jpeg";
                  $extension = ".jpg";
                  break;
              case "png":
              default:
                  $contentType = "image/png";
                  $extension = ".png";
                  break;
          }
  
          header("Cache-Control: private");
          header("Content-Type: $contentType");
  
          $filename = str_replace(array("\n", "'"), "", basename($filename, ".$type")) . $extension;
          $attachment = $options["Attachment"] ? "attachment" : "inline";
          header(Helpers::buildContentDispositionHeader($attachment, $filename));
  
          $this->_output($options);
          flush();
      }
code_tokens: public function stream ( $ filename , $ options = array ( ) ) { if ( headers_sent ( ) ) { die ( "Unable to stream image: headers already sent" ) ; } if ( ! isset ( $ options [ "type" ] ) ) $ options [ "type" ] = "png" ; if ( ! isset ( $ options [ "Attachment" ] ) ) $ options [ "Attachment" ] = true ; $ type = strtolower ( $ options [ "type" ] ) ; switch ( $ type ) { case "jpg" : case "jpeg" : $ contentType = "image/jpeg" ; $ extension = ".jpg" ; break ; case "png" : default : $ contentType = "image/png" ; $ extension = ".png" ; break ; } header ( "Cache-Control: private" ) ; header ( "Content-Type: $contentType" ) ; $ filename = str_replace ( array ( "\n" , "'" ) , "" , basename ( $ filename , ".$type" ) ) . $ extension ; $ attachment = $ options [ "Attachment" ] ? "attachment" : "inline" ; header ( Helpers :: buildContentDispositionHeader ( $ attachment , $ filename ) ) ; $ this -> _output ( $ options ) ; flush ( ) ; }
docstring: Streams the image to the client.
  
  @param string $filename The filename to present to the client.
  @param array $options Associative array: 'type' => jpeg|jpg|png; 'quality' => 0 - 100 (JPEG only);
  'page' => Number of the page to output (defaults to the first); 'Attachment': 1 or 0 (default 1).
docstring_tokens: Streams the image to the client .