# Файл водяного изображения $wmark[/i/watermark.png] # tl Верх-лево # tr Верх-право # br Низ право # bl Низ лево #center - по центру $wmark_position[center] # Общее смещение логотипа от всех краёв # для ручного указания отступа для каждого края # указать 0 или пустое значение $wmark_margin(10) # Персональный учитывается при общем 0 отступе $wmark_margin_top(0) $wmark_margin_right(0) $wmark_margin_bottom(0) $wmark_margin_left(0) # Путь до изображения на сайте $path[$form:path] # Ширина уменьшенного изображения $w[$form:w] # Высота уменбшенного изображения $h[$form:h] # Размещать логотип? # @param 1/0 ^switch[$form:wmark]{ ^case[da]{$wmark_do[da]} ^case[net]{$wmark_do[net]} ^case[DEFAULT]{$wmark_do[net]} } # Проверка на существование файла ^if(-f $path){ # Открывает изображение $big[^image::measure[$path]] ^if((!def $w || $w>=$big.width) && !def $h){ $w($big.width-1) } ^if((!def $h || $h>=$big.height) && !def $w){ $h($big.height-1) } $maxwidth(100) $maxwidth(75) # Если передана ширина и не передана высота ^if(def $w && !def $h){ ^if($w > 1){ $maxwidth($w) $maxheight($maxwidth/$big.width*$big.height) }{ $maxwidth($big.width*$w) $maxheight($big.height*$w) } } # Если передана высота, но не передана ширина ^if(def $h && !def $w){ ^if($h > 1){ $maxheight($h) $maxwidth($maxheight/$big.height*$big.width) }{ $maxheight($big.height*$h) $maxwidth($big.width*$h) } } # Если не передана ни высота ни ширина ^if(def $w && def $h){ ^if($h > 1){ $maxheight($h) }{ $maxheight($big.height*$h) } ^if($w > 1){ $maxheight($w) }{ $maxheight($big.height*$w) } } $maxheight(^math:round($maxheight)) $maxwidth(^math:round($maxwidth)) $temp[^path.match[\w+\.][i']] # # $maxwidth # $maxheight # $path_thumb[/_cache/_thumbs${temp.prematch}^temp.match.mid(0;^temp.match.length[]-1)_${maxwidth}_${maxheight}.$temp.postmatch] $path_thumb2[/_cache/_thumbs${temp.prematch}^temp.match.mid(0;^temp.match.length[]-1)_${maxwidth}__${maxheight}.$temp.postmatch] $path_null[/_cache/_thumbs${temp.prematch}] ^if(!-f "$path_thumb"){ $empt[a] ^empt.save[${path_null}null] ^if(-f $wmark && $wmark_do eq da){ ^if($big.width < '300'){ $wmark[/i/watermark_s.png] } ^if($big.width > '1500'){ $wmark[/i/watermark_b.png] } $logo[^image::measure[$wmark]] ^if(def $wmark_margin){ $wmark_margin_top($wmark_margin) $wmark_margin_right($wmark_margin) $wmark_margin_bottom($wmark_margin) $wmark_margin_left($wmark_margin) } ^switch[$wmark_position]{ ^case[tl]{ $wmark_margin_x($wmark_margin_left) $wmark_margin_y($wmark_margin_top) } ^case[tr]{ $wmark_margin_x($big.width - $logo.width - $wmark_margin_right) $wmark_margin_y($wmark_margin_top) } ^case[br]{ $wmark_margin_x($big.width-$logo.width-$wmark_margin_right) $wmark_margin_y($big.height-$logo.height-$wmark_margin_bottom) } ^case[bl]{ $wmark_margin_x($wmark_margin_left) $wmark_margin_y($big.height - $logo.height - $wmark_margin_bottom) } ^case[center]{ $wmark_margin_x($big.width/2-$logo.width/2) $wmark_margin_y($big.height/2-$logo.height/2) } ^case[DEFAULT]{ $wmark_margin_x($big.width - $logo.width - $wmark_margin_right) $wmark_margin_y($big.height - $logo.height - $wmark_margin_bottom) } } $hParams[ $.iX($wmark_margin_x) $.iY($wmark_margin_y) $.sFormat[jpg] $.iQuality(90) ] ^if(def $form:cropW && def $form:cropH){ ^oImg.crop[$sFileSrc;$sFileDest;$iX;$iY;$iCropWidth;$iCropHeight;$hParams] } ^oImg.watermark[$path;$path_thumb2;$wmark;$hParams] # ресайз1 $maxwidth $maxheight ^oImg.resize[$path_thumb2;$path_thumb;$maxwidth;$maxheight] }{ # ресайз2 $maxwidth $maxheight ^oImg.resize[$path;$path_thumb;$maxwidth;$maxheight] } } ^if(-f $path_thumb){ $response:body[^file::load[binary;$path_thumb]] } }