wp_imagecreatetruecolor( int $width, int $height ): resource|GdImage|false

In this article

Creates a new GD image resource with transparency support.

Parameters

$widthintrequired
Image width in pixels.
$heightintrequired
Image height in pixels.

Return

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

Source

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;
}

Changelog

VersionDescription
2.9.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.