Is it possible to add a background picture to a image if it's less than XX wide or YY high? And is it possible to center the uploaded image (both height and width)?
Code: Select all
// resize
$maxWidth = '100';
$maxHeight = '150';
function addBackground();
add 'background.jpg';
}
if(($uploaded_file_width < $maxWidth) || ($uploaded_file_height < $maxHeight)) { // --> after resize!
// Add background.jpg under the uploaded image
if($uploaded_file_width < $maxWidth) {
$get_width_space = $maxWidth/$imgWidth/2; // Finds the space between the image and the end of the background image
// add padding/margin to the left and right of the uploaded image (value = $get_width_space)
} else {
$get_heigh_space = $maxHeight/$imgHeight/2; // Finds the space between the image and the end of the background image
// add padding/margin to the top and bottom of the uploaded image (value = $get_height_space)
}
}