In some cases the use of the IMG_CROP_WHITE or IMG_CROP_BLACK does not work. The function returns FALSE. It is best to use the IMG_CROP_THRESHOLD mode and specify the color in fourth argument as in the example below :
<?php
$original_img = imagecreatefromjpeg($image_path);
$cropped_img_white = imagecropauto($original_img , IMG_CROP_THRESHOLD, null, 16777215);
$cropped_img_white = imagecropauto($original_img , IMG_CROP_WHITE);
$cropped_img_black = imagecropauto($original_img , IMG_CROP_THRESHOLD, null, 0);
$cropped_img_black = imagecropauto($original_img , IMG_CROP_BLACK);
?>