Feature #31334

Additional orientation-related functions for Image

Added by Adrian Föder almost 4 years ago. Updated over 3 years ago.

Status:Resolved Start date:2011-10-27
Priority:Could have Due date:
Assigned To:Bastian Waidelich % Done:

100%

Category:-
Target version:-

Description

Hi guys,

I would like to improve the image handling of the TYPO3.Media package; I like it very much so far.

When working on it, I figured out some things that could be improved, I think or hope.

At first I added a few functions to the Image class, could be backed also into the interface (see attached patches).

In general, I would suggest a bit another approach of the ImageVariant: at first I say it should be extended from Image, because an image variant mostly has the properties of an Image (which is inherently correct :)

This ImageVariant class then has only an additional property $originalImage which is set during construction. All other properties and methods are interited anyway, and that's correct.

Then I say an Image Variant should not be "created" or "transformed" during creation (i.e. within the constructor), but be more a "base" for working on an image variant. So I would suggest something like this (pseudo-code):

class ImageVariant extends Image {
    /**
     * @var \TYPO3\Media\Domain\Model\Image
     */
    protected $originalImage;

    /**
     * @param Image $baseImage The Image that image variant is based on
     */
    public function __construct(\TYPO3\Media\Domain\Model\Image $baseImage) {
        $this->originalImage = $baseImage;
        $this->width = $baseImage->getWidth();
        $this->height = $baseImage->getHeight();
    }

and than one could do the following:

$myThumbnail = new ImageVariant();
$myThumbnail->setWidth(180)->preserveAspectRatio(true)->cropToSquare()->getResource();

each mentioned function is set in the ImageVariant and returns $this itself. Also each function just modyfies private properties; and with e.g. getResource() or any other 'build()' function (even __toString() is possible) the image is finally built.

What do you think?

0001-Related-31334.patch Magnifier (4 kB) Adrian Föder, 2011-10-27 10:54

Associated revisions

Revision 94273784
Added by Adrian Föder over 3 years ago

[FEATURE] Additional orientation-related functions for Image

Providing functions to get information about the orientation of the image.

Change-Id: I26f8dcf8d0abc9051f63185853b503fed7dd0ab7
Related: #31334

History

#2 Updated by Adrian Föder over 3 years ago

#3 Updated by Bastian Waidelich over 3 years ago

  • Subject changed from Making ImageVariant more object orientated to Additional orientation-related functions for Image
  • Status changed from New to Resolved
  • Assigned To set to Bastian Waidelich
  • % Done changed from 0 to 100

Also available in: Atom PDF