return sprintf( __( 'File “%s” does not exist?'
),
$file );
} if ( !
function_exists('imagecreatefromstring'
) ) return __('The GD image library is not installed.'
);
// Set artificially high because GD uses uncompressed images in memory.
wp_raise_memory_limit( 'image'
);
$image =
imagecreatefromstring( file_get_contents( $file ) );
if ( !
is_gd_image( $image ) ) { /* translators: %s: File name. */
return sprintf( __( 'File “%s” is not an image.'
),
$file );
} return $image;
}/**
* Scale down an image to fit a particular size and save a new copy of the image.
*
* The PNG transparency will be preserved using the function, as well as the
* image type. If the file going in is PNG, then the resized image is going to
* be PNG. The only supported image types are PNG, GIF, and JPEG.
*
* Some functionality requires API to exist, so some PHP version may lose out
* support. This is not the fault of WordPress (where functionality is
* downgraded, not actual defects), but of your PHP version.
*
* @since 2.5.0
* @deprecated 3.5.0 Use wp_get_image_editor()
* @see wp_get_image_editor()
*
* @param string $file Image file path.
* @param int $max_w Maximum width to resize to.
* @param int $max_h Maximum height to resize to.
* @param bool $crop Optional. Whether to crop image or resize. Default false.
* @param string $suffix Optional. File suffix. Default null.
* @param string $dest_path Optional. New image file path. Default null.
* @param int $jpeg_quality Optional. Image quality percentage. Default 90.
* @return mixed WP_Error on failure. String with new destination path.
*/