• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tito10047 / progressive-image-bundle / 20688684442

04 Jan 2026 06:11AM UTC coverage: 88.746%. Remained the same
20688684442

push

github

tito10047
update comments and exception messages: standardize English terminology in comments, exceptions, and test outputs across all source files and tests

0 of 5 new or added lines in 3 files covered. (0.0%)

623 of 702 relevant lines covered (88.75%)

185.41 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.31
/src/Analyzer/ImagickAnalyzer.php
1
<?php
2

3
/*
4
 * This file is part of the Progressive Image Bundle.
5
 *
6
 * (c) Jozef Môstka <https://github.com/tito10047/progressive-image-bundle>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
namespace Tito10047\ProgressiveImageBundle\Analyzer;
13

14
use kornrunner\Blurhash\Blurhash;
15
use Tito10047\ProgressiveImageBundle\DTO\ImageMetadata;
16
use Tito10047\ProgressiveImageBundle\Exception\ImageProcessingException;
17
use Tito10047\ProgressiveImageBundle\Loader\LoaderInterface;
18

19
final class ImagickAnalyzer implements ImageAnalyzerInterface
20
{
21
    public function __construct(
22
        private readonly int $componentsX = 4,
23
        private readonly int $componentsY = 3,
24
    ) {
25
    }
14✔
26

27
    public function analyze(LoaderInterface $loader, string $path): ImageMetadata
28
    {
29
        $image = new \Imagick();
14✔
30

31
        try {
32
                        // 3. Loading directly from handle
33
            $image->readImageFile($loader->load($path));
14✔
34
            $image->thumbnailImage(64, 64, true);
14✔
35

36
            $width = $image->getImageWidth();
14✔
37
            $height = $image->getImageHeight();
14✔
38
            $pixels = $image->exportImagePixels(0, 0, $width, $height, 'RGB', \Imagick::PIXEL_CHAR);
14✔
39

40
            $formattedPixels = [];
14✔
41
            for ($y = 0; $y < $height; ++$y) {
14✔
42
                $row = [];
14✔
43
                for ($x = 0; $x < $width; ++$x) {
14✔
44
                    $offset = ($y * $width + $x) * 3;
14✔
45
                    $row[] = [
14✔
46
                        $pixels[$offset],
14✔
47
                        $pixels[$offset + 1],
14✔
48
                        $pixels[$offset + 2],
14✔
49
                    ];
14✔
50
                }
51
                $formattedPixels[] = $row;
14✔
52
            }
53
        } catch (\ImagickException $e) {
×
NEW
54
                        throw new ImageProcessingException('Imagick could not load data from stream: ' . $e->getMessage());
×
55
        }
56

57
        $hash = Blurhash::encode($formattedPixels, $this->componentsX, $this->componentsY);
14✔
58

59
        return new ImageMetadata(
14✔
60
            $hash,
14✔
61
            $width,
14✔
62
            $height
14✔
63
        );
14✔
64
    }
65
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc