Change language

PHP Imagescale () Function

Syntax:
resource imagescale ($image, $new_width, $new_height = -1, $mode = IMG_BILINEAR_FIXED)
Parameters:This function takes four parameters as above and described below:
  • $image:is returned by one of the create functions images such as imagecreatetruecolor(). Used to create the size of the image.
  • $new_width:this parameter contains the width to scale the image.
  • $new_height:this parameter contains the height to scale the image. If this parameter is negative or omitted, the aspect ratio of the image is preserved.
  • $mode:This parameter contains the mode. The value of this parameter - IMG_NEAREST_NEIGHBOUR, IMG_BILINEAR_FIXED, IMG_BICUBIC, IMG_BICUBIC_FIXED or whatever.
Return value:this function returns the scaled image resource on success or False on error.The following programs illustrate the imagescale() function in PHP:Program 1:  
// Assign variable image file $image_name = https://media.engineerforengineer.org/wp-content/uploads/engineerforengineer-15.png ;  
// Load image file $image = imagecreatefrompng ( $image_name );  
// Use the imagescale() function to scale the image $img = imagescale ( $image , 500, 400);  
// Output image to browser header ( "Content-type: image / png" ); imagepng ( $img );  
?>
Output: Program 2:  
// Create the size of the image or blank image. $image = imagecreatetruecolor (500, 300);  
// Set the background color of the image. $bg = imagecolorallocate ( $image , 205, 220, 200);  
// Fill the background with the selected color above. imagefill ( $image , 0, 0, $bg );  
// Set the color of the ellipse. $col_ellipse = imagecolorallocate ( $image , 0, 102, 0);  
// Function for drawing a filled ellipse. imagefilledellipse ( $image , 250, 150, 400, 250, $col_ellipse );  
// Use the imagescale() function to scale the image $img = imagescale ( $image , 700, 500);  
// Output image to browser header ( "Content-type: image / png" ); imagepng ( $img );  
?>
Output: Link: https://www.php.net/manual/en/function.imagescale.php

Shop

Best laptop for Sims 4

$

Best laptop for Zoom

$499

Best laptop for Minecraft

$590

Best laptop for engineering student

$

Best laptop for development

$

Best laptop for Cricut Maker

$

Best laptop for hacking

$890

Best laptop for Machine Learning

$950

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method