src/Image.php
private function cloneResource($resource) {
		// Get width from image.
		$w = imagesx($resource);
		// Get height from image.
		$h = imagesy($resource);
		// Get the transparent color from a 256 palette image.
		$trans = imagecolortransparent($resource);

		if (imageistruecolor($resource)) {
			// this is a true color image...
			$clone = imagecreatetruecolor($w, $h);
			imagealphablending($clone, false);
			imagesavealpha($clone, true);
		} else {
			// this is a 256 color palette image...
			$clone = imagecreate($w, $h);

			// If the image has transparency...
			if ($trans >= 0) {
				$rgb = imagecolorsforindex($resource, $trans);
				imagesavealpha($clone, true);
				$trans_index = imagecolorallocatealpha($clone, $rgb['red'], $rgb['green'], $rgb['blue'], $rgb['alpha']);
				imagefill($clone, 0, 0, $trans_index);
			}
		}

		// Create the Clone!!
		imagecopy($clone, $resource, 0, 0, 0, 0, $w, $h);

		return [
			'resource' => $clone,
			'width' => $w,
			'height' => $h,
		];
	}
private function cloneResource($resource) {
		// Get width from image.
		$w = imagesx($resource);
		// Get height from image.
		$h = imagesy($resource);
		// Get the transparent color from a 256 palette image.
		$trans = imagecolortransparent($resource);

		if (imageistruecolor($resource)) {
			// this is a true color image...
			$clone = imagecreatetruecolor($w, $h);
			imagealphablending($clone, false);
			imagesavealpha($clone, true);
		} else {
			// this is a 256 color palette image...
			$clone = imagecreate($w, $h);

			// If the image has transparency...
			if ($trans >= 0) {
				$rgb = imagecolorsforindex($resource, $trans);
				imagesavealpha($clone, true);
				$trans_index = imagecolorallocatealpha($clone, $rgb['red'], $rgb['green'], $rgb['blue'], $rgb['alpha']);
				imagefill($clone, 0, 0, $trans_index);
			}
		}

		// Create the Clone!!
		imagecopy($clone, $resource, 0, 0, 0, 0, $w, $h);

		return [
			'resource' => $clone,
			'width' => $w,
			'height' => $h,
		];
	}
private function cloneResource ( $ resource ) { // Get width from image. $ w = imagesx ( $ resource ) ; // Get height from image. $ h = imagesy ( $ resource ) ; // Get the transparent color from a 256 palette image. $ trans = imagecolortransparent ( $ resource ) ; if ( imageistruecolor ( $ resource ) ) { // this is a true color image... $ clone = imagecreatetruecolor ( $ w , $ h ) ; imagealphablending ( $ clone , false ) ; imagesavealpha ( $ clone , true ) ; } else { // this is a 256 color palette image... $ clone = imagecreate ( $ w , $ h ) ; // If the image has transparency... if ( $ trans >= 0 ) { $ rgb = imagecolorsforindex ( $ resource , $ trans ) ; imagesavealpha ( $ clone , true ) ; $ trans_index = imagecolorallocatealpha ( $ clone , $ rgb [ 'red' ] , $ rgb [ 'green' ] , $ rgb [ 'blue' ] , $ rgb [ 'alpha' ] ) ; imagefill ( $ clone , 0 , 0 , $ trans_index ) ; } } // Create the Clone!! imagecopy ( $ clone , $ resource , 0 , 0 , 0 , 0 , $ w , $ h ) ; return [ 'resource' => $ clone , 'width' => $ w , 'height' => $ h , ] ; }
Clone Image Resource

@param $resource
@return array
Clone Image Resource