/**
 * Branded ein Bild mit einem Wasserzeichen
 *
 * Der Filter sucht im Verzeichnis addons/image_resize/media/
 * nach einem Bild mit dem Dateinamen "brand.*" und verwendet den 1. Treffer
 */
function image_resize_brand(&$src_im)
{
    global $REX;
    $files = glob($REX['INCLUDE_PATH'] . '/addons/image_resize/media/brand.*');
    $brandImage = $files[0];
    $brand = new rex_thumbnail($brandImage);
    // -------------------------------------- CONFIG
    // Abstand vom Rand
    $paddX = -10;
    $paddY = -10;
    // horizontale ausrichtung: left/center/right
    $hpos = 'right';
    // vertikale ausrichtung:   top/center/bottom
    $vpos = 'bottom';
    // -------------------------------------- /CONFIG
    switch ($hpos) {
        case 'left':
            $dstX = 0;
            break;
        case 'center':
            $dstX = (int) ((imagesx($src_im) - $brand->getImageWidth()) / 2);
            break;
        case 'right':
            $dstX = imagesx($src_im) - $brand->getImageWidth();
            break;
        default:
            trigger_error('Unexpected value for "hpos"!', E_USER_ERROR);
    }
    switch ($vpos) {
        case 'top':
            $dstY = 0;
            break;
        case 'center':
            $dstY = (int) ((imagesy($src_im) - $brand->getImageHeight()) / 2);
            break;
        case 'bottom':
            $dstY = imagesy($src_im) - $brand->getImageHeight();
            break;
        default:
            trigger_error('Unexpected value for "vpos"!', E_USER_ERROR);
    }
    imagealphablending($src_im, true);
    imagecopy($src_im, $brand->getImage(), $dstX + $paddX, $dstY + $paddY, 0, 0, $brand->getImageWidth(), $brand->getImageHeight());
    $brand->destroyImage();
}
/**
 * Branded ein Bild mit einem Wasserzeichen
 *
 * Der Filter sucht im Verzeichnis addons/image_resize/media/
 * nach einem Bild mit dem Dateinamen "brand.*" und verwendet den 1. Treffer
 */
function image_resize_brand(&$src_im)
{
    global $REX;
    $files = glob($REX['INCLUDE_PATH'] . '/addons/image_resize/media/brand.*');
    $brandImage = $files[0];
    $brand = new rex_thumbnail($brandImage);
    $paddX = 10;
    $paddY = 10;
    imagealphablending($src_im, true);
    imagecopy($src_im, $brand->getImage(), imagesx($src_im) - $brand->getImageWidth() - $paddX, imagesy($src_im) - $brand->getImageHeight() - $paddY, 0, 0, $brand->getImageWidth(), $brand->getImageHeight());
    $brand->destroyImage();
}
 function rex_image_ep_mediaupdated($params)
 {
     rex_thumbnail::deleteCache($params["filename"]);
 }
<?php

/**
 * Image-Resize Addon
 *
 * @author office[at]vscope[dot]at Wolfgang Hutteger
 * @author markus.staab[at]redaxo[dot]de Markus Staab
 * @author jan.kristinus[at]yakmara[dot]de Jan Kristinus
 *
 * @package redaxo4
 * @version $Id: index.inc.php,v 1.6 2008/03/20 18:13:13 kills Exp $
 */
require $REX['INCLUDE_PATH'] . '/layout/top.php';
if (isset($subpage) and $subpage == 'clear_cache') {
    $c = rex_thumbnail::deleteCache();
    $msg = 'Cache cleared - ' . $c . ' cachefiles removed';
}
// Build Subnavigation
$subpages = array(array('', 'Erkl&auml;rung'), array('settings', 'Konfiguration'), array('clear_cache', 'Resize Cache l&ouml;schen'));
rex_title('Image Resize', $subpages);
// Include Current Page
switch ($subpage) {
    case 'settings':
        break;
    default:
        if (isset($msg) and $msg != '') {
            echo rex_warning($msg);
        }
        $subpage = 'overview';
}
require $REX['INCLUDE_PATH'] . '/addons/image_resize/pages/' . $subpage . '.inc.php';
 function createFromUrl($rex_resize)
 {
     global $REX;
     // Loesche alle Ausgaben zuvor
     while (ob_get_level()) {
         ob_end_clean();
     }
     // get params
     preg_match('@([0-9]*)([awhc])__(([0-9]*)h__)?((\\-?[0-9]*)o__)?(.*)@', $rex_resize, $resize);
     $size = $resize[1];
     $mode = $resize[2];
     $height = $resize[4];
     $offset = $resize[6];
     $imagefile = $resize[7];
     $rex_filter = rex_get('rex_filter', 'array');
     if (count($rex_filter) > $REX['ADDON']['image_resize']['max_filters']) {
         $rex_filter = array();
     }
     $filters = '';
     foreach ($rex_filter as $filter) {
         $filters .= $filter;
     }
     if ($filters != '') {
         $filters = md5($filters);
     }
     $cachepath = $REX['INCLUDE_PATH'] . '/generated/files/image_resize__' . $filters . $rex_resize;
     $imagepath = $REX['HTDOCS_PATH'] . 'files/' . $imagefile;
     // ----- check for cache file
     if (file_exists($cachepath)) {
         // time of cache
         $cachetime = filectime($cachepath);
         // file exists?
         if (file_exists($imagepath)) {
             $filetime = filectime($imagepath);
         } else {
             // image file not exists
             print 'Error: Imagefile does not exist - ' . $imagefile;
             exit;
         }
         // cache is newer? - show cache
         if ($cachetime > $filetime) {
             $thumb = new rex_thumbnail($cachepath);
             $thumb->send($cachepath, $cachetime);
             exit;
         }
     }
     // ----- check params
     if (!file_exists($imagepath)) {
         print 'Error: Imagefile does not exist - ' . $imagefile;
         exit;
     }
     // ----- check filesize
     $max_file_size = $REX['ADDON']['image_resize']['max_resizekb'] * 1024;
     if (filesize($imagepath) > $max_file_size) {
         print 'Error: Imagefile is to big. Only files < ' . $REX['ADDON']['image_resize']['max_resizekb'] . 'kb are allowed. - ' . $imagefile;
         exit;
     }
     // ----- check mode
     if ($mode != 'w' && $mode != 'h' && $mode != 'a' && $mode != 'c') {
         print 'Error wrong mode - only h,w,a,c';
         exit;
     }
     if ($size == '') {
         print 'Error size is no INTEGER';
         exit;
     }
     if ($size > $REX['ADDON']['image_resize']['max_resizepixel'] || $height > $REX['ADDON']['image_resize']['max_resizepixel']) {
         print 'Error size to big: max ' . $REX['ADDON']['image_resize']['max_resizepixel'] . ' px';
         exit;
     }
     // ----- start thumb class
     $thumb = new rex_thumbnail($imagepath);
     $thumb->img_filename = $imagefile;
     $thumb->img_cachepath = $REX['INCLUDE_PATH'] . '/generated/files/';
     // check method
     if ($mode == 'w') {
         $thumb->size_width($size);
     }
     if ($mode == 'h') {
         $thumb->size_height($size);
     }
     if ($mode == 'c') {
         $thumb->size_crop($size, $height, $offset);
     } elseif ($height != '') {
         $thumb->size_height($height);
     }
     if ($mode == 'a') {
         $thumb->size_auto($size);
     }
     // Add Default Filters
     $rex_filter = array_merge($rex_filter, $REX['ADDON']['image_resize']['default_filters']);
     // Add Filters
     foreach ($rex_filter as $filter) {
         $thumb->addFilter($filter);
     }
     // save cache
     $thumb->generateImage($cachepath);
     exit;
 }