2. Сервис обработки картинок
upload.api broker
worker workerworker
content server
ZeroMQ
Sharding (round-robin)
WebDAV
content server
content server
отправить
картинку
получить статус
обработки
Application servers
2/19
8. Feature: Image processing in gif format
As a system
I want to process images in 7 modes
To use these images on different web pages
Scenario Outline: Processing horizontal image.gif
Given I have image <original_image>
When image is processed using mode <mode>
Then I should get image "<result_image>"
Examples:
| original_image | mode | result_image |
| original_horizontal.gif | crop_center | crop_center/result_horizontal.gif |
| original_horizontal.gif | copy | copy/result_horizontal.gif |
| original_horizontal.gif | large | large/result_horizontal.gif |
| original_horizontal.gif | resize | resize/result_horizontal.gif |
| original_horizontal.gif | resize_by_bigger_size | resize_by_bigger_size/result_horizontal.gif |
| original_horizontal.gif | scale | scale/result_horizontal.gif |
| original_horizontal.gif | white_background | white_background/result_horizontal.gif |
8/19
9. /**
* @Given I have image :path
*/
public function iHaveImage($path)
{
$path = $this->getImagePath($path);
if (!file_exists($path)) {
throw new Exception(
"File $path not found"
);
}
$this->originalImagePath = $path;
}
/**
* @When image is processed using mode
:name
*/
public function
imageIsProcessedUsingMode($name)
{
$this->processImage([
'mode' => $name,
'w' => 300,
'h' => 300,
]);
}
/**
* @Then I should get image :path
*/
public function iShouldGetImage($path)
{
$expectedImagePath = $this->getImagePath($path);
if (!file_exists($expectedImagePath)) {
throw new Exception(
"File $expectedImagePath not found"
);
}
$expected = new Imagick($expectedImagePath);
$actual = new Imagick($this->actualImagePath);
if ($actual->getImageGeometry() != $expected-
>getImageGeometry()) {
throw new Exception(
'Image sizes do not match'
);
}
if ($actual->compareImages($expected, 1)[1] != 0) {
throw new Exception('Images do not match');
}
unlink($this->actualImagePath);
}
9/19