diff --git a/lib/Alchemy/Phrasea/Media/Subdef/Subdef.php b/lib/Alchemy/Phrasea/Media/Subdef/Subdef.php index db42b01c84..339d50002f 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/Subdef.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/Subdef.php @@ -20,6 +20,7 @@ interface Subdef const TYPE_VIDEO = 'video'; const TYPE_AUDIO = 'audio'; const TYPE_FLEXPAPER = 'flexpaper'; + const TYPE_UNKNOWN = 'unknown'; /** * One of Subdef Type const diff --git a/lib/Alchemy/Phrasea/Media/Subdef/Unknown.php b/lib/Alchemy/Phrasea/Media/Subdef/Unknown.php new file mode 100644 index 0000000000..4a19f4b3d0 --- /dev/null +++ b/lib/Alchemy/Phrasea/Media/Subdef/Unknown.php @@ -0,0 +1,69 @@ +translator = $translator; + + $this->registerOption(new OptionType\Range($this->translator->trans('Dimension'), self::OPTION_SIZE, 20, 3000, 800)); + $this->registerOption(new OptionType\Range($this->translator->trans('Resolution'), self::OPTION_RESOLUTION, 50, 300, 72)); + $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\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() + { + return self::TYPE_IMAGE; + } + + public function getDescription() + { + return $this->translator->trans('Generates an image'); + } + + public function getMediaAlchemystSpec() + { + if (! $this->spec) { + $this->spec = new ImageSpecification(); + } + + $size = $this->getOption(self::OPTION_SIZE)->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->setDimensions($size, $size); + $this->spec->setQuality($this->getOption(self::OPTION_QUALITY)->getValue()); + $this->spec->setStrip($this->getOption(self::OPTION_STRIP)->getValue()); + $this->spec->setFlatten($this->getOption(self::OPTION_FLATTEN)->getValue()); + $this->spec->setResolution($resolution, $resolution); + + return $this->spec; + } +} diff --git a/lib/classes/databox/subdef.php b/lib/classes/databox/subdef.php index e64ca7fb08..94f6f546a4 100644 --- a/lib/classes/databox/subdef.php +++ b/lib/classes/databox/subdef.php @@ -14,6 +14,7 @@ use Alchemy\Phrasea\Media\Subdef\Audio; use Alchemy\Phrasea\Media\Subdef\Video; use Alchemy\Phrasea\Media\Subdef\FlexPaper; use Alchemy\Phrasea\Media\Subdef\Gif; +use Alchemy\Phrasea\Media\Subdef\Unknown; use Alchemy\Phrasea\Media\Subdef\Subdef as SubdefSpecs; use Alchemy\Phrasea\Media\Type\Type as SubdefType; use MediaAlchemyst\Specification\SpecificationInterface; @@ -46,6 +47,7 @@ class databox_subdef SubdefType::TYPE_FLASH => [SubdefSpecs::TYPE_IMAGE], SubdefType::TYPE_IMAGE => [SubdefSpecs::TYPE_IMAGE], SubdefType::TYPE_VIDEO => [SubdefSpecs::TYPE_IMAGE, SubdefSpecs::TYPE_VIDEO, SubdefSpecs::TYPE_ANIMATION], + SubdefType::TYPE_UNKNOWN => [SubdefSpecs::TYPE_IMAGE], ]; const CLASS_THUMBNAIL = 'thumbnail'; @@ -106,6 +108,9 @@ class databox_subdef case SubdefSpecs::TYPE_FLEXPAPER: $this->subdef_type = $this->buildFlexPaperSubdef($sd); break; + case SubdefSpecs::TYPE_UNKNOWN: + $this->subdef_type = $this->buildImageSubdef($sd); + break; } } @@ -229,6 +234,9 @@ class databox_subdef case SubdefSpecs::TYPE_VIDEO: $mediatype_obj = new Video($this->translator); break; + case SubdefSpecs::TYPE_UNKNOWN: + $mediatype_obj = new Unknown($this->translator); + break; default: continue; break;