-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b12f31e
commit 04faec2
Showing
6 changed files
with
104 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Intervention\Image\Encoders; | ||
|
||
use Intervention\Image\Interfaces\EncodedImageInterface; | ||
use Intervention\Image\Interfaces\ImageInterface; | ||
|
||
class MediaTypeEncoder extends AutoEncoder | ||
{ | ||
/** | ||
* Create new encoder instance to encode given media (mime) type | ||
* | ||
* @param null|string $type | ||
* @return void | ||
*/ | ||
public function __construct(protected ?string $type = null) | ||
{ | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @see EncoderInterface::encode() | ||
*/ | ||
public function encode(ImageInterface $image): EncodedImageInterface | ||
{ | ||
return $image->encode( | ||
$this->encoderByMediaType( | ||
is_null($this->type) ? $image->origin()->mediaType() : $this->type | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters