А така..
<?php
$imagesource = $_GET['path'];
$watermarkPath = $_GET['watermark'];
$filetype = substr($imagesource,strlen($imagesource)-4,4);
$filetype = strtolower($filetype);
$watermarkType = substr($watermarkPath,strlen($watermarkPath)-4,4);
$watermarkType =...