PHP dynamic zip file creation crashes with non-image filetypes. (wp)
The problem section seems to be where you're asking PDFs, etc. their image size. Why don't you try:
$image_size = getimagesize($file);if($image_size===false){ // This is not an image // Do what you want to PDFs, etc.}else{ // This is an image // Find out image type, dimensions, etc.}