Found 26504 Articles for Server Side Programming

How to crop an image automatically using imagecropauto() function in PHP?

Urmila Samariya
Updated on 09-Aug-2021 10:12:07

1K+ Views

imagecropauto() is an inbuilt function in PHP that is used to crop an image automatically using one of the available modes.Syntaxresource imagecropauto(resource $image, int $mode, float $threshold, int $color)Parametersimagecropauto() takes four different parameters − $image, $mode, $threshold and $color.$image − Specifies the image resource to be cropped.$mode − It is an optional parameter and it is used to specify an integer corresponding to a crop mode, below is the list of crop modes.IMG_CROP_DEFAULT − The IMG_CROP_DEFAULT works just like the IMG_CROP_TRANSPARENT mode.IMG_CROP_TRANSPARENT − This mode is used to crop out a transparent background.IMG_CROP_BLACK − This mode is used to crop ... Read More

How to destroy an image in PHP using imagedestroy() function?

Urmila Samariya
Updated on 09-Aug-2021 10:05:23

644 Views

imagedestroy() is an inbuilt PHP function that is used to destroy an image and free any memory associated with the image.Syntaxbool imagedestroy(resource $image)Parametersimagedestroy() takes only one parameter, $image. It holds the name of an image.Return Valuesimagedestroy() returns true on success and failure on false.Example 1 − Destroying an image after loading it.OutputNote − By using imagedestroy() function, we have destroyed the $cropped variable and therefore, it can no longer be accessed.Explanation − In Example1, imagecreatefrompng() loads an image from the local drive folder and crops a part of the image from the given image using imagecropauto() function. After cropping, imagedestroy() ... Read More

How to create a new image from a WBMP file or URL using imagecreatefromwbmp() function in PHP?

Urmila Samariya
Updated on 09-Aug-2021 09:58:16

258 Views

In PHP, imagecreatefromwbmp() is an inbuilt function that is used to create a new image from a WBMP file or URL. imagecreatefromwbmp() returns an image identifier representing the image obtained from the given filename. We can use imagecreatefromwbmp() whenever we want to edit the images after loading them from a WBMP file. Using the imagewbmp() function, an image can be converted into WBMP.Syntaxresource imagecreatefromwbmp(string $filename)Parametersimagecreatefromwbmp() takes only one parameter, $filename. It holds the name of the image.Return Valuesimagecreatefromwbmp() returns an image resource identifier on success, and it gives an error on false.Example 1

How to create a new image from a PNG file or URL using the imagecreatefrompng() function in PHP?

Urmila Samariya
Updated on 09-Aug-2021 09:54:10

2K+ Views

In PHP, imagecreatefrompng() is an inbuilt function that is used to create a new image from a PNG file or URL. imagecreatefrompng() returns an image identifier representing the image obtained from the given filename.Syntaxresource imagecreatefrompng(string $filename)Parametersimagecreatefrompng() takes only one parameter, $filename. This parameter holds the name of the image or path to the PNG image.Return Valuesimagecreatefrompng() returns an image resource identifier on success, and it gives an error on false.Example 1 − Showing the loaded PNG image in the browserOutputExample 2 − Loaded and saving PNG image in the local drive pathOutputExplanation − In Example 2, a png image is ... Read More

How to create a new image from a JPEG file using the imagecreatefromjpeg() function in PHP?

Urmila Samariya
Updated on 09-Aug-2021 09:48:33

3K+ Views

imagecreatefromjpeg() is an inbuilt function in PHP that is used to create a new image from a JPEG file. It returns an image identifier representing the image obtained from the given filename.Syntaxresource imagecreatefromjpeg(string $filename)Parametersimagecreatefromjpeg() uses only one parameter, $filename, that holds the name of the image or path to the JPEG image.Return Valuesimagecreatefromjpeg() returns an image resource identifier on success, and it gives an error on false.Example 1OutputExample 2Input ImageOutput ImageExplanation − In Example 2, we loaded the jpeg image from the local path using the imagecreatefromjpeg() function. Thereafter, we used the imageflip() function to flip the image.Example 3 − ... Read More

How to print string vectors vertically in R?

Nizamuddin Siddiqui
Updated on 14-Aug-2021 08:28:17

396 Views

To print string vectors vertically in R, we can follow the below steps −First of all, create a vector.Then, use cat function to print the vector vertically.Example 1 Let's create a vector as shown below − Live DemoAlphabets

How to divide matrix rows by maximum value in each row excluding 0 in R?

Nizamuddin Siddiqui
Updated on 14-Aug-2021 08:26:59

294 Views

To divide matrix row values by row maximum excluding 0 in R, we can follow the below steps −First of all, create a matrix.Then, use apply function and if else function to divide the matrix row values by row maximum excluding 0.Create the matrixLet's create a matrix as shown below − Live DemoM

How to subset rows of an R data frame if all columns have values greater than a certain value

Nizamuddin Siddiqui
Updated on 09-Aug-2021 09:01:57

2K+ Views

To subset rows of an R data frame if all columns have values greater than a certain value, we can follow the below steps −First of all, create a data frame.Then, use filter_all function of dplyr package with all_vars function to subset the rows of the data frame for all columns having values greater than a certain value.Create the data frameLet's create a data frame as shown below −Example Live Demox1

How to divide data frame rows in R by row maximum?

Nizamuddin Siddiqui
Updated on 14-Aug-2021 08:25:24

293 Views

To divide the data frame row values by row maximum in R, we can follow the below steps −First of all, create a data frame.Then, use apply function to divide the data frame row values by row maximum.Create the data frameLet's create a data frame as shown below − Live Demox

How to find the row and column position of a value as vector in an R matrix?

Nizamuddin Siddiqui
Updated on 14-Aug-2021 08:24:24

799 Views

To find the row and column position of a value as vector in an R matrix, we can follow the below steps −First of all, create a matrix.Then, find the row and column position of a particular value using which function and reading the output with as.vector function.Example 1Create a matrixLet's create a matrix as shown below − Live DemoM1

Advertisements