Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wp-file-.../lib/php/plugins/Watermar...
File: plugin.php
<?php
[0] Fix | Delete
[1] Fix | Delete
/**
[2] Fix | Delete
* elFinder Plugin Watermark
[3] Fix | Delete
* Print watermark on file upload.
[4] Fix | Delete
* ex. binding, configure on connector options
[5] Fix | Delete
* $opts = array(
[6] Fix | Delete
* 'bind' => array(
[7] Fix | Delete
* 'upload.presave' => array(
[8] Fix | Delete
* 'Plugin.Watermark.onUpLoadPreSave'
[9] Fix | Delete
* )
[10] Fix | Delete
* ),
[11] Fix | Delete
* // global configure (optional)
[12] Fix | Delete
* 'plugin' => array(
[13] Fix | Delete
* 'Watermark' => array(
[14] Fix | Delete
* 'enable' => true, // For control by volume driver
[15] Fix | Delete
* 'source' => 'logo.png', // Path to Water mark image
[16] Fix | Delete
* 'ratio' => 0.2, // Ratio to original image (ratio > 0 and ratio <= 1)
[17] Fix | Delete
* 'position' => 'RB', // Position L(eft)/C(enter)/R(ight) and T(op)/M(edium)/B(ottom)
[18] Fix | Delete
* 'marginX' => 5, // Margin horizontal pixel
[19] Fix | Delete
* 'marginY' => 5, // Margin vertical pixel
[20] Fix | Delete
* 'quality' => 95, // JPEG image save quality
[21] Fix | Delete
* 'transparency' => 70, // Water mark image transparency ( other than PNG )
[22] Fix | Delete
* 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field )
[23] Fix | Delete
* 'targetMinPixel' => 200, // Target image minimum pixel size
[24] Fix | Delete
* 'interlace' => IMG_GIF|IMG_JPG, // Set interlacebit image formats ( bit-field )
[25] Fix | Delete
* 'offDropWith' => null, // Enabled by default. To disable it if it is dropped with pressing the meta key
[26] Fix | Delete
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
[27] Fix | Delete
* // In case of using any key, specify it as an array
[28] Fix | Delete
* 'onDropWith' => null // Disabled by default. To enable it if it is dropped with pressing the meta key
[29] Fix | Delete
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
[30] Fix | Delete
* // In case of using any key, specify it as an array
[31] Fix | Delete
* )
[32] Fix | Delete
* ),
[33] Fix | Delete
* // each volume configure (optional)
[34] Fix | Delete
* 'roots' => array(
[35] Fix | Delete
* array(
[36] Fix | Delete
* 'driver' => 'LocalFileSystem',
[37] Fix | Delete
* 'path' => '/path/to/files/',
[38] Fix | Delete
* 'URL' => 'http://localhost/to/files/'
[39] Fix | Delete
* 'plugin' => array(
[40] Fix | Delete
* 'Watermark' => array(
[41] Fix | Delete
* 'enable' => true, // For control by volume driver
[42] Fix | Delete
* 'source' => 'logo.png', // Path to Water mark image
[43] Fix | Delete
* 'ratio' => 0.2, // Ratio to original image (ratio > 0 and ratio <= 1)
[44] Fix | Delete
* 'position' => 'RB', // Position L(eft)/C(enter)/R(ight) and T(op)/M(edium)/B(ottom)
[45] Fix | Delete
* 'marginX' => 5, // Margin horizontal pixel
[46] Fix | Delete
* 'marginY' => 5, // Margin vertical pixel
[47] Fix | Delete
* 'quality' => 95, // JPEG image save quality
[48] Fix | Delete
* 'transparency' => 70, // Water mark image transparency ( other than PNG )
[49] Fix | Delete
* 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field )
[50] Fix | Delete
* 'targetMinPixel' => 200, // Target image minimum pixel size
[51] Fix | Delete
* 'interlace' => IMG_GIF|IMG_JPG, // Set interlacebit image formats ( bit-field )
[52] Fix | Delete
* 'offDropWith' => null, // Enabled by default. To disable it if it is dropped with pressing the meta key
[53] Fix | Delete
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
[54] Fix | Delete
* // In case of using any key, specify it as an array
[55] Fix | Delete
* 'onDropWith' => null // Disabled by default. To enable it if it is dropped with pressing the meta key
[56] Fix | Delete
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
[57] Fix | Delete
* // In case of using any key, specify it as an array
[58] Fix | Delete
* )
[59] Fix | Delete
* )
[60] Fix | Delete
* )
[61] Fix | Delete
* )
[62] Fix | Delete
* );
[63] Fix | Delete
*
[64] Fix | Delete
* @package elfinder
[65] Fix | Delete
* @author Naoki Sawada
[66] Fix | Delete
* @license New BSD
[67] Fix | Delete
*/
[68] Fix | Delete
class elFinderPluginWatermark extends elFinderPlugin
[69] Fix | Delete
{
[70] Fix | Delete
[71] Fix | Delete
private $watermarkImgInfo = null;
[72] Fix | Delete
[73] Fix | Delete
public function __construct($opts)
[74] Fix | Delete
{
[75] Fix | Delete
$defaults = array(
[76] Fix | Delete
'enable' => true, // For control by volume driver
[77] Fix | Delete
'source' => 'logo.png', // Path to Water mark image
[78] Fix | Delete
'ratio' => 0.2, // Ratio to original image (ratio > 0 and ratio <= 1)
[79] Fix | Delete
'position' => 'RB', // Position L(eft)/C(enter)/R(ight) and T(op)/M(edium)/B(ottom)
[80] Fix | Delete
'marginX' => 5, // Margin horizontal pixel
[81] Fix | Delete
'marginY' => 5, // Margin vertical pixel
[82] Fix | Delete
'quality' => 95, // JPEG image save quality
[83] Fix | Delete
'transparency' => 70, // Water mark image transparency ( other than PNG )
[84] Fix | Delete
'targetType' => IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP, // Target image formats ( bit-field )
[85] Fix | Delete
'targetMinPixel' => 200, // Target image minimum pixel size
[86] Fix | Delete
'interlace' => IMG_GIF | IMG_JPG, // Set interlacebit image formats ( bit-field )
[87] Fix | Delete
'offDropWith' => null, // To disable it if it is dropped with pressing the meta key
[88] Fix | Delete
// Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
[89] Fix | Delete
// In case of using any key, specify it as an array
[90] Fix | Delete
'marginRight' => 0, // Deprecated - marginX should be used
[91] Fix | Delete
'marginBottom' => 0, // Deprecated - marginY should be used
[92] Fix | Delete
'disableWithContentSaveId' => true // Disable on URL upload with post data "contentSaveId"
[93] Fix | Delete
);
[94] Fix | Delete
[95] Fix | Delete
$this->opts = array_merge($defaults, $opts);
[96] Fix | Delete
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
public function onUpLoadPreSave(&$thash, &$name, $src, $elfinder, $volume)
[100] Fix | Delete
{
[101] Fix | Delete
if (!$src) {
[102] Fix | Delete
return false;
[103] Fix | Delete
}
[104] Fix | Delete
[105] Fix | Delete
$opts = $this->getCurrentOpts($volume);
[106] Fix | Delete
[107] Fix | Delete
if (!$this->iaEnabled($opts, $elfinder)) {
[108] Fix | Delete
return false;
[109] Fix | Delete
}
[110] Fix | Delete
[111] Fix | Delete
$imageType = null;
[112] Fix | Delete
$srcImgInfo = null;
[113] Fix | Delete
if (extension_loaded('fileinfo') && function_exists('mime_content_type')) {
[114] Fix | Delete
$mime = mime_content_type($src);
[115] Fix | Delete
if (substr($mime, 0, 5) !== 'image') {
[116] Fix | Delete
return false;
[117] Fix | Delete
}
[118] Fix | Delete
}
[119] Fix | Delete
if (extension_loaded('exif') && function_exists('exif_imagetype')) {
[120] Fix | Delete
$imageType = exif_imagetype($src);
[121] Fix | Delete
if ($imageType === false) {
[122] Fix | Delete
return false;
[123] Fix | Delete
}
[124] Fix | Delete
} else {
[125] Fix | Delete
$srcImgInfo = getimagesize($src);
[126] Fix | Delete
if ($srcImgInfo === false) {
[127] Fix | Delete
return false;
[128] Fix | Delete
}
[129] Fix | Delete
$imageType = $srcImgInfo[2];
[130] Fix | Delete
}
[131] Fix | Delete
[132] Fix | Delete
// check target image type
[133] Fix | Delete
$imgTypes = array(
[134] Fix | Delete
IMAGETYPE_GIF => IMG_GIF,
[135] Fix | Delete
IMAGETYPE_JPEG => IMG_JPEG,
[136] Fix | Delete
IMAGETYPE_PNG => IMG_PNG,
[137] Fix | Delete
IMAGETYPE_BMP => IMG_WBMP,
[138] Fix | Delete
IMAGETYPE_WBMP => IMG_WBMP
[139] Fix | Delete
);
[140] Fix | Delete
if (!isset($imgTypes[$imageType]) || !($opts['targetType'] & $imgTypes[$imageType])) {
[141] Fix | Delete
return false;
[142] Fix | Delete
}
[143] Fix | Delete
[144] Fix | Delete
// check Animation Gif
[145] Fix | Delete
if ($imageType === IMAGETYPE_GIF && elFinder::isAnimationGif($src)) {
[146] Fix | Delete
return false;
[147] Fix | Delete
}
[148] Fix | Delete
// check Animation Png
[149] Fix | Delete
if ($imageType === IMAGETYPE_PNG && elFinder::isAnimationPng($src)) {
[150] Fix | Delete
return false;
[151] Fix | Delete
}
[152] Fix | Delete
// check water mark image
[153] Fix | Delete
if (!file_exists($opts['source'])) {
[154] Fix | Delete
$opts['source'] = dirname(__FILE__) . "/" . $opts['source'];
[155] Fix | Delete
}
[156] Fix | Delete
if (is_readable($opts['source'])) {
[157] Fix | Delete
$watermarkImgInfo = getimagesize($opts['source']);
[158] Fix | Delete
if (!$watermarkImgInfo) {
[159] Fix | Delete
return false;
[160] Fix | Delete
}
[161] Fix | Delete
} else {
[162] Fix | Delete
return false;
[163] Fix | Delete
}
[164] Fix | Delete
[165] Fix | Delete
if (!$srcImgInfo) {
[166] Fix | Delete
$srcImgInfo = getimagesize($src);
[167] Fix | Delete
}
[168] Fix | Delete
[169] Fix | Delete
$watermark = $opts['source'];
[170] Fix | Delete
$quality = $opts['quality'];
[171] Fix | Delete
$transparency = $opts['transparency'];
[172] Fix | Delete
[173] Fix | Delete
// check target image size
[174] Fix | Delete
if ($opts['targetMinPixel'] > 0 && $opts['targetMinPixel'] > min($srcImgInfo[0], $srcImgInfo[1])) {
[175] Fix | Delete
return false;
[176] Fix | Delete
}
[177] Fix | Delete
[178] Fix | Delete
$watermark_width = $watermarkImgInfo[0];
[179] Fix | Delete
$watermark_height = $watermarkImgInfo[1];
[180] Fix | Delete
[181] Fix | Delete
// Specified as a ratio to the image size
[182] Fix | Delete
if ($opts['ratio'] && $opts['ratio'] > 0 && $opts['ratio'] <= 1) {
[183] Fix | Delete
$maxW = $srcImgInfo[0] * $opts['ratio'] - ($opts['marginX'] * 2);
[184] Fix | Delete
$maxH = $srcImgInfo[1] * $opts['ratio'] - ($opts['marginY'] * 2);
[185] Fix | Delete
$dx = $dy = 0;
[186] Fix | Delete
if (($maxW >= $watermarkImgInfo[0] && $maxH >= $watermarkImgInfo[0]) || ($maxW <= $watermarkImgInfo[0] && $maxH <= $watermarkImgInfo[0])) {
[187] Fix | Delete
$dx = abs($srcImgInfo[0] - $watermarkImgInfo[0]);
[188] Fix | Delete
$dy = abs($srcImgInfo[1] - $watermarkImgInfo[1]);
[189] Fix | Delete
} else if ($maxW < $watermarkImgInfo[0]) {
[190] Fix | Delete
$dx = -1;
[191] Fix | Delete
} else {
[192] Fix | Delete
$dy = -1;
[193] Fix | Delete
}
[194] Fix | Delete
if ($dx < $dy) {
[195] Fix | Delete
$ww = $maxW;
[196] Fix | Delete
$wh = $watermarkImgInfo[1] * ($ww / $watermarkImgInfo[0]);
[197] Fix | Delete
} else {
[198] Fix | Delete
$wh = $maxH;
[199] Fix | Delete
$ww = $watermarkImgInfo[0] * ($wh / $watermarkImgInfo[1]);
[200] Fix | Delete
}
[201] Fix | Delete
$watermarkImgInfo[0] = $ww;
[202] Fix | Delete
$watermarkImgInfo[1] = $wh;
[203] Fix | Delete
} else {
[204] Fix | Delete
$opts['ratio'] = null;
[205] Fix | Delete
}
[206] Fix | Delete
[207] Fix | Delete
$opts['position'] = strtoupper($opts['position']);
[208] Fix | Delete
[209] Fix | Delete
// Set vertical position
[210] Fix | Delete
if (strpos($opts['position'], 'T') !== false) {
[211] Fix | Delete
// Top
[212] Fix | Delete
$dest_x = $opts['marginX'];
[213] Fix | Delete
} else if (strpos($opts['position'], 'M') !== false) {
[214] Fix | Delete
// Middle
[215] Fix | Delete
$dest_x = ($srcImgInfo[0] - $watermarkImgInfo[0]) / 2;
[216] Fix | Delete
} else {
[217] Fix | Delete
// Bottom
[218] Fix | Delete
$dest_x = $srcImgInfo[0] - $watermarkImgInfo[0] - max($opts['marginBottom'], $opts['marginX']);
[219] Fix | Delete
}
[220] Fix | Delete
[221] Fix | Delete
// Set horizontal position
[222] Fix | Delete
if (strpos($opts['position'], 'L') !== false) {
[223] Fix | Delete
// Left
[224] Fix | Delete
$dest_y = $opts['marginY'];
[225] Fix | Delete
} else if (strpos($opts['position'], 'C') !== false) {
[226] Fix | Delete
// Middle
[227] Fix | Delete
$dest_y = ($srcImgInfo[1] - $watermarkImgInfo[1]) / 2;
[228] Fix | Delete
} else {
[229] Fix | Delete
// Right
[230] Fix | Delete
$dest_y = $srcImgInfo[1] - $watermarkImgInfo[1] - max($opts['marginRight'], $opts['marginY']);
[231] Fix | Delete
}
[232] Fix | Delete
[233] Fix | Delete
[234] Fix | Delete
// check interlace
[235] Fix | Delete
$opts['interlace'] = ($opts['interlace'] & $imgTypes[$imageType]);
[236] Fix | Delete
[237] Fix | Delete
// Repeated use of Imagick::compositeImage() may cause PHP to hang, so disable it
[238] Fix | Delete
//if (class_exists('Imagick', false)) {
[239] Fix | Delete
// return $this->watermarkPrint_imagick($src, $watermark, $dest_x, $dest_y, $quality, $transparency, $watermarkImgInfo, $opts);
[240] Fix | Delete
//} else {
[241] Fix | Delete
elFinder::expandMemoryForGD(array($watermarkImgInfo, $srcImgInfo));
[242] Fix | Delete
return $this->watermarkPrint_gd($src, $watermark, $dest_x, $dest_y, $quality, $transparency, $watermarkImgInfo, $srcImgInfo, $opts);
[243] Fix | Delete
//}
[244] Fix | Delete
}
[245] Fix | Delete
[246] Fix | Delete
private function watermarkPrint_imagick($src, $watermarkSrc, $dest_x, $dest_y, $quality, $transparency, $watermarkImgInfo, $opts)
[247] Fix | Delete
{
[248] Fix | Delete
[249] Fix | Delete
try {
[250] Fix | Delete
[251] Fix | Delete
// Open the original image
[252] Fix | Delete
$img = new Imagick($src);
[253] Fix | Delete
[254] Fix | Delete
// Open the watermark
[255] Fix | Delete
$watermark = new Imagick($watermarkSrc);
[256] Fix | Delete
[257] Fix | Delete
// zoom
[258] Fix | Delete
if ($opts['ratio']) {
[259] Fix | Delete
$watermark->scaleImage($watermarkImgInfo[0], $watermarkImgInfo[1]);
[260] Fix | Delete
}
[261] Fix | Delete
[262] Fix | Delete
// Set transparency
[263] Fix | Delete
if (strtoupper($watermark->getImageFormat()) !== 'PNG') {
[264] Fix | Delete
$watermark->setImageOpacity($transparency / 100);
[265] Fix | Delete
}
[266] Fix | Delete
[267] Fix | Delete
// Overlay the watermark on the original image
[268] Fix | Delete
$img->compositeImage($watermark, imagick::COMPOSITE_OVER, $dest_x, $dest_y);
[269] Fix | Delete
[270] Fix | Delete
// Set quality
[271] Fix | Delete
if (strtoupper($img->getImageFormat()) === 'JPEG') {
[272] Fix | Delete
$img->setImageCompression(imagick::COMPRESSION_JPEG);
[273] Fix | Delete
$img->setCompressionQuality($quality);
[274] Fix | Delete
}
[275] Fix | Delete
[276] Fix | Delete
// set interlace
[277] Fix | Delete
$opts['interlace'] && $img->setInterlaceScheme(Imagick::INTERLACE_PLANE);
[278] Fix | Delete
[279] Fix | Delete
$result = $img->writeImage($src);
[280] Fix | Delete
[281] Fix | Delete
$img->clear();
[282] Fix | Delete
$img->destroy();
[283] Fix | Delete
$watermark->clear();
[284] Fix | Delete
$watermark->destroy();
[285] Fix | Delete
[286] Fix | Delete
return $result ? true : false;
[287] Fix | Delete
} catch (Exception $e) {
[288] Fix | Delete
$ermsg = $e->getMessage();
[289] Fix | Delete
$ermsg && trigger_error($ermsg);
[290] Fix | Delete
return false;
[291] Fix | Delete
}
[292] Fix | Delete
}
[293] Fix | Delete
[294] Fix | Delete
private function watermarkPrint_gd($src, $watermark, $dest_x, $dest_y, $quality, $transparency, $watermarkImgInfo, $srcImgInfo, $opts)
[295] Fix | Delete
{
[296] Fix | Delete
[297] Fix | Delete
$watermark_width = $watermarkImgInfo[0];
[298] Fix | Delete
$watermark_height = $watermarkImgInfo[1];
[299] Fix | Delete
[300] Fix | Delete
$ermsg = '';
[301] Fix | Delete
switch ($watermarkImgInfo['mime']) {
[302] Fix | Delete
case 'image/gif':
[303] Fix | Delete
if (imagetypes() & IMG_GIF) {
[304] Fix | Delete
$oWatermarkImg = imagecreatefromgif($watermark);
[305] Fix | Delete
} else {
[306] Fix | Delete
$ermsg = 'GIF images are not supported as watermark image';
[307] Fix | Delete
}
[308] Fix | Delete
break;
[309] Fix | Delete
case 'image/jpeg':
[310] Fix | Delete
if (imagetypes() & IMG_JPG) {
[311] Fix | Delete
$oWatermarkImg = imagecreatefromjpeg($watermark);
[312] Fix | Delete
} else {
[313] Fix | Delete
$ermsg = 'JPEG images are not supported as watermark image';
[314] Fix | Delete
}
[315] Fix | Delete
break;
[316] Fix | Delete
case 'image/png':
[317] Fix | Delete
if (imagetypes() & IMG_PNG) {
[318] Fix | Delete
$oWatermarkImg = imagecreatefrompng($watermark);
[319] Fix | Delete
} else {
[320] Fix | Delete
$ermsg = 'PNG images are not supported as watermark image';
[321] Fix | Delete
}
[322] Fix | Delete
break;
[323] Fix | Delete
case 'image/wbmp':
[324] Fix | Delete
if (imagetypes() & IMG_WBMP) {
[325] Fix | Delete
$oWatermarkImg = imagecreatefromwbmp($watermark);
[326] Fix | Delete
} else {
[327] Fix | Delete
$ermsg = 'WBMP images are not supported as watermark image';
[328] Fix | Delete
}
[329] Fix | Delete
break;
[330] Fix | Delete
default:
[331] Fix | Delete
$oWatermarkImg = false;
[332] Fix | Delete
$ermsg = $watermarkImgInfo['mime'] . ' images are not supported as watermark image';
[333] Fix | Delete
break;
[334] Fix | Delete
}
[335] Fix | Delete
[336] Fix | Delete
[337] Fix | Delete
if (!$ermsg) {
[338] Fix | Delete
// zoom
[339] Fix | Delete
if ($opts['ratio']) {
[340] Fix | Delete
$tmpImg = imagecreatetruecolor($watermarkImgInfo[0], $watermarkImgInfo[1]);
[341] Fix | Delete
imagealphablending($tmpImg, false);
[342] Fix | Delete
imagesavealpha($tmpImg, true);
[343] Fix | Delete
imagecopyresampled($tmpImg, $oWatermarkImg, 0, 0, 0, 0, $watermarkImgInfo[0], $watermarkImgInfo[1], imagesx($oWatermarkImg), imagesy($oWatermarkImg));
[344] Fix | Delete
imageDestroy($oWatermarkImg);
[345] Fix | Delete
$oWatermarkImg = $tmpImg;
[346] Fix | Delete
$tmpImg = null;
[347] Fix | Delete
}
[348] Fix | Delete
[349] Fix | Delete
switch ($srcImgInfo['mime']) {
[350] Fix | Delete
case 'image/gif':
[351] Fix | Delete
if (imagetypes() & IMG_GIF) {
[352] Fix | Delete
$oSrcImg = imagecreatefromgif($src);
[353] Fix | Delete
} else {
[354] Fix | Delete
$ermsg = 'GIF images are not supported as source image';
[355] Fix | Delete
}
[356] Fix | Delete
break;
[357] Fix | Delete
case 'image/jpeg':
[358] Fix | Delete
if (imagetypes() & IMG_JPG) {
[359] Fix | Delete
$oSrcImg = imagecreatefromjpeg($src);
[360] Fix | Delete
} else {
[361] Fix | Delete
$ermsg = 'JPEG images are not supported as source image';
[362] Fix | Delete
}
[363] Fix | Delete
break;
[364] Fix | Delete
case 'image/png':
[365] Fix | Delete
if (imagetypes() & IMG_PNG) {
[366] Fix | Delete
$oSrcImg = imagecreatefrompng($src);
[367] Fix | Delete
} else {
[368] Fix | Delete
$ermsg = 'PNG images are not supported as source image';
[369] Fix | Delete
}
[370] Fix | Delete
break;
[371] Fix | Delete
case 'image/wbmp':
[372] Fix | Delete
if (imagetypes() & IMG_WBMP) {
[373] Fix | Delete
$oSrcImg = imagecreatefromwbmp($src);
[374] Fix | Delete
} else {
[375] Fix | Delete
$ermsg = 'WBMP images are not supported as source image';
[376] Fix | Delete
}
[377] Fix | Delete
break;
[378] Fix | Delete
default:
[379] Fix | Delete
$oSrcImg = false;
[380] Fix | Delete
$ermsg = $srcImgInfo['mime'] . ' images are not supported as source image';
[381] Fix | Delete
break;
[382] Fix | Delete
}
[383] Fix | Delete
}
[384] Fix | Delete
[385] Fix | Delete
if ($ermsg || false === $oSrcImg || false === $oWatermarkImg) {
[386] Fix | Delete
$ermsg && trigger_error($ermsg);
[387] Fix | Delete
return false;
[388] Fix | Delete
}
[389] Fix | Delete
[390] Fix | Delete
if ($srcImgInfo['mime'] === 'image/png') {
[391] Fix | Delete
if (function_exists('imagecolorallocatealpha')) {
[392] Fix | Delete
$bg = imagecolorallocatealpha($oSrcImg, 255, 255, 255, 127);
[393] Fix | Delete
imagefill($oSrcImg, 0, 0, $bg);
[394] Fix | Delete
}
[395] Fix | Delete
}
[396] Fix | Delete
[397] Fix | Delete
if ($watermarkImgInfo['mime'] === 'image/png') {
[398] Fix | Delete
imagecopy($oSrcImg, $oWatermarkImg, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height);
[399] Fix | Delete
} else {
[400] Fix | Delete
imagecopymerge($oSrcImg, $oWatermarkImg, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $transparency);
[401] Fix | Delete
}
[402] Fix | Delete
[403] Fix | Delete
// set interlace
[404] Fix | Delete
$opts['interlace'] && imageinterlace($oSrcImg, true);
[405] Fix | Delete
[406] Fix | Delete
switch ($srcImgInfo['mime']) {
[407] Fix | Delete
case 'image/gif':
[408] Fix | Delete
imagegif($oSrcImg, $src);
[409] Fix | Delete
break;
[410] Fix | Delete
case 'image/jpeg':
[411] Fix | Delete
imagejpeg($oSrcImg, $src, $quality);
[412] Fix | Delete
break;
[413] Fix | Delete
case 'image/png':
[414] Fix | Delete
if (function_exists('imagesavealpha') && function_exists('imagealphablending')) {
[415] Fix | Delete
imagealphablending($oSrcImg, false);
[416] Fix | Delete
imagesavealpha($oSrcImg, true);
[417] Fix | Delete
}
[418] Fix | Delete
imagepng($oSrcImg, $src);
[419] Fix | Delete
break;
[420] Fix | Delete
case 'image/wbmp':
[421] Fix | Delete
imagewbmp($oSrcImg, $src);
[422] Fix | Delete
break;
[423] Fix | Delete
}
[424] Fix | Delete
[425] Fix | Delete
imageDestroy($oSrcImg);
[426] Fix | Delete
imageDestroy($oWatermarkImg);
[427] Fix | Delete
[428] Fix | Delete
return true;
[429] Fix | Delete
}
[430] Fix | Delete
}
[431] Fix | Delete
[432] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function