Here is the second part of the article “Image Cropping in PHP”. The first part is here This part describes the function imagecrop introduced in PHP 5.5.0 for cropping images. imagecrop can be used to crop an image based on a start and end point/co-ordinate and dimensions. (It doesn’t take into account any color like… Continue reading Image Cropping in PHP – Part 2
Month: November 2014
Nice Article on Full Page Background Image
Image Cropping in PHP – Part 1
With PHP 5.5.0 two functions, imagecropauto and imagecrop, have been added for advanced image resizing. This article describes the imagecropauto function. The imagecropauto function is useful to remove borders or background/outer area of a photo. The mode parameter defines the border to be removed e.g. IMG_CROP_BLACK will remove black borders, IMG_CROP_WHITE will remove white borders… Continue reading Image Cropping in PHP – Part 1
Some Useful Regex
Mail-id verification: /^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/ Though both can be used in PHP and JS but there is another method to verify an email-id in PHP, by using the below code if(!filter_var($email, FILTER_VALIDATE_EMAIL)) FILTER_VALIDATE_EMAIL is a predefined filter in PHP. Name Verification: /^[A-Za-z .’-]+$/ Phone Verification: /^[0-9 -]+$/ Removing all spaces: $pattern = ‘/\s+/’; $replace = “”; $string… Continue reading Some Useful Regex
Secure Upload Folders
There are two ways to prevent execution of any (malicious) scripts uploaded to by users. Method one – like described in this post. Method two – add the below code to .htaccess file of the directory that needs to be protected. RemoveHandler .cgi .php .php3 .php4 .php5 .phtml .pl .py .pyc .pyo .sh .html .shtml… Continue reading Secure Upload Folders