Skip to content

Commit

Permalink
Merge branch '3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
crynobone committed Aug 21, 2015
2 parents 6535239 + eb53824 commit cf6c89d
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 26 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Here a simple example how to create a thumbnail from an image:

use Imagine\Image\Box;
use Imagine\Image\ImageInterface;
use Orchestra\Imagine\Facade as Imagine;

function create_thumbnail($path, $filename, $extension)
{
Expand Down
6 changes: 6 additions & 0 deletions docs/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ title: Imagine Change Log
---
## Version 3.1 {#v3-1}

### v3.1.1 {#v3-1-1}

* Improved performances by reducing call within `Illuminate\Container\Container`.
* Create dispatchable job that you can use to create image thumbnail via `Orchestra\Imagine\Jobs\CreateThumbnail`.
* Create dispatchable job that you can use to resize an image via `Orchestra\Imagine\Jobs\ResizeImage`.

### v3.1.0 {#v3-1-0}

* Update support to Laravel Framework v5.1.
Expand Down
2 changes: 1 addition & 1 deletion src/ImagineServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ protected function bootUsingLaravel($path)
*/
public function provides()
{
return ['orchestra.imagine'];
return ['orchestra.imagine', ImagineInterface::class];
}
}
2 changes: 1 addition & 1 deletion src/Jobs/CreateThumbnail.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected function getDefaultOptions()
return [
'dimension' => 200,
'filter' => ImageInterface::FILTER_UNDEFINED,
'format' => '{filename}.{width}x{height}.{extension}',
'format' => '{filename}.thumb.{extension}',
'mode' => ImageInterface::THUMBNAIL_OUTBOUND,
];
}
Expand Down
33 changes: 26 additions & 7 deletions src/Jobs/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,44 @@
use Orchestra\Support\Str;
use Illuminate\Support\Arr;
use Imagine\Image\ImageInterface;
use Imagine\Image\ImagineInterface;
use Illuminate\Contracts\Bus\SelfHandling;

abstract class Generator extends Job implements SelfHandling
{
/**
* Execute the job.
* Generator options.
*
* @var array
*/
protected $options = [];

/**
* Construct a new Job.
*
* @param array $options
*/
public function __construct(array $options)
{
$this->options = $options;
}

/**
* Execute the job.
*
* @param \Imagine\Image\ImagineInterface $imagine
*
* @return void
*/
public function handle(array $options)
public function handle(ImagineInterface $imagine)
{
$data = $this->getFilteredOptions($options);
$path = $data['path'];
$data = $this->getFilteredOptions($this->options);
$path = $data['path'];

$source = Str::replace('{filename}.{extension}', $data);
$destination = Str::replace($format, $data);
$destination = Str::replace($data['format'], $data);

$image = $this->imagine->open("{$path}/{$source}");
$image = $imagine->open("{$path}/{$source}");

$this->handleImageManipulation($image, $data);

Expand All @@ -45,7 +64,7 @@ protected function getFilteredOptions(array $options)
'filename',
'extension',
'format',
], array_keys($default));
], array_keys($default)));

$data = Arr::only($options, $uses);

Expand Down
17 changes: 0 additions & 17 deletions src/Jobs/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,4 @@ abstract class Job
*/

use Queueable;

/**
* The image manipulation implementation.
*
* @var \Imagine\Image\ImageInterface
*/
protected $imagine;

/**
* Construct a new Job.
*
* @param \Imagine\Image\ImageInterface $imagine
*/
public function __construct(ImageInterface $imagine)
{
$this->imagine = $imagine;
}
}

0 comments on commit cf6c89d

Please sign in to comment.