contao/core — pull request #7383 by ausi (2014-10-19 11:33:12+00:00)
Title: [3.4-dev] Restructure image class

As discussed in #7351

I’ve split the image class into three classes `Image`, `GdImage` and `Picture`. Usage:

```php
$image = \Image::create('example.jpg', array(100, 100, 'top_left'));
// OR
$image = \Image::create(new \File(…), 1);
$src = $image->executeResize()->getResizedPath();

$picture = Picture::create('example.jpg', array(100, 100, 'top_left'));
// OR
$picture = Picture::create(new \File(…), 1);
$data = $picture->getData();

$source = GdImage::fromFile(new \File(…));
$target = GdImage::fromDimensions(100, 100);
$source->copyTo($target, 0, 0, 100, 100);
$target->convertToPaletteImage()->saveToFile('image.jpg');
```

### Questions:

Is there a better name for `Picture::getData()`?

---

How should `Controller::addImageToTemplate()` behave if `$arrItem['singleSRC']` is empty, doesn’t exist or isn’t a valid image type.

Behavior in Contao 3.3.5:

* Emtpy `singleSRC`: Sets `src` to an empty string
* Image doesn’t exist: Sets `src` to an empty string and prints a Warning: getimagesize(...): failed to open stream
* Invalid image type: Sets `src` to an empty string

Behavior now:

* Emtpy `singleSRC`: Uncaught exception Directory "" is not a file
* Image doesn’t exist: Uncaught InvalidArgumentException Image "..." could not be found
* Invalid image type: Uncaught InvalidArgumentException Image type "..." was not allowed to be processed

Should we preserve the behavior of Contao 3.3.5?

---

Do we need [`rawurldecode($image)`](https://github.com/contao/core/blob/97b82b7e2d091eda70c40d332fe4c2b4c534ac96/system/modules/core/library/Contao/Image.php#L1252)? If so, we should use it consistent, e. g. in [system/modules/core/library/Contao/Controller.php:2515](https://github.com/contao/core/blob/97b82b7e2d091eda70c40d332fe4c2b4c534ac96/system/modules/core/library/Contao/Controller.php#L2515).