画像をアップロード時にファイルサイズを500KBに自動変換
このコミットが含まれているのは:
コミット
2c07627087
|
@ -10,6 +10,8 @@ use Illuminate\Support\Facades\DB;
|
|||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
use Image;
|
||||
|
||||
use App\Models\Child;
|
||||
use App\Models\FatherRelation;
|
||||
use App\Models\MeetingApprovals;
|
||||
|
@ -135,8 +137,7 @@ class ChildrenController extends Controller {
|
|||
$password = Hash::make($r->password);
|
||||
|
||||
if (!is_null($r->image)) {
|
||||
$ext = explode('/', mime_content_type($r->image))[1];
|
||||
$filename = $this->uuidv4() . '.'.$ext;
|
||||
$filename = $this->uuidv4() . '.jpg';
|
||||
}
|
||||
|
||||
$insert = [
|
||||
|
@ -158,6 +159,10 @@ class ChildrenController extends Controller {
|
|||
if (!is_null($r->image)) {
|
||||
$image = base64_decode(substr($r->image, strpos($r->image, ',') + 1));
|
||||
Storage::disk('private')->put($filename, $image);
|
||||
|
||||
$quality = 1;
|
||||
$img = Image::make('/work/storage/app/private/'.$filename)->encode('jpg', $quality);
|
||||
$img->save('/work/storage/app/private/'.$filename);
|
||||
}
|
||||
|
||||
$child->fill($insert);
|
||||
|
@ -394,8 +399,7 @@ class ChildrenController extends Controller {
|
|||
return ['status_code' => 422, 'error_messages' => $validate->errors()];
|
||||
}
|
||||
|
||||
$ext = explode('/', mime_content_type($r->image))[1];
|
||||
$filename = $this->uuidv4() . '.'.$ext;
|
||||
$filename = $this->uuidv4() . '.jpg';
|
||||
$oldimg = null;
|
||||
|
||||
try {
|
||||
|
@ -404,6 +408,10 @@ class ChildrenController extends Controller {
|
|||
$image = base64_decode(substr($r->image, strpos($r->image, ',') + 1));
|
||||
Storage::disk('private')->put($filename, $image);
|
||||
|
||||
$quality = 1;
|
||||
$img = Image::make('/work/storage/app/private/'.$filename)->encode('jpg', $quality);
|
||||
$img->save('/work/storage/app/private/'.$filename);
|
||||
|
||||
$child = Child::find((int)$child_id);
|
||||
if (!is_null($child->image) && $child->image != '/assets/default/avatar.jpg') {
|
||||
$oldimg = str_replace('/files/', '', $child->image);
|
||||
|
|
|
@ -11,6 +11,8 @@ use Illuminate\Support\Facades\Log;
|
|||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
use Image;
|
||||
|
||||
use App\Models\Father;
|
||||
use App\Models\FatherRelation;
|
||||
use App\Models\EmailActivation;
|
||||
|
@ -175,10 +177,13 @@ class FathersController extends Controller {
|
|||
$password = Hash::make($r->password);
|
||||
|
||||
if (!is_null($r->image)) {
|
||||
$ext = explode('/', mime_content_type($r->image))[1];
|
||||
$filename = $this->uuidv4() . '.'.$ext;
|
||||
$filename = $this->uuidv4() . '.jpg';
|
||||
$image = base64_decode(substr($r->image, strpos($r->image, ',') + 1));
|
||||
Storage::disk('private')->put($filename, $image);
|
||||
|
||||
$quality = 1;
|
||||
$img = Image::make('/work/storage/app/private/'.$filename)->encode('jpg', $quality);
|
||||
$img->save('/work/storage/app/private/'.$filename);
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -329,8 +334,7 @@ class FathersController extends Controller {
|
|||
return ['status_code' => 422, 'error_messages' => $validate->errors()];
|
||||
}
|
||||
|
||||
$ext = explode('/', mime_content_type($r->image))[1];
|
||||
$filename = $this->uuidv4() . '.'.$ext;
|
||||
$filename = $this->uuidv4() . '.jpg';
|
||||
$oldimg = null;
|
||||
|
||||
try {
|
||||
|
@ -339,6 +343,10 @@ class FathersController extends Controller {
|
|||
$image = base64_decode(substr($r->image, strpos($r->image, ',') + 1));
|
||||
Storage::disk('private')->put($filename, $image);
|
||||
|
||||
$quality = 1;
|
||||
$img = Image::make('/work/storage/app/private/'.$filename)->encode('jpg', $quality);
|
||||
$img->save('/work/storage/app/private/'.$filename);
|
||||
|
||||
$father = Father::find((int)$father_id);
|
||||
if (!is_null($father->image) && $father->image != '/assets/default/avatar.jpg') {
|
||||
$oldimg = str_replace('/files/', '', $father->image);
|
||||
|
|
|
@ -8,6 +8,8 @@ use Illuminate\Http\Request;
|
|||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
use Image;
|
||||
|
||||
use App\Models\MeetingImage;
|
||||
|
||||
class MeetingImagesController extends Controller {
|
||||
|
@ -46,11 +48,13 @@ class MeetingImagesController extends Controller {
|
|||
|
||||
try {
|
||||
foreach (json_decode($r->image) as $img) {
|
||||
$ext = explode('/', mime_content_type($img))[1];
|
||||
$filename = $this->uuidv4() . '.'.$ext;
|
||||
$fname[] = $this->uuidv4() . '.'.$ext;
|
||||
$filename = $this->uuidv4() . '.jpg';
|
||||
$fname[] = $filename;
|
||||
$image = base64_decode(substr($img, strpos($img, ',') + 1));
|
||||
Storage::disk('private')->put($filename, $image);
|
||||
$quality = 1;
|
||||
$imag = Image::make('/work/storage/app/private/'.$filename)->encode('jpg', $quality);
|
||||
$imag->save('/work/storage/app/private/'.$filename);
|
||||
|
||||
$insert = [
|
||||
'meeting_id' => (int)$r->meeting_id,
|
||||
|
|
|
@ -8,6 +8,8 @@ use Illuminate\Http\Request;
|
|||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
use Image;
|
||||
|
||||
use App\Models\Meeting;
|
||||
use App\Models\MeetingImage;
|
||||
use App\Models\MeetingApprovals;
|
||||
|
@ -97,11 +99,13 @@ class MeetingsController extends Controller {
|
|||
if (isset($r->image)) {
|
||||
foreach ($r->image as $img) {
|
||||
if (substr($img, -5) != '.jpeg' && substr($img, -4) != '.jpg' && substr($img, -4) != '.png' && substr($img, -4) != '.gif') {
|
||||
$ext = explode('/', mime_content_type($img))[1];
|
||||
$fname = $this->uuidv4() . '.'.$ext;
|
||||
$fname = $this->uuidv4() . '.jpg';
|
||||
$fnames[] = $fname;
|
||||
$image = base64_decode(substr($img, strpos($img, ',') + 1));
|
||||
Storage::disk('private')->put($fname, $image);
|
||||
$quality = 1;
|
||||
$imag = Image::make('/work/storage/app/private/'.$fname)->encode('jpg', $quality);
|
||||
$imag->save('/work/storage/app/private/'.$fname);
|
||||
|
||||
$imgname = '/files/'.$fname;
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
"fideloper/proxy": "^4.4",
|
||||
"fruitcake/laravel-cors": "^2.0",
|
||||
"guzzlehttp/guzzle": "^7.0.1",
|
||||
"intervention/image": "^2.7",
|
||||
"laravel/framework": "^8.12",
|
||||
"laravel/nexmo-notification-channel": "^2.5",
|
||||
"laravel/tinker": "^2.5"
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "397d841f3fa22203eb38abc989f11c62",
|
||||
"content-hash": "9c7f3f3ae06176c13a2e71065d0491b6",
|
||||
"packages": [
|
||||
{
|
||||
"name": "asm89/stack-cors",
|
||||
|
@ -1089,6 +1089,90 @@
|
|||
],
|
||||
"time": "2021-10-06T17:43:30+00:00"
|
||||
},
|
||||
{
|
||||
"name": "intervention/image",
|
||||
"version": "2.7.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Intervention/image.git",
|
||||
"reference": "9a8cc99d30415ec0b3f7649e1647d03a55698545"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Intervention/image/zipball/9a8cc99d30415ec0b3f7649e1647d03a55698545",
|
||||
"reference": "9a8cc99d30415ec0b3f7649e1647d03a55698545",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-fileinfo": "*",
|
||||
"guzzlehttp/psr7": "~1.1 || ^2.0",
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "~0.9.2",
|
||||
"phpunit/phpunit": "^4.8 || ^5.7 || ^7.5.15"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-gd": "to use GD library based image processing.",
|
||||
"ext-imagick": "to use Imagick based image processing.",
|
||||
"intervention/imagecache": "Caching extension for the Intervention Image library"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.4-dev"
|
||||
},
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Intervention\\Image\\ImageServiceProvider"
|
||||
],
|
||||
"aliases": {
|
||||
"Image": "Intervention\\Image\\Facades\\Image"
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Intervention\\Image\\": "src/Intervention/Image"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Oliver Vogel",
|
||||
"email": "oliver@olivervogel.com",
|
||||
"homepage": "http://olivervogel.com/"
|
||||
}
|
||||
],
|
||||
"description": "Image handling and manipulation library with support for Laravel integration",
|
||||
"homepage": "http://image.intervention.io/",
|
||||
"keywords": [
|
||||
"gd",
|
||||
"image",
|
||||
"imagick",
|
||||
"laravel",
|
||||
"thumbnail",
|
||||
"watermark"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/Intervention/image/issues",
|
||||
"source": "https://github.com/Intervention/image/tree/2.7.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://www.paypal.me/interventionphp",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/Intervention",
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2021-10-03T14:17:12+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laminas/laminas-diactoros",
|
||||
"version": "2.8.0",
|
||||
|
@ -8561,5 +8645,5 @@
|
|||
"php": "^7.3|^8.0"
|
||||
},
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "2.1.0"
|
||||
"plugin-api-version": "2.0.0"
|
||||
}
|
||||
|
|
|
@ -165,6 +165,7 @@ return [
|
|||
/*
|
||||
* Package Service Providers...
|
||||
*/
|
||||
Intervention\Image\ImageServiceProvider::class,
|
||||
|
||||
/*
|
||||
* Application Service Providers...
|
||||
|
@ -209,6 +210,7 @@ return [
|
|||
'Gate' => Illuminate\Support\Facades\Gate::class,
|
||||
'Hash' => Illuminate\Support\Facades\Hash::class,
|
||||
'Http' => Illuminate\Support\Facades\Http::class,
|
||||
'Image' => Intervention\Image\Facades\Image::class,
|
||||
'Lang' => Illuminate\Support\Facades\Lang::class,
|
||||
'Log' => Illuminate\Support\Facades\Log::class,
|
||||
'Mail' => Illuminate\Support\Facades\Mail::class,
|
||||
|
|
|
@ -13,10 +13,22 @@ RUN apt-get install -y nodejs
|
|||
|
||||
# yarnをインストール
|
||||
RUN apt-get update && \
|
||||
apt-get -y install git unzip libzip-dev libicu-dev libonig-dev && \
|
||||
apt-get -y install git unzip libzip-dev libicu-dev libonig-dev zlib1g-dev && \
|
||||
apt-get clean && \
|
||||
curl --output libpng16-16_1.6.36-6_amd64.deb http://ftp.jp.debian.org/debian/pool/main/libp/libpng1.6/libpng16-16_1.6.36-6_amd64.deb && \
|
||||
curl --output libpng-dev_1.6.36-6_amd64.deb http://ftp.jp.debian.org/debian/pool/main/libp/libpng1.6/libpng-dev_1.6.36-6_amd64.deb && \
|
||||
curl --output libjpeg62-turbo_1.5.2-2+deb10u1_amd64.deb http://ftp.jp.debian.org/debian/pool/main/libj/libjpeg-turbo/libjpeg62-turbo_1.5.2-2+deb10u1_amd64.deb && \
|
||||
curl --output libjpeg62-turbo-dev_1.5.2-2+deb10u1_amd64.deb http://ftp.jp.debian.org/debian/pool/main/libj/libjpeg-turbo/libjpeg62-turbo-dev_1.5.2-2+deb10u1_amd64.deb && \
|
||||
curl --output libjpeg-dev_1.5.2-2+deb10u1_all.deb http://ftp.jp.debian.org/debian/pool/main/libj/libjpeg-turbo/libjpeg-dev_1.5.2-2+deb10u1_all.deb && \
|
||||
dpkg -i libpng16-16_1.6.36-6_amd64.deb && \
|
||||
dpkg -i libpng-dev_1.6.36-6_amd64.deb && \
|
||||
dpkg -i libjpeg62-turbo_1.5.2-2+deb10u1_amd64.deb && \
|
||||
dpkg -i libjpeg62-turbo-dev_1.5.2-2+deb10u1_amd64.deb && \
|
||||
dpkg -i libjpeg-dev_1.5.2-2+deb10u1_all.deb && \
|
||||
rm -rf *.deb && \
|
||||
rm -rf /var/lib/apt/lists/* && \
|
||||
docker-php-ext-install intl pdo_mysql zip bcmath
|
||||
docker-php-ext-configure gd --with-jpeg
|
||||
docker-php-ext-install intl pdo_mysql zip bcmath gd
|
||||
|
||||
COPY ./php.ini /usr/local/etc/php/php.ini
|
||||
|
||||
|
|
新しいイシューから参照