8000 fix: update base image to 1.8.1, enhance error message in InputImage,… by sadok-f · Pull Request #569 · flyimg/flyimg · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: update base image to 1.8.1, enhance error message in InputImage,… #569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM flyimg/base-image:1.7.1
FROM flyimg/base-image:1.8.1

COPY . /var/www/html

Expand Down
2 changes: 1 addition & 1 deletion src/Core/Entity/Image/InputImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ protected function saveToTemporaryFile()
$imageData = file_get_contents($this->sourceImageUrl);
file_put_contents($this->sourceImagePath, $imageData);
} else {
throw new ReadFileException('Local file does not exist.');
throw new ReadFileException('File ' . $this->sourceImageUrl . ' does not exist.');
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Exception/ReadFileException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

class ReadFileException extends HttpException
{
public function __construct()
public function __construct($message = "The server is temporarily unable to process requests")
{
parent::__construct(503, "The server is temporarily unable to process requests");
parent::__construct(503, $message);
}
}
1 change: 1 addition & 0 deletions tests/Core/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class BaseTest extends TestCase

public const FACES_TEST_IMAGE = __DIR__ . '/../testImages/faces.jpg';
public const FACES_CP0_TEST_IMAGE = __DIR__ . '/../testImages/face_cp0.png';
public const FACES_CP0_TEST_IMAGE_AVIF = __DIR__ . '/../testImages/face_cp0.avif';
public const FACES_BLUR_TEST_IMAGE = __DIR__ . '/../testImages/face_fb.png';

public const EXTRACT_TEST_IMAGE = __DIR__ . '/../testImages/extract-original.jpg';
Expand Down
1 change: 1 addition & 0 deletions tests/Core/Entity/Image/InputImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class InputImageTest extends BaseTest
public function testSaveToTemporaryFileException()
{
$this->expectException(ReadFileException::class);
$this->expectExceptionMessage('File ' . parent::JPG_TEST_IMAGE . '--fail does not exist.');
$optionsBag = new OptionsBag($this->imageHandler->appParameters(), 'o_jpg');

new InputImage($optionsBag, parent::JPG_TEST_IMAGE . '--fail');
Expand Down
25 changes: 17 additions & 8 deletions tests/Core/Processor/FaceDetectProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,23 @@ public function testProcessFaceCropping()
{
$image = $this->imageHandler->processImage('fc_1,o_png,rf_1', parent::FACES_TEST_IMAGE);
$filesize = filesize($image->getOutputTmpPath());
$filesize2 = filesize(parent::FACES_CP0_TEST_IMAGE);
// $image1Crc32 = crc32(\file_get_contents($image->getOutputImagePath()));
// $image2Crc32 = crc32(\file_get_contents(parent::FACES_CP0_TEST_IMAGE));
$expectedSize = filesize(parent::FACES_CP0_TEST_IMAGE);
$this->generatedImage[] = $image;
$this->assertFileExists($image->getOutputTmpPath());
$this->assertEquals($filesize, $filesize2);
$this->assertEquals($filesize, $expectedSize);
}

/**
* @throws \Exception
*/
public function testProcessFaceCroppingAvifOutput()
{
$image = $this->imageHandler->processImage('fc_1,o_avif,rf_1', parent::FACES_TEST_IMAGE);
$filesize = filesize($image->getOutputTmpPath());
$expectedSize = filesize(parent::FACES_CP0_TEST_IMAGE_AVIF);
$this->generatedImage[] = $image;
$this->assertFileExists($image->getOutputTmpPath());
$this->assertEquals($filesize, $expectedSize);
}

/**
Expand All @@ -32,11 +43,9 @@ public function testProcessFaceBlurring()
{
$image = $this->imageHandler->processImage('fb_1,o_png,rf_1', parent::FACES_TEST_IMAGE);
$filesize = filesize($image->getOutputTmpPath());
$filesize2 = filesize(parent::FACES_BLUR_TEST_IMAGE);
// $image1Crc32 = crc32(\file_get_contents($image->getOutputImagePath()));
// $image2Crc32 = crc32(\file_get_contents(parent::FACES_BLUR_TEST_IMAGE));
$expectedSize = filesize(parent::FACES_BLUR_TEST_IMAGE);
$this->generatedImage[] = $image;
$this->assertFileExists($image->getOutputTmpPath());
$this->assertEquals($filesize, $filesize2);
$this->assertEquals($filesize, $expectedSize);
}
}
Binary file modified tests/testImages/extract-result.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/testImages/face_cp0.avif
Binary file not shown.
Binary file modified tests/testImages/image-with-text-result.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/testImages/smart_crop_restult.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
0