DevGroup-ru / dotplant2

E-Commerce CMS - Yii Framework 2 (yii2, shop)
http://dotplant.ru/
Other
640 stars 253 forks source link

[enh] add a way to use watermark w/o thumbnail #358

Open Philosoft opened 7 years ago

Philosoft commented 7 years ago

here is my proposal:

<?php

namespace app\modules\image\actions\helpers;

use app\modules\image\models\ThumbnailWatermark;

class ImageHelper
{
    public static function mergeWithWatermark($imageSrc, $watermarkSrc, $watermarkPosition)
    {
        return "/files/" . ThumbnailWatermark::createWatermark(
            (object)["thumb_path" => $imageSrc],
            (object)[
                "watermark_path" => $watermarkSrc,
                "position" => $watermarkPosition
            ]
        );
    }
}

$imageSrc and $watermarkSrc must be path relative to @webroot/files/

Additional ideas:

@fps01 @bethrezen this is a review request