mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 03:23:19 +00:00
PHRAS-987 1h
PNG-Subdefs (port from 3.8)
This commit is contained in:

committed by
Benoît Burnichon

parent
0109c6c0d2
commit
b6cc58a68e
@@ -66,7 +66,7 @@
|
|||||||
"justinrainbow/json-schema": "~1.3",
|
"justinrainbow/json-schema": "~1.3",
|
||||||
"league/flysystem": "^1.0",
|
"league/flysystem": "^1.0",
|
||||||
"league/flysystem-aws-s3-v2": "^1.0",
|
"league/flysystem-aws-s3-v2": "^1.0",
|
||||||
"media-alchemyst/media-alchemyst": "~0.4",
|
"media-alchemyst/media-alchemyst": "^0.5",
|
||||||
"monolog/monolog": "~1.3",
|
"monolog/monolog": "~1.3",
|
||||||
"mrclay/minify": "~2.1.6",
|
"mrclay/minify": "~2.1.6",
|
||||||
"neutron/process-manager": "2.0.x-dev@dev",
|
"neutron/process-manager": "2.0.x-dev@dev",
|
||||||
|
@@ -151,7 +151,7 @@ class FilesystemService
|
|||||||
{
|
{
|
||||||
switch ($spec->getType()) {
|
switch ($spec->getType()) {
|
||||||
case SpecificationInterface::TYPE_IMAGE:
|
case SpecificationInterface::TYPE_IMAGE:
|
||||||
return 'jpg';
|
return $this->getExtensionFromImageCodec($spec->getImageCodec());
|
||||||
case SpecificationInterface::TYPE_ANIMATION:
|
case SpecificationInterface::TYPE_ANIMATION:
|
||||||
return 'gif';
|
return 'gif';
|
||||||
case SpecificationInterface::TYPE_AUDIO:
|
case SpecificationInterface::TYPE_AUDIO:
|
||||||
@@ -186,6 +186,27 @@ class FilesystemService
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the extension from imageCodec
|
||||||
|
*
|
||||||
|
* @param string $imageCodec
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getExtensionFromImageCodec($imageCodec)
|
||||||
|
{
|
||||||
|
switch ($imageCodec) {
|
||||||
|
case 'tiff':
|
||||||
|
return 'tif';
|
||||||
|
case 'jpeg':
|
||||||
|
return 'jpg';
|
||||||
|
case 'png':
|
||||||
|
return 'png';
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the extension from videocodec
|
* Get the extension from videocodec
|
||||||
*
|
*
|
||||||
|
@@ -21,6 +21,7 @@ class Image extends Provider
|
|||||||
const OPTION_STRIP = 'strip';
|
const OPTION_STRIP = 'strip';
|
||||||
const OPTION_QUALITY = 'quality';
|
const OPTION_QUALITY = 'quality';
|
||||||
const OPTION_FLATTEN = 'flatten';
|
const OPTION_FLATTEN = 'flatten';
|
||||||
|
const OPTION_ICODEC = 'icodec';
|
||||||
|
|
||||||
protected $options = [];
|
protected $options = [];
|
||||||
|
|
||||||
@@ -33,6 +34,7 @@ class Image extends Provider
|
|||||||
$this->registerOption(new OptionType\Boolean($this->translator->trans('Remove ICC Profile'), self::OPTION_STRIP, false));
|
$this->registerOption(new OptionType\Boolean($this->translator->trans('Remove ICC Profile'), self::OPTION_STRIP, false));
|
||||||
$this->registerOption(new OptionType\Boolean($this->translator->trans('Flatten layers'), self::OPTION_FLATTEN, false));
|
$this->registerOption(new OptionType\Boolean($this->translator->trans('Flatten layers'), self::OPTION_FLATTEN, false));
|
||||||
$this->registerOption(new OptionType\Range($this->translator->trans('Quality'), self::OPTION_QUALITY, 0, 100, 75));
|
$this->registerOption(new OptionType\Range($this->translator->trans('Quality'), self::OPTION_QUALITY, 0, 100, 75));
|
||||||
|
$this->registerOption(new OptionType\Enum('Image Codec', self::OPTION_ICODEC, array('jpeg', 'png', 'tiff'), 'jpeg'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getType()
|
public function getType()
|
||||||
@@ -42,7 +44,7 @@ class Image extends Provider
|
|||||||
|
|
||||||
public function getDescription()
|
public function getDescription()
|
||||||
{
|
{
|
||||||
return $this->translator->trans('Generates a Jpeg image');
|
return $this->translator->trans('Generates an image');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMediaAlchemystSpec()
|
public function getMediaAlchemystSpec()
|
||||||
@@ -54,6 +56,7 @@ class Image extends Provider
|
|||||||
$size = $this->getOption(self::OPTION_SIZE)->getValue();
|
$size = $this->getOption(self::OPTION_SIZE)->getValue();
|
||||||
$resolution = $this->getOption(self::OPTION_RESOLUTION)->getValue();
|
$resolution = $this->getOption(self::OPTION_RESOLUTION)->getValue();
|
||||||
|
|
||||||
|
$this->spec->setImageCodec($this->getOption(self::OPTION_ICODEC)->getValue());
|
||||||
$this->spec->setResizeMode(ImageSpecification::RESIZE_MODE_INBOUND_FIXEDRATIO);
|
$this->spec->setResizeMode(ImageSpecification::RESIZE_MODE_INBOUND_FIXEDRATIO);
|
||||||
$this->spec->setDimensions($size, $size);
|
$this->spec->setDimensions($size, $size);
|
||||||
$this->spec->setQuality($this->getOption(self::OPTION_QUALITY)->getValue());
|
$this->spec->setQuality($this->getOption(self::OPTION_QUALITY)->getValue());
|
||||||
|
@@ -107,8 +107,6 @@ class databox_subdef
|
|||||||
$this->subdef_type = $this->buildFlexPaperSubdef($sd);
|
$this->subdef_type = $this->buildFlexPaperSubdef($sd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -289,13 +287,16 @@ class databox_subdef
|
|||||||
/**
|
/**
|
||||||
* Build Image Subdef object depending the SimpleXMLElement
|
* Build Image Subdef object depending the SimpleXMLElement
|
||||||
*
|
*
|
||||||
* @param SimpleXMLElement $sd
|
* @param SimpleXMLElement $sd
|
||||||
* @return \Alchemy\Phrasea\Media\Subdef\Video
|
* @return Image
|
||||||
*/
|
*/
|
||||||
protected function buildImageSubdef(SimpleXMLElement $sd)
|
protected function buildImageSubdef(SimpleXMLElement $sd)
|
||||||
{
|
{
|
||||||
$image = new Image($this->translator);
|
$image = new Image($this->translator);
|
||||||
|
|
||||||
|
if ($sd->icodec) {
|
||||||
|
$image->setOptionValue(Image::OPTION_ICODEC, (string) $sd->icodec);
|
||||||
|
}
|
||||||
if ($sd->size) {
|
if ($sd->size) {
|
||||||
$image->setOptionValue(Image::OPTION_SIZE, (int) $sd->size);
|
$image->setOptionValue(Image::OPTION_SIZE, (int) $sd->size);
|
||||||
}
|
}
|
||||||
@@ -318,8 +319,8 @@ class databox_subdef
|
|||||||
/**
|
/**
|
||||||
* Build Audio Subdef object depending the SimpleXMLElement
|
* Build Audio Subdef object depending the SimpleXMLElement
|
||||||
*
|
*
|
||||||
* @param SimpleXMLElement $sd
|
* @param SimpleXMLElement $sd
|
||||||
* @return \Alchemy\Phrasea\Media\Subdef\Video
|
* @return Audio
|
||||||
*/
|
*/
|
||||||
protected function buildAudioSubdef(SimpleXMLElement $sd)
|
protected function buildAudioSubdef(SimpleXMLElement $sd)
|
||||||
{
|
{
|
||||||
@@ -352,8 +353,8 @@ class databox_subdef
|
|||||||
/**
|
/**
|
||||||
* Build GIF Subdef object depending the SimpleXMLElement
|
* Build GIF Subdef object depending the SimpleXMLElement
|
||||||
*
|
*
|
||||||
* @param SimpleXMLElement $sd
|
* @param SimpleXMLElement $sd
|
||||||
* @return \Alchemy\Phrasea\Media\Subdef\Video
|
* @return Gif
|
||||||
*/
|
*/
|
||||||
protected function buildGifSubdef(SimpleXMLElement $sd)
|
protected function buildGifSubdef(SimpleXMLElement $sd)
|
||||||
{
|
{
|
||||||
@@ -372,8 +373,8 @@ class databox_subdef
|
|||||||
/**
|
/**
|
||||||
* Build Video Subdef object depending the SimpleXMLElement
|
* Build Video Subdef object depending the SimpleXMLElement
|
||||||
*
|
*
|
||||||
* @param SimpleXMLElement $sd
|
* @param SimpleXMLElement $sd
|
||||||
* @return \Alchemy\Phrasea\Media\Subdef\Video
|
* @return Video
|
||||||
*/
|
*/
|
||||||
protected function buildVideoSubdef(SimpleXMLElement $sd)
|
protected function buildVideoSubdef(SimpleXMLElement $sd)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user