示例#1
0
 public function testRead()
 {
     $s = new Stream();
     $s->open(STREAM_MODE_READWRITE);
     $s->writeLine('Pellentesque sapien enim, pellentesque sed.');
     $s->writeLine('Sed et tortor suscipit velit.');
     $s->writeLine('Phasellus at metus quis erat.');
     $this->assertEquals($s->read(), '');
     $this->assertEquals($s->tell(), 104);
     // Rewind and read each line
     $s->rewind();
     $this->assertEquals($s->readLine(), 'Pellentesque sapien enim, pellentesque sed.');
     $this->assertEquals($s->readLine(), 'Sed et tortor suscipit velit.');
     $this->assertEquals($s->readLine(), 'Phasellus at metus quis erat.');
     // No more lines left, we should receive an empty string
     $this->assertEquals($s->readLine(), '');
     // Check that the offset is still at the "end" of the stream
     $this->assertEquals($s->tell(), 104);
 }
示例#2
0
 /**
  * Get Thumbnail
  *
  * @return  img.Image  
  */
 public function getThumbnail()
 {
     $s = new Stream();
     $s->open(STREAM_MODE_WRITE);
     $s->write(exif_thumbnail($this->getFilename()));
     $s->rewind();
     return Image::loadFrom(new StreamReader($s));
 }