Today, We want to share with you PHP Automatically Stretch Background Fit Image .In this post we will show you PHP stretch background image to fit screen, hear for Scale Image Using PHP and Maintaining Aspect Ratio we will give you demo and example for implement.In this post, we will learn about PHP Stretch Background Image using API with an example.
PHP Automatically Stretch Background Fit Image
There are the Following The simple About PHP Automatically Stretch Background Fit Image Full Information With Example and source code.
As I will cover this Post with live Working example to develop Stretch Image to Fit 100% of Div Height and Width, so the Scale an image using the given new width and height for this example is following below.
This Examples below are converted in real time using Very Imp Source code below, as well as You feel free to use it and merge your source code with improve.
$w = intval($_GET['width']); $h = intval($_GET['height']); $img_tupe = $_GET['img_tupe']=='fit'?'fit':'fill'; if ($w = 1000) $w = 520; if ($h = 1000) $h = 400; // Main Live Source image $src = imagecreatefromjpeg('./pakainfo.jpg'); // Destination your image with white background $final_result = imagecreatetruecolor($w, $h); imagefill($final_result, 0, 0, imagecolorallocate($final_result, 255, 255, 255)); // PHP Flexify Image FIT/FILL example using PHP GD scale_image($src, $final_result, $img_tupe); // Output to the any browser (Mozila, chrome, IE..) Header('Content-Type: image/jpeg'); imagejpeg($final_result); //PHP background image stretch to fill function scale_image($live_img, $dst_image, $op = 'fit') { $img_wdht = imagesx($live_img); $img_hght = imagesy($live_img); $dst_width = imagesx($dst_image); $dst_height = imagesy($dst_image); // Try to match destination image by width $con_wdh = $dst_width; $con_hgt = round($con_wdh*($img_hght/$img_wdht)); $x_side = 0; $y_side = round(($dst_height-$con_hgt)/2); // FILL and FIT img_tupe are mutually exclusive if ($op =='fill') $next = $con_hgt $dst_height; // If match by main Src width failed as well as destination image does not fit, try by height if ($next) { $con_hgt = $dst_height; $con_wdh = round($con_hgt*($img_wdht/$img_hght)); $x_side = round(($dst_width - $con_wdh)/2); $y_side = 0; } // Copy image on right place imagecopyresampled($dst_image, $live_img , $x_side, $y_side, 0, 0, $con_wdh, $con_hgt, $img_wdht, $img_hght); }
Angular 6 CRUD Operations Application Tutorials
Read :
Summary
You can also read about AngularJS, ASP.NET, VueJs, PHP.
I hope you get an idea about PHP Automatically Stretch Background Fit Image .
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.