public static function createImageModel($image_file_name) { if (empty($image_file_name)) { return null; } $image = new ImageModel(); $image->imgType = ImageModel::getImgTypeByExtension($image_file_name); $image->data = file_get_contents(app_path() . '/storage/uploads/' . $image_file_name); return $image; }
public function store() { $file = Input::file('uploader'); $destinationPath = app_path() . '/storage/uploads/'; $filename = $file->getClientOriginalName(); $destinationPath = app_path() . '/storage/uploads/'; $filename = $file->getClientOriginalName(); $file->move($destinationPath, $filename); if (exif_imagetype($destinationPath . $filename) == 2) { $layer = PHPImageWorkshop\ImageWorkshop::initFromPath($destinationPath . $filename); $exif = exif_read_data($destinationPath . $filename); if (isset($exif['Orientation']) && $exif['Orientation'] == '6') { $layer->rotate(90); } if (isset($exif['Orientation']) && $exif['Orientation'] == '3') { $layer->rotate(180); } $layer->save($destinationPath, $filename, false, null, 95); } if (ImageModel::getImgTypeByExtension($filename) == ImageModel::IMGTYPE_PDF) { return array(); } list($width, $height, $type, $attr) = getimagesize($destinationPath . $filename); if ($width < 500 || $height < 500 || filesize($destinationPath . $filename) > 5242880) { return array('error' => "Picture width and height must be at least 500px. Please select a larger image or limit the photo size to 5MB."); } else { return array(); } }