Browse Source

add libvips to project

master
Mohammad Khazaee 2 years ago
parent
commit
0e00b18bef
  1. 14
      Dockerfile
  2. 2
      docker-compose.yml
  3. 1
      php.ini
  4. BIN
      public/image.jpg
  5. 26
      routes/web.php

14
Dockerfile

@ -0,0 +1,14 @@
FROM omidshj/laravel-dev
# RUN apt install -y php-dev
RUN apt-get -y update
RUN apt-get -y install libffi-dev
RUN docker-php-ext-configure ffi --with-ffi \
&& docker-php-ext-install ffi
RUN apt-get -y install --no-install-recommends libvips42
RUN apt-get -y install libvips-tools
RUN apt-get -y install libvips-dev
RUN pecl install vips
RUN echo 'extension="vips.so"' > /usr/local/etc/php/conf.d/20-vips.ini
COPY ./php.ini /usr/local/etc/php/php.ini

2
docker-compose.yml

@ -2,7 +2,7 @@
version: '3'
services:
laravel:
image: omidshj/laravel-dev
build: .
container_name: app
user: "1000:${GID}"
ports:

1
php.ini

@ -0,0 +1 @@
ffi.enable = "true"

BIN
public/image.jpg

Binary file not shown.

After

Width: 5175  |  Height: 3372  |  Size: 2.6 MiB

26
routes/web.php

@ -13,23 +13,21 @@ use Illuminate\Support\Facades\Route;
|
*/
Route::get('/update', function () {
$user = \App\Models\User::first();
$user->fill(['name' => 'xxxxxx']);
$user->saveRich();
// Route::get('/update', function () {
// $user = \App\Models\User::first();
// $user->fill(['name' => 'xxxxxx']);
// $user->saveRich();
return 'done';
return view('welcome');
});
// return 'done';
// return view('welcome');
// });
Route::get('/', function () {
$user = new \App\Models\User([
'name'=>'test',
'email' => 'aaaa',
'status' => "active"
$image = Image::thumbnail('../public/image.jpg', $request->w);
$image->writeToFile('image-modified.jpg',[
'Q' => $request->q
]);
$user->saveRich();
echo '<img src="image-modified.jpg" alt="">';
return 'done';
return view('welcome');
});
Loading…
Cancel
Save