Skip to content

Commit

Permalink
chore: release 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bepsvpt committed Feb 9, 2024
1 parent db928b5 commit 66d35c8
Show file tree
Hide file tree
Showing 46 changed files with 1,314 additions and 300 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.php]
indent_size = 4
15 changes: 15 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
* text=auto eol=lf

*.md diff=markdown
*.php diff=php

/.github export-ignore
/tests export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
artisan export-ignore
phpstan.neon export-ignore
phpunit.xml export-ignore
screenshot.png export-ignore
testbench.yaml export-ignore
27 changes: 17 additions & 10 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ name: Testing

on:
push:
pull_request:
schedule:
# run tests on every week Monday
- cron: '0 0 * * 1'
- cron: '0 0 * * 1' # run tests on every week Monday

jobs:
static_analysis:
Expand All @@ -19,14 +17,14 @@ jobs:
- name: Setup PHP with PECL extension
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
php-version: '8.3'
coverage: xdebug

- name: Get composer cache directory
run: echo "COMPOSER_DIR=$(composer config cache-files-dir)" >> $GITHUB_ENV

- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ env.COMPOSER_DIR }}
key: ${{ runner.os }}-composer-static-analysis-${{ hashFiles('**/composer.json') }}
Expand All @@ -45,7 +43,7 @@ jobs:
run: composer normalize --dry-run

- name: Run static analysis
run: vendor/bin/phpstan --verbose
run: vendor/bin/phpstan --memory-limit=-1 --verbose

- name: Run coding style checker
run: vendor/bin/pint --verbose --test
Expand All @@ -61,7 +59,7 @@ jobs:
matrix:
laravel: [ '10', '9', '8' ]
php: [ '8.3', '8.2', '8.1', '8.0' ]
os: [ ubuntu-latest, windows-latest, macOS-latest ]
os: [ ubuntu-latest, macOS-latest ]

steps:
- uses: actions/checkout@v4
Expand All @@ -70,8 +68,17 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: fileinfo, gd
coverage: xdebug
extensions: fileinfo, gd, imagick, exif, ffi

- name: Install libvips
if: runner.os == 'Linux'
env:
DEBIAN_FRONTEND: noninteractive
run: sudo apt-get install -y libvips

- name: Install libvips
if: runner.os == 'macOS'
run: brew install vips

- name: Get composer cache directory for Windows
if: runner.os == 'Windows'
Expand All @@ -82,7 +89,7 @@ jobs:
run: echo "COMPOSER_DIR=$(composer config cache-files-dir)" >> $GITHUB_ENV

- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ env.COMPOSER_DIR }}
key: ${{ runner.os }}-composer-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-${{ hashFiles('**/composer.json') }}
Expand Down
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
/.fleet
/.idea
/build
/.vscode
/coverage
/vendor
.php_cs.cache
.DS_Store
.phpunit.result.cache
clover.xml
composer.phar
composer.lock
Thumbs.db
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# BlurHash Changelog

## 3.x

- 3.0.0 (2024-02-10)
- Added support for the libvips ([php-vips](https://github.com/libvips/php-vips)) image processing library as a driver.
- Separated from the [intervention/image](https://github.com/Intervention/image) library.

## 2.x

- 2.1.1 (2023-04-24)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) BePsvPT
Copyright (c) bepsvpt

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
27 changes: 21 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,22 @@ A PHP implementation of [BlurHash](https://github.com/woltapp/blurhash) with Lar

BlurHash is a compact representation of a placeholder for an image.

![screenshot](screenshot.png)
![screenshot](https://raw.githubusercontent.com/bepsvpt/blurhash/main/screenshot.png)

<p align="center">Nr8%YLkDR4j[aej]NSaznzjuk9ayR3jYofayj[f6</p>

- [Version](#version)
- [Installation](#installation)
- [Usage](#usage)
- [Changelog](#changelog)
- [Upgrade](#upgrade)
- [License](#license)

## Version

2.1.1
3.0.0

## Supported Laravel Version
### Supported Laravel Version

8.0 ~ 10.x

Expand All @@ -44,21 +51,29 @@ Done!
### Facade

```php
BlurHash::encode($file);
BlurHash::encode($path);
```

`$file` can be any [Intervention make method](https://image.intervention.io/v2/api/make) acceptable source.
`$file` can be `UploadedFile` or a file path string.

### app helper function

```php
app('blurhash')
->setComponentX(7)
->setComponentY(4)
->setResizedImageMaxWidth(96)
->setMaxSize(96)
->encode(request('file'));
```

## Changelog

Please see [CHANGELOG](CHANGELOG.md) for details.

## Upgrade

Please see [UPGRADE](UPGRADE.md) for details.

## License

BlurHash is licensed under [The MIT License (MIT).](LICENSE.md)
6 changes: 6 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## 2.x.x to 3.0.0

- A new configuration option, `driver`, has been added. You can see it [here](https://github.com/bepsvpt/blurhash/blob/3.0.0/config/blurhash.php#L5-L11) and add it to your own config file.
- The `resized-image-max-width` setting is now called `resized-max-size`.
- The `encode` method accepts only `UploadedFile` and `string` (for file path).
- `decode` returns a resource based on the driver you've configured.
53 changes: 53 additions & 0 deletions artisan
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env php
<?php

define('LARAVEL_START', microtime(true));

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any of our classes manually. It's great to relax.
|
*/

require __DIR__.'/vendor/autoload.php';

$app = require_once __DIR__.'/vendor/orchestra/testbench-core/laravel/bootstrap/app.php';

/*
|--------------------------------------------------------------------------
| Run The Artisan Application
|--------------------------------------------------------------------------
|
| When we run the console application, the current CLI command will be
| executed in this console and the response sent back to a terminal
| or another output device for the developers. Here goes nothing!
|
*/

$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);

$status = $kernel->handle(
$input = new Symfony\Component\Console\Input\ArgvInput,
new Symfony\Component\Console\Output\ConsoleOutput
);

/*
|--------------------------------------------------------------------------
| Shutdown The Application
|--------------------------------------------------------------------------
|
| Once Artisan has finished running, we will fire off the shutdown events
| so that any final work may be done by the application before we shut
| down the process. This is the last thing to happen to the request.
|
*/

$kernel->terminate($input, $status);

exit($status);
22 changes: 14 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,28 @@
"authors": [
{
"name": "bepsvpt",
"email": "og7lsrszah6y3lz@infinitefa.email"
"email": "6ibrl@cpp.tw"
}
],
"homepage": "https://github.com/bepsvpt/blurhash",
"require": {
"php": "^8.0",
"ext-gd": "*",
"illuminate/support": "^8.0 || ^9.0 || ^10.0",
"intervention/image": "^2.7"
"ext-exif": "*",
"illuminate/support": "^8.0 || ^9.0 || ^10.0 || ^11.0"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.39",
"ergebnis/composer-normalize": "^2.42",
"jcupitt/vips": "^2.3",
"larastan/larastan": "^2.8",
"laravel/pint": "^1.13",
"orchestra/testbench": "^6.38 || ^7.35 || ^8.15",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^9.6 || ^10.4"
"orchestra/testbench": "^6.42 || ^7.40 || ^8.21",
"phpunit/phpunit": "^9.6"
},
"suggest": {
"ext-ffi": "Required to use php-vips driver.",
"ext-gd": "Required to use GD driver.",
"ext-imagick": "Required to use Imagick driver.",
"jcupitt/vips": "Required to use php-vips driver."
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down
31 changes: 18 additions & 13 deletions config/blurhash.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,34 @@
return [

/*
* Components picked from image x and y axis.
* The image driver is used for encoding and decoding blurhash.
*
* The more components you pick, the more information
* is retained in the placeholder, but the longer the
* BlurHash string will be. Also, it doesn't always
* look good with too many components.
* Supported drivers include "gd", "imagick", and "php-vips".
*/

'driver' => 'gd',

/*
* Components are selected from the image's x and y axis.
*
* Valid value is from 1 to 9.
* Choosing more components means the placeholder will
* retain more information, but it also makes the
* BlurHash string longer. However, having too many
* components doesn't always result in a better look.
*
* The valid range for values is from 1 to 9.
*/

'components-x' => 4,

'components-y' => 3,

/*
* Resize image max width.
*
* When encoding the image, image will resize to
* small one to optimize performance. It is not
* recommend to set the value larger than 256.
*
* When encoding the image, it will resize to a smaller
* version to enhance performance. It's not recommended
* to set the max width and height values larger than 256.
*/

'resized-image-max-width' => 64,
'resized-max-size' => 64,

];
3 changes: 3 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
includes:
- vendor/larastan/larastan/extension.neon

parameters:
level: max

Expand Down
16 changes: 14 additions & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
executionOrder="random"
testdox="true"
>
<testsuites>
<testsuite name="BlurHash Test">
<directory>./tests</directory>
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<report>
<html outputDirectory="coverage"/>
</report>
</coverage>
<php>
<ini name="memory_limit" value="-1"/>
<ini name="error_reporting" value="-1"/>
<ini name="log_errors_max_len" value="0"/>
<ini name="xdebug.show_exception_trace" value="0"/>
<ini name="assert.exception" value="1"/>
</php>
</phpunit>
11 changes: 0 additions & 11 deletions pint.json

This file was deleted.

Loading

0 comments on commit 66d35c8

Please sign in to comment.