/** * type dependant image resizing * * @param array $aImageInfo Contains information on image's type / width / height * @param string $sSrc source image * @param string $hDestinationImage Destination Image * @param string $sTarget Resized Image target * @param int $iNewWidth Resized Image's width * @param int $iNewHeight Resized Image's height * @param mixed $iGdVer used GDVersion, if null or false returns false * @param bool $blDisableTouch false if "touch()" should be called for gif resizing * @param string $iDefQuality quality for "imagejpeg" function * * @return bool */ protected function _resize($aImageInfo, $sSrc, $hDestinationImage, $sTarget, $iNewWidth, $iNewHeight, $iGdVer, $blDisableTouch, $iDefQuality) { startProfile("PICTURE_RESIZE"); $blSuccess = false; switch ($aImageInfo[2]) { //Image type case $this->_aImageTypes["GIF"]: //php does not process gifs until 7th July 2004 (see lzh licensing) if (function_exists("imagegif")) { $blSuccess = resizeGif($sSrc, $sTarget, $iNewWidth, $iNewHeight, $aImageInfo[0], $aImageInfo[1], $iGdVer); } break; case $this->_aImageTypes["JPEG"]: case $this->_aImageTypes["JPG"]: $blSuccess = resizeJpeg($sSrc, $sTarget, $iNewWidth, $iNewHeight, $aImageInfo, $iGdVer, $hDestinationImage, $iDefQuality); break; case $this->_aImageTypes["PNG"]: $blSuccess = resizePng($sSrc, $sTarget, $iNewWidth, $iNewHeight, $aImageInfo, $iGdVer, $hDestinationImage); break; } if ($blSuccess && !$blDisableTouch) { @touch($sTarget); } stopProfile("PICTURE_RESIZE"); return $blSuccess; }
/** * Generates PNG type image and returns its location on file system * * @param string $sSource image source * @param string $sTarget image target * @param int $iWidth image width * @param int $iHeight image height * * @return string */ protected function _generatePng($sSource, $sTarget, $iWidth, $iHeight) { return resizePng($sSource, $sTarget, $iWidth, $iHeight, @getimagesize($sSource), getGdVersion(), null); }
$bgFile = __DIR__ . "/" . $ip . ".png"; // 93 x 93 $imageFile = __DIR__ . "/new.png"; $overlayText = __DIR__ . "/" . $name; $x = 1920; $y = 1080; // dimensions of the final image $final_img = imagecreatetruecolor($x, $y); $image_1 = imagecreatefrompng($bgFile); $image_2 = imagecreatefrompng($imageFile); $image_3 = imagecreatefrompng($overlayText); /* * IMAGE RESIZE */ // The file $image_1 = resizePng($image_1, $x, $y); /* * */ imagealphablending($final_img, true); imagesavealpha($final_img, true); imagecopyresampled($final_img, $image_1, 0, 0, 0, 0, $x, $y, $x, $y); imagecopy($final_img, $image_2, 0, 0, 0, 0, $x, $y); imagecopy($final_img, $image_3, 90, 872, 0, 0, 1730, 80); ob_start(); imagepng($final_img); $watermarkedImg = ob_get_contents(); // Capture the output ob_end_clean(); // Clear the output buffer header('Content-Type: image/png');
/** * Generates PNG type image and returns its location on file system * * @param string $source image source * @param string $target image target * @param int $width image width * @param int $height image height * * @return string */ protected function _generatePng($source, $target, $width, $height) { return resizePng($source, $target, $width, $height, @getimagesize($source), getGdVersion(), null); }