$resource_path = env('APP_URL') . $hotel->hero_image;
$name = explode('.', $resource_path);
if(!file_exists('upload/hotel/thumb/'.$id.'.'.$name[2]))
{
$s_size = getimagesize($resource_path);
$s_height = $s_size[1];
$s_width = $s_size[0];
$d_height = $s_size[1]/3;
$d_width = $s_size[0]/3;
$dest = imagecreatetruecolor($d_width, $d_height);
if (strpos($name[2],'png')!==false){
$source = imagecreatefrompng($resource_path);
imagecopyresized($dest, $source, 0, 0, 0, 0, $d_width, $d_height, $s_width, $s_height);
imagepng($dest,'upload/hotel/thumb/'.$id.'.'.$name[2],1);
}else{
$source = imagecreatefromjpeg($resource_path);
imagecopyresized($dest, $source, 0, 0, 0, 0, $d_width, $d_height, $s_width, $s_height);
imagejpeg($dest,'upload/hotel/thumb/'.$id.'.'.$name[2],100);
}
}