wp_imagecreatetruecolor() WordPress Function

This function is used to create a new image with a specific width and height. The image will be created with true color and will be returned as a resource.

wp_imagecreatetruecolor( int $width, int $height ) #

Create new GD image resource with transparency support


Parameters

$width

(int)(Required)Image width in pixels.

$height

(int)(Required)Image height in pixels.


Top ↑

Return

(resource|GdImage|false) The GD image resource or GdImage instance on success. False on failure.


Top ↑

Source

File: wp-includes/media.php

function wp_imagecreatetruecolor( $width, $height ) {
	$img = imagecreatetruecolor( $width, $height );

	if ( is_gd_image( $img )
		&& function_exists( 'imagealphablending' ) && function_exists( 'imagesavealpha' )
	) {
		imagealphablending( $img, false );
		imagesavealpha( $img, true );
	}

	return $img;
}


Top ↑

Changelog

Changelog
VersionDescription
2.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More