charger une image
This commit is contained in:
25
upLoadImage/vendor/intervention/image/src/Encoders/AutoEncoder.php
vendored
Normal file
25
upLoadImage/vendor/intervention/image/src/Encoders/AutoEncoder.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Image\Encoders;
|
||||
|
||||
use Intervention\Image\Interfaces\EncodedImageInterface;
|
||||
use Intervention\Image\Interfaces\ImageInterface;
|
||||
|
||||
class AutoEncoder extends MediaTypeEncoder
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see EncoderInterface::encode()
|
||||
*/
|
||||
public function encode(ImageInterface $image): EncodedImageInterface
|
||||
{
|
||||
return $image->encode(
|
||||
$this->encoderByMediaType(
|
||||
$image->origin()->mediaType()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
23
upLoadImage/vendor/intervention/image/src/Encoders/AvifEncoder.php
vendored
Normal file
23
upLoadImage/vendor/intervention/image/src/Encoders/AvifEncoder.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Image\Encoders;
|
||||
|
||||
use Intervention\Image\Drivers\SpecializableEncoder;
|
||||
|
||||
class AvifEncoder extends SpecializableEncoder
|
||||
{
|
||||
/**
|
||||
* Create new encoder object
|
||||
*
|
||||
* @param null|bool $strip Strip EXIF metadata
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
public int $quality = self::DEFAULT_QUALITY,
|
||||
public ?bool $strip = null
|
||||
) {
|
||||
//
|
||||
}
|
||||
}
|
||||
15
upLoadImage/vendor/intervention/image/src/Encoders/BmpEncoder.php
vendored
Normal file
15
upLoadImage/vendor/intervention/image/src/Encoders/BmpEncoder.php
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Image\Encoders;
|
||||
|
||||
use Intervention\Image\Drivers\SpecializableEncoder;
|
||||
|
||||
class BmpEncoder extends SpecializableEncoder
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
69
upLoadImage/vendor/intervention/image/src/Encoders/FileExtensionEncoder.php
vendored
Normal file
69
upLoadImage/vendor/intervention/image/src/Encoders/FileExtensionEncoder.php
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Image\Encoders;
|
||||
|
||||
use Error;
|
||||
use Intervention\Image\Exceptions\EncoderException;
|
||||
use Intervention\Image\FileExtension;
|
||||
use Intervention\Image\Interfaces\EncodedImageInterface;
|
||||
use Intervention\Image\Interfaces\EncoderInterface;
|
||||
use Intervention\Image\Interfaces\ImageInterface;
|
||||
|
||||
class FileExtensionEncoder extends AutoEncoder
|
||||
{
|
||||
/**
|
||||
* Encoder options
|
||||
*
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
protected array $options = [];
|
||||
|
||||
/**
|
||||
* Create new encoder instance to encode to format of given file extension
|
||||
*
|
||||
* @param null|string|FileExtension $extension Target file extension for example "png"
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(public null|string|FileExtension $extension = null, mixed ...$options)
|
||||
{
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see EncoderInterface::encode()
|
||||
*/
|
||||
public function encode(ImageInterface $image): EncodedImageInterface
|
||||
{
|
||||
$extension = is_null($this->extension) ? $image->origin()->fileExtension() : $this->extension;
|
||||
|
||||
return $image->encode(
|
||||
$this->encoderByFileExtension(
|
||||
$extension
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create matching encoder for given file extension
|
||||
*
|
||||
* @throws EncoderException
|
||||
*/
|
||||
protected function encoderByFileExtension(null|string|FileExtension $extension): EncoderInterface
|
||||
{
|
||||
if (empty($extension)) {
|
||||
throw new EncoderException('No encoder found for empty file extension.');
|
||||
}
|
||||
|
||||
try {
|
||||
$extension = is_string($extension) ? FileExtension::from(strtolower($extension)) : $extension;
|
||||
} catch (Error) {
|
||||
throw new EncoderException('No encoder found for file extension (' . $extension . ').');
|
||||
}
|
||||
|
||||
return $extension->format()->encoder(...$this->options);
|
||||
}
|
||||
}
|
||||
38
upLoadImage/vendor/intervention/image/src/Encoders/FilePathEncoder.php
vendored
Normal file
38
upLoadImage/vendor/intervention/image/src/Encoders/FilePathEncoder.php
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Image\Encoders;
|
||||
|
||||
use Intervention\Image\Interfaces\ImageInterface;
|
||||
use Intervention\Image\Interfaces\EncodedImageInterface;
|
||||
|
||||
class FilePathEncoder extends FileExtensionEncoder
|
||||
{
|
||||
/**
|
||||
* Create new encoder instance to encode to format of file extension in given path
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(protected ?string $path = null, mixed ...$options)
|
||||
{
|
||||
parent::__construct(
|
||||
is_null($path) ? $path : pathinfo($path, PATHINFO_EXTENSION),
|
||||
...$options
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see EncoderInterface::encode()
|
||||
*/
|
||||
public function encode(ImageInterface $image): EncodedImageInterface
|
||||
{
|
||||
return $image->encode(
|
||||
$this->encoderByFileExtension(
|
||||
is_null($this->path) ? $image->origin()->fileExtension() : pathinfo($this->path, PATHINFO_EXTENSION)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
20
upLoadImage/vendor/intervention/image/src/Encoders/GifEncoder.php
vendored
Normal file
20
upLoadImage/vendor/intervention/image/src/Encoders/GifEncoder.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Image\Encoders;
|
||||
|
||||
use Intervention\Image\Drivers\SpecializableEncoder;
|
||||
|
||||
class GifEncoder extends SpecializableEncoder
|
||||
{
|
||||
/**
|
||||
* Create new encoder object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(public bool $interlaced = false)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
23
upLoadImage/vendor/intervention/image/src/Encoders/HeicEncoder.php
vendored
Normal file
23
upLoadImage/vendor/intervention/image/src/Encoders/HeicEncoder.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Image\Encoders;
|
||||
|
||||
use Intervention\Image\Drivers\SpecializableEncoder;
|
||||
|
||||
class HeicEncoder extends SpecializableEncoder
|
||||
{
|
||||
/**
|
||||
* Create new encoder object
|
||||
*
|
||||
* @param null|bool $strip Strip EXIF metadata
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
public int $quality = self::DEFAULT_QUALITY,
|
||||
public ?bool $strip = null
|
||||
) {
|
||||
//
|
||||
}
|
||||
}
|
||||
23
upLoadImage/vendor/intervention/image/src/Encoders/Jpeg2000Encoder.php
vendored
Normal file
23
upLoadImage/vendor/intervention/image/src/Encoders/Jpeg2000Encoder.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Image\Encoders;
|
||||
|
||||
use Intervention\Image\Drivers\SpecializableEncoder;
|
||||
|
||||
class Jpeg2000Encoder extends SpecializableEncoder
|
||||
{
|
||||
/**
|
||||
* Create new encoder object
|
||||
*
|
||||
* @param null|bool $strip Strip EXIF metadata
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
public int $quality = self::DEFAULT_QUALITY,
|
||||
public ?bool $strip = null
|
||||
) {
|
||||
//
|
||||
}
|
||||
}
|
||||
24
upLoadImage/vendor/intervention/image/src/Encoders/JpegEncoder.php
vendored
Normal file
24
upLoadImage/vendor/intervention/image/src/Encoders/JpegEncoder.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Image\Encoders;
|
||||
|
||||
use Intervention\Image\Drivers\SpecializableEncoder;
|
||||
|
||||
class JpegEncoder extends SpecializableEncoder
|
||||
{
|
||||
/**
|
||||
* Create new encoder object
|
||||
*
|
||||
* @param null|bool $strip Strip EXIF metadata
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
public int $quality = self::DEFAULT_QUALITY,
|
||||
public bool $progressive = false,
|
||||
public ?bool $strip = null
|
||||
) {
|
||||
//
|
||||
}
|
||||
}
|
||||
64
upLoadImage/vendor/intervention/image/src/Encoders/MediaTypeEncoder.php
vendored
Normal file
64
upLoadImage/vendor/intervention/image/src/Encoders/MediaTypeEncoder.php
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Image\Encoders;
|
||||
|
||||
use Error;
|
||||
use Intervention\Image\Drivers\AbstractEncoder;
|
||||
use Intervention\Image\Exceptions\EncoderException;
|
||||
use Intervention\Image\Interfaces\EncodedImageInterface;
|
||||
use Intervention\Image\Interfaces\EncoderInterface;
|
||||
use Intervention\Image\Interfaces\ImageInterface;
|
||||
use Intervention\Image\MediaType;
|
||||
|
||||
class MediaTypeEncoder extends AbstractEncoder
|
||||
{
|
||||
/**
|
||||
* Encoder options
|
||||
*
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
protected array $options = [];
|
||||
|
||||
/**
|
||||
* Create new encoder instance
|
||||
*
|
||||
* @param null|string|MediaType $mediaType Target media type for example "image/jpeg"
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(public null|string|MediaType $mediaType = null, mixed ...$options)
|
||||
{
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see EncoderInterface::encode()
|
||||
*/
|
||||
public function encode(ImageInterface $image): EncodedImageInterface
|
||||
{
|
||||
$mediaType = is_null($this->mediaType) ? $image->origin()->mediaType() : $this->mediaType;
|
||||
|
||||
return $image->encode(
|
||||
$this->encoderByMediaType($mediaType)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return new encoder by given media (MIME) type
|
||||
*
|
||||
* @throws EncoderException
|
||||
*/
|
||||
protected function encoderByMediaType(string|MediaType $mediaType): EncoderInterface
|
||||
{
|
||||
try {
|
||||
$mediaType = is_string($mediaType) ? MediaType::from($mediaType) : $mediaType;
|
||||
} catch (Error) {
|
||||
throw new EncoderException('No encoder found for media type (' . $mediaType . ').');
|
||||
}
|
||||
|
||||
return $mediaType->format()->encoder(...$this->options);
|
||||
}
|
||||
}
|
||||
20
upLoadImage/vendor/intervention/image/src/Encoders/PngEncoder.php
vendored
Normal file
20
upLoadImage/vendor/intervention/image/src/Encoders/PngEncoder.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Image\Encoders;
|
||||
|
||||
use Intervention\Image\Drivers\SpecializableEncoder;
|
||||
|
||||
class PngEncoder extends SpecializableEncoder
|
||||
{
|
||||
/**
|
||||
* Create new encoder object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(public bool $interlaced = false, public bool $indexed = false)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
23
upLoadImage/vendor/intervention/image/src/Encoders/TiffEncoder.php
vendored
Normal file
23
upLoadImage/vendor/intervention/image/src/Encoders/TiffEncoder.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Image\Encoders;
|
||||
|
||||
use Intervention\Image\Drivers\SpecializableEncoder;
|
||||
|
||||
class TiffEncoder extends SpecializableEncoder
|
||||
{
|
||||
/**
|
||||
* Create new encoder object
|
||||
*
|
||||
* @param null|bool $strip Strip EXIF metadata
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
public int $quality = self::DEFAULT_QUALITY,
|
||||
public ?bool $strip = null
|
||||
) {
|
||||
//
|
||||
}
|
||||
}
|
||||
23
upLoadImage/vendor/intervention/image/src/Encoders/WebpEncoder.php
vendored
Normal file
23
upLoadImage/vendor/intervention/image/src/Encoders/WebpEncoder.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Image\Encoders;
|
||||
|
||||
use Intervention\Image\Drivers\SpecializableEncoder;
|
||||
|
||||
class WebpEncoder extends SpecializableEncoder
|
||||
{
|
||||
/**
|
||||
* Create new encoder object
|
||||
*
|
||||
* @param null|bool $strip Strip EXIF metadata
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
public int $quality = self::DEFAULT_QUALITY,
|
||||
public ?bool $strip = null
|
||||
) {
|
||||
//
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user