$errors['watermark']['opacity'] = '(0..100]';
}
// step 3 - save data
if (count($errors) == 0) {
    $watermark = new WatermarkParams();
    $watermark->file = $pwatermark['file'];
    $watermark->xpos = intval($pwatermark['xpos']);
    $watermark->ypos = intval($pwatermark['ypos']);
    $watermark->xrepeat = intval($pwatermark['xrepeat']);
    $watermark->yrepeat = intval($pwatermark['yrepeat']);
    $watermark->opacity = intval($pwatermark['opacity']);
    $watermark->min_size = array(intval($pwatermark['minw']), intval($pwatermark['minh']));
    $old_watermark = ImageStdParams::get_watermark();
    $watermark_changed = $watermark->file != $old_watermark->file || $watermark->xpos != $old_watermark->xpos || $watermark->ypos != $old_watermark->ypos || $watermark->xrepeat != $old_watermark->xrepeat || $watermark->yrepeat != $old_watermark->yrepeat || $watermark->opacity != $old_watermark->opacity;
    // save the new watermark configuration
    ImageStdParams::set_watermark($watermark);
    // do we have to regenerate the derivatives (and which types)?
    $changed_types = array();
    foreach (ImageStdParams::get_defined_type_map() as $type => $params) {
        $old_use_watermark = $params->use_watermark;
        ImageStdParams::apply_global($params);
        $changed = $params->use_watermark != $old_use_watermark;
        if (!$changed and $params->use_watermark) {
            $changed = $watermark_changed;
        }
        if (!$changed and $params->use_watermark) {
            // if thresholds change and before/after the threshold is lower than the corresponding derivative side -> some derivatives might switch the watermark
            $changed |= $watermark->min_size[0] != $old_watermark->min_size[0] and ($watermark->min_size[0] < $params->max_width() or $old_watermark->min_size[0] < $params->max_width());
            $changed |= $watermark->min_size[1] != $old_watermark->min_size[1] and ($watermark->min_size[1] < $params->max_height() or $old_watermark->min_size[1] < $params->max_height());
        }
        if ($changed) {