Example #1
0
 function testSetThumbBox()
 {
     $magicHand = new MagicHand('src', 'dst');
     $magicHand->setThumbBox([300, 200]);
     $this->assertEquals(300, $magicHand->getThumbBox()->getWidth());
     $this->assertEquals(200, $magicHand->getThumbBox()->getHeight());
 }
Example #2
0
 /**
  * 绑定ui
  * @param MagicHand $magicHand
  * @param OutputInterface $output
  */
 protected function bindEventsForUi(MagicHand $magicHand, OutputInterface $output)
 {
     $magicHand->getDispatcher()->bind(MagicHand::EVENT_BEGIN, function (Event $event) use($output) {
         $images = $event->getArgument('images');
         $progressBar = new ProgressBar($output, count($images));
         $output->writeln("Magic Hand started and will be performed {$progressBar->getMaxSteps()} images");
         $output->write(PHP_EOL);
         $progressBar->start();
         $this->progressBar = $progressBar;
     });
     $magicHand->getDispatcher()->bind(MagicHand::EVENT_PROCESS, function (Event $event) use($output) {
         $this->progressBar->advance(1);
     });
     $magicHand->getDispatcher()->bind(MagicHand::EVENT_END, function (Event $event) use($output) {
         $this->progressBar->finish();
         $output->writeln(PHP_EOL);
         $output->writeln("Work ok");
     });
 }