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

nepada / file-upload-control / 9327437708

pending completion
9327437708

Pull #156

github

web-flow
Merge 92839108e into 46a12c798
Pull Request #156: Update mockery/mockery requirement from 1.6.11 to 1.6.12

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

78.13
/src/FileUploadControl/Thumbnail/ImageLoader.php
1
<?php
2
declare(strict_types = 1);
3

4
namespace Nepada\FileUploadControl\Thumbnail;
5

6
use Nette;
7
use Nette\Utils\Image;
8

9
final class ImageLoader
10
{
11

12
    use Nette\SmartObject;
13

14
    private bool $autoRotate;
15

16
    public function __construct(bool $autoRotate = true)
1✔
17
    {
18
        $this->autoRotate = $autoRotate;
1✔
19
    }
1✔
20

21
    public function load(string $path): Image
1✔
22
    {
23
        $image = Image::fromFile($path);
1✔
24
        if (! $this->autoRotate) {
1✔
25
            return $image;
1✔
26
        }
27

28
        $exifData = @exif_read_data($path);
1✔
29
        if ($exifData === false) {
1✔
30
            return $image;
1✔
31
        }
32

33
        $orientation = $exifData['Orientation'] ?? 1;
1✔
34
        switch ($orientation) {
1✔
35
            case 2:
×
36
                $image->resize('-100%', null);
1✔
37
                break;
1✔
38
            case 3:
×
39
                $image->resize('-100%', '-100%');
1✔
40
                break;
1✔
41
            case 4:
×
42
                $image->resize(null, '-100%');
1✔
43
                break;
1✔
44
            /** @noinspection PhpMissingBreakStatementInspection */
45
            case 5:
×
46
                $image->resize(null, '-100%');
1✔
47
                // intentionally no break
48
            case 6:
×
49
                $image->rotate(-90, Image::rgb(0, 0, 0, 127));
1✔
50
                break;
1✔
51
            /** @noinspection PhpMissingBreakStatementInspection */
52
            case 7:
×
53
                $image->resize(null, '-100%');
1✔
54
                // intentionally no break
55
            case 8:
×
56
                $image->rotate(90, Image::rgb(0, 0, 0, 127));
1✔
57
                break;
1✔
58
        }
59

60
        return $image;
1✔
61
    }
62

63
}
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

© 2025 Coveralls, Inc