55[ ![ GitHub Code Style Action Status] ( https://img.shields.io/github/actions/workflow/status/flixtechs-labs/laravel-bytepoint/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square )] ( https://github.com/flixtechs-labs/laravel-bytepoint/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain )
66[ ![ Total Downloads] ( https://img.shields.io/packagist/dt/flixtechs-labs/laravel-bytepoint.svg?style=flat-square )] ( https://packagist.org/packages/flixtechs-labs/laravel-bytepoint )
77
8- This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
8+ Optimize uploaded images on the fly with Bytepoint in Laravel. Fits nicely into your existing workflow
99
10- ## Support us
10+ ``` php
11+
12+ $file = $request->file('image');
1113
12- [ <img src =" https://github-ads.s3.eu-central-1.amazonaws.com/laravel-bytepoint.jpg?t=1 " width =" 419px " />] ( https://spatie.be/github-ad-click/laravel-bytepoint )
14+ $file->bytepoint([
15+ 'type' => 'jpeg'
16+ ])
17+ ->store('avatars');
1318
14- We invest a lot of resources into creating [ best in class open source packages ] ( https://spatie.be/open-source ) . You can support us by [ buying one of our paid products ] ( https://spatie.be/open-source/support-us ) .
19+ ```
1520
16- We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [ our contact page] ( https://spatie.be/about-us ) . We publish all received postcards on [ our virtual postcard wall] ( https://spatie.be/open-source/postcards ) .
1721
1822## Installation
1923
@@ -23,12 +27,6 @@ You can install the package via composer:
2327composer require flixtechs-labs/laravel-bytepoint
2428```
2529
26- You can publish and run the migrations with:
27-
28- ``` bash
29- php artisan vendor:publish --tag=" laravel-bytepoint-migrations"
30- php artisan migrate
31- ```
3230
3331You can publish the config file with:
3432
@@ -40,22 +38,67 @@ This is the contents of the published config file:
4038
4139``` php
4240return [
41+ 'token' => env('BYTEPOINT_TOKEN', ''),
42+ 'url' => env('BYTEPOINT_URL', ''),
4343];
4444```
4545
46- Optionally, you can publish the views using
46+ ## Usage
47+ To use this package you to first to obtain an API token from Bytepont
48+
49+ Visit https://bytepont.flixtechs.co.zw and create an account
50+
51+ On the profile page at the bottom click on "generate token" and copy the token to your .env file as follows
52+
53+ ``` bash
54+ BYTEPOINT_TOKEN=XXXXXX
55+ ```
56+
57+ Add another optional enviroment variable
4758
4859``` bash
49- php artisan vendor:publish --tag= " laravel- bytepoint-views "
60+ BYTEPOINT_URL=https:// bytepoint.flixtechs.co.zw/api/v1/images
5061```
5162
52- ## Usage
63+ After this, all you need to do is hook bytepoint into your existing workflow.
64+
65+ This package adds a fluent ` bytepoint() ` helper to the ` UploadedFile ` object which accepts an array options as arguments.
66+
67+ Currently you can only specifiy the resulting file type, more options coming soon!
5368
5469``` php
55- $bytepoint = new FlixtechsLabs\Bytepoint();
56- echo $bytepoint->echoPhrase('Hello, FlixtechsLabs!');
70+ $request->file('image')->bytepoint(['type' => 'resulting type'])->store('avatars');
5771```
5872
73+ list of accepted file types
74+
75+ - webp
76+ - png
77+ - jpeg
78+
79+ Just call bytepoint before you save the file storage or any other media library that you are using
80+
81+ ## Optimizing existing images
82+
83+ You can also optimize existing images using the Bytepoint facade
84+
85+ ``` php
86+ use FlixtechsLabs\Bytepoint\Facades\Bytepoint;
87+
88+ Bytepoint::optimize($filePath, $destinationPath, $fileName = '', $options = []);
89+
90+ ```
91+
92+ The parameters are as follows
93+
94+ - the file ` $filePath ` is the path to file you want to optimize
95+ - ` $destinationPath ` is the path to save the optimized file
96+ - ` $fileName ` is the name of the file, this is optional though
97+ - ` $options ` an array of options to tell bytepoint how to optimize the image, currently you can only set the resulting file to either ` webp,jpeg,png `
98+
99+
100+
101+
59102## Testing
60103
61104``` bash
0 commit comments