mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-13 15:07:49 +00:00
initial commit
This commit is contained in:
parent
32d63c09e7
commit
01655b413e
37 changed files with 2564 additions and 283 deletions
26
app/Utils/OneBitModifier.php
Normal file
26
app/Utils/OneBitModifier.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace App\Utils;
|
||||
|
||||
use Intervention\Image\Interfaces\ImageInterface;
|
||||
use Intervention\Image\Interfaces\ModifierInterface;
|
||||
|
||||
class OneBitModifier implements ModifierInterface
|
||||
{
|
||||
public function apply(ImageInterface $image): ImageInterface
|
||||
{
|
||||
foreach ($image as $pixel) {
|
||||
// Get brightness value of pixel (0-255)
|
||||
$brightness = $pixel->brightness();
|
||||
|
||||
// Convert to Black or White based on a threshold (128)
|
||||
if ($brightness < 128) {
|
||||
$pixel->set([0, 0, 0]); // Black
|
||||
} else {
|
||||
$pixel->set([255, 255, 255]); // White
|
||||
}
|
||||
}
|
||||
|
||||
return $image;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue