mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-01-26 11:14:06 +00:00
145 - Resizing the Poster Image
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
namespace App\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Intervention\Image\Facades\Image;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
@@ -21,6 +23,9 @@ class ProcessPosterImage implements ShouldQueue
|
||||
|
||||
public function handle()
|
||||
{
|
||||
//
|
||||
$imageContents = Storage::disk('public')->get($this->concert->poster_image_path);
|
||||
$image = Image::make($imageContents);
|
||||
$image->resize(600)->encode();
|
||||
Storage::disk('public')->put($this->concert->poster_image_path, (string) $image);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
"stripe/stripe-php": "^4.3",
|
||||
"guzzlehttp/guzzle": "^6.2",
|
||||
"hashids/hashids": "^2.0",
|
||||
"laravel/dusk": "^1.1"
|
||||
"laravel/dusk": "^1.1",
|
||||
"intervention/image": "^2.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"fzaninotto/faker": "~1.4",
|
||||
|
||||
72
composer.lock
generated
72
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "a503f9147c24fb95300877d6d2f3f0bc",
|
||||
"content-hash": "02c9d4c5e1e6a691a3b64c3a732aee1d",
|
||||
"packages": [
|
||||
{
|
||||
"name": "doctrine/inflector",
|
||||
@@ -522,6 +522,76 @@
|
||||
],
|
||||
"time": "2017-01-01T13:33:33+00:00"
|
||||
},
|
||||
{
|
||||
"name": "intervention/image",
|
||||
"version": "2.4.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Intervention/image.git",
|
||||
"reference": "3603dbcc9a17d307533473246a6c58c31cf17919"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Intervention/image/zipball/3603dbcc9a17d307533473246a6c58c31cf17919",
|
||||
"reference": "3603dbcc9a17d307533473246a6c58c31cf17919",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-fileinfo": "*",
|
||||
"guzzlehttp/psr7": "~1.1",
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "~0.9.2",
|
||||
"phpunit/phpunit": "^4.8 || ^5.7"
|
||||
},
|
||||
"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.3-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"
|
||||
],
|
||||
"time": "2017-09-21T16:29:17+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/dusk",
|
||||
"version": "v1.1.0",
|
||||
|
||||
33
tests/Unit/Jobs/ProcessPosterImageTest.php
Normal file
33
tests/Unit/Jobs/ProcessPosterImageTest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Jobs;
|
||||
|
||||
use Tests\TestCase;
|
||||
use App\Jobs\ProcessPosterImage;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
class ProcessPosterImageTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
function it_resizes_the_poster_image_to_600px_wide()
|
||||
{
|
||||
Storage::fake('public');
|
||||
Storage::disk('public')->put(
|
||||
'posters/example-poster.png',
|
||||
file_get_contents(base_path('tests/__fixtures__/full-size-poster.png'))
|
||||
);
|
||||
$concert = \ConcertFactory::createUnpublished([
|
||||
'poster_image_path' => 'posters/example-poster.png',
|
||||
]);
|
||||
|
||||
ProcessPosterImage::dispatch($concert);
|
||||
|
||||
$resizedImage = Storage::disk('public')->get('posters/example-poster.png');
|
||||
list($width) = getimagesizefromstring($resizedImage);
|
||||
$this->assertEquals(600, $width);
|
||||
|
||||
}
|
||||
}
|
||||
BIN
tests/__fixtures__/full-size-poster.png
Normal file
BIN
tests/__fixtures__/full-size-poster.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 MiB |
Reference in New Issue
Block a user