PHP image_type_to_extension() Function Last Updated : 26 May, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report The image_type_to_extension() function is an inbuilt function in PHP which is used to get the file extension for an image type. This function can be found in any PHP version similar or greater than 5.2.0. Syntax: string image_type_to_extension( int $imagetype, bool $include_dot ) Parameters: This function accepts two parameters as mentioned above and described below: $imagetype: It takes an integer value as first parameter that is one of the IMAGETYPE_XXX constant. For example: IMAGETYPE_GIF, IMAGETYPE_JPEG etc.$include_dot: The second parameter takes a boolean value to decide whether to prepend a dot to the extension or not. The default value is set to TRUE in the function. Return Value: This function returns a string value associated with the extension corresponding to the given image type. Below programs illustrate the image_type_to_extension() function in PHP. Program 1: php <?php // Extension with dot echo image_type_to_extension(IMAGETYPE_PNG, TRUE) . "\n"; // Extension without dot echo image_type_to_extension(IMAGETYPE_PNG, FALSE); ?> Output: .png png Program 2: php <?php // Create image instance $image = imagecreatetruecolor(100, 100); // Creates an image with .png extension imagepng($image, './test' . image_type_to_extension(IMAGETYPE_PNG)); // Free any memory associated with image imagedestroy($image); ?> Output: Creates an image with name test.png Reference: https://www.php.net/manual/en/function.image-type-to-extension.php Comment More infoAdvertise with us Next Article PHP image_type_to_extension() Function S ShrabanaBiswas Follow Improve Article Tags : Web Technologies PHP Image-Processing PHP-function Similar Reads PHP | mime_content_type() function The mime_content_type() function is an inbuilt function in PHP which is used to get the MIME content-type of a file. Syntax: string mime_content_type( $file ) Parameters: This function accepts single parameter $file which specifies the path of the file which MIME details to be find. Return Value: Th 1 min read PHP | image_type_to_mime_type() Function The image_type_to_mime_type() function is an inbuilt function in PHP which is used to get the MimeType for an imagetype returned by other different functions like getimagesize(), exif_read_data(), exif_thumbnail(), exif_imagetype() etc. The MIME stands for Multi-purpose Internet Mail Extensions. MIM 2 min read PHP get_loaded_extensions() Function The get_loaded_extensions() is an inbuilt function that returns an array of loaded and compiled modules in PHP. Syntax: get_loaded_extensions(bool $zend_extensions = false): Parameters: This function has only one parameter. $zend_extensions: It only returns zend extensions, if not then regular exten 2 min read PHP | exif_imagetype() function The exif_imagetype() function is an inbuilt function in PHP which is used to determine the type of an image.Syntax:Â Â int exif_imagetype( string $filename ) Parameters:This function accepts a single parameter $filename which holds the name or URL of the image.Return Value: This function returns an i 1 min read PHP get_resource_type() Function The get_resource_type() function is an inbuilt function in PHP that is used for returning the type of resource. Syntax: get_resource_type(resource $resource) Parameters: This function accepts one parameter that described below: $resource: This parameter specifies the evaluated resource handle name.R 1 min read Like