[TASK] Added a very simple progress indicator.

This commit is contained in:
Jan Philipp Timme 2010-12-28 19:41:27 +00:00
parent 9eebcddb84
commit 9342827940
3 changed files with 13 additions and 0 deletions

View File

@ -90,6 +90,7 @@ class FileImageConverter {
$this->image->setCurrentPixel($r, $g, $b, 0); $this->image->setCurrentPixel($r, $g, $b, 0);
//move the pointer //move the pointer
$this->image->movePointer(1); $this->image->movePointer(1);
$this->progressBar($i, $strlen);
} }
} catch (Exception $e) { } catch (Exception $e) {
@ -97,7 +98,19 @@ class FileImageConverter {
echo "Caught Exception:\n"; echo "Caught Exception:\n";
echo $e; echo $e;
} }
echo "\rDone.\n";
}
/**
* Displays a simple progressbar using \r
* @param int $x
* @param int $total
* @return void
*/
protected function progressBar($x, $total) {
$percent = round($x / $total * 100, 2);
echo " \r";
echo "Working... " . $percent . " %";
} }
} }

BIN
result.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 KiB

BIN
test.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 91 KiB