2010-12-14 16:26:35 +00:00
|
|
|
<?php
|
2011-06-21 03:40:53 +00:00
|
|
|
/**
|
|
|
|
|
* Bootstrapping for test image file generation
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
*/
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2011-06-21 03:40:53 +00:00
|
|
|
// Start up MediaWiki in command-line mode
|
2013-05-17 00:16:59 +00:00
|
|
|
require_once __DIR__ . "/../../../../maintenance/Maintenance.php";
|
|
|
|
|
require __DIR__ . "/RandomImageGenerator.php";
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2011-06-21 03:40:53 +00:00
|
|
|
class GenerateRandomImages extends Maintenance {
|
|
|
|
|
|
2012-06-26 17:02:55 +00:00
|
|
|
public function getDbType() {
|
|
|
|
|
return Maintenance::DB_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-21 03:40:53 +00:00
|
|
|
public function execute() {
|
2016-02-17 09:09:32 +00:00
|
|
|
$getOptSpec = [
|
2011-06-21 03:40:53 +00:00
|
|
|
'minWidth::',
|
|
|
|
|
'maxWidth::',
|
|
|
|
|
'minHeight::',
|
|
|
|
|
'maxHeight::',
|
|
|
|
|
'shapesToDraw::',
|
|
|
|
|
'shape::',
|
|
|
|
|
|
|
|
|
|
'number::',
|
|
|
|
|
'format::'
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2011-06-21 03:40:53 +00:00
|
|
|
$options = getopt( null, $getOptSpec );
|
|
|
|
|
|
2017-10-06 22:17:58 +00:00
|
|
|
$format = $options['format'] ?? 'jpg';
|
2011-06-21 03:40:53 +00:00
|
|
|
unset( $options['format'] );
|
|
|
|
|
|
|
|
|
|
$number = isset( $options['number'] ) ? intval( $options['number'] ) : 10;
|
|
|
|
|
unset( $options['number'] );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2011-06-21 03:40:53 +00:00
|
|
|
$randomImageGenerator = new RandomImageGenerator( $options );
|
|
|
|
|
$randomImageGenerator->writeImages( $number, $format );
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2020-03-24 20:39:38 +00:00
|
|
|
$maintClass = GenerateRandomImages::class;
|
2013-05-17 00:16:59 +00:00
|
|
|
require RUN_MAINTENANCE_IF_MAIN;
|