public function saveThumbnailImage(Request $request)
 {
     $file = $request->file('product_thumbnail_img');
     if ($file && $_FILES["product_thumbnail_img"]["tmp_name"]) {
         try {
             $preview_img_x = $_POST['x_thumbnail'];
             $preview_img_y = $_POST['y_thumbnail'];
             $preview_img_w = $_POST['w_thumbnail'];
             $preview_img_h = $_POST['h_thumbnail'];
             $display_w = $_POST['display_w_thumbnail'];
             $file_path = $file->getPathname();
             $orig_w = getimagesize($_FILES["product_thumbnail_img"]["tmp_name"])[0];
             $ratio = $orig_w / $display_w;
             $fileUploadDir = 'files/uploads/';
             $fileName = $file->getFilename() . time() . "." . $file->getClientOriginalExtension();
             if (File::exists($fileUploadDir . $fileName)) {
                 $fileName = $file->getFilename() . time() . "." . $file->getClientOriginalExtension();
             }
             $img = \Img::make($file_path)->crop((int) ($preview_img_w * $ratio), (int) ($preview_img_h * $ratio), (int) ($preview_img_x * $ratio), (int) ($preview_img_y * $ratio));
             $img->resize(300, 167);
             $img->save($fileUploadDir . $fileName);
             return $fileName;
         } catch (Exception $e) {
             return false;
         }
     }
     return false;
 }
Пример #2
0
 public function saveCroppedImage(Request $request, $slider_title = "")
 {
     $file = $request->file('slider_img');
     if ($file && isset($_FILES["slider_img"]["tmp_name"])) {
         try {
             $slider_img_x = $_POST['x'];
             $slider_img_y = $_POST['y'];
             $slider_img_w = $_POST['w'];
             $slider_img_h = $_POST['h'];
             $display_w = $_POST['display_w'];
             $file_path = $file->getPathname();
             $orig_w = getimagesize($_FILES["slider_img"]["tmp_name"])[0];
             $ratio = $orig_w / $display_w;
             $fileUploadDir = 'files/uploads/';
             $fileName = $file->getFilename() . time() . "." . $file->getClientOriginalExtension();
             if (File::exists($fileUploadDir . $fileName)) {
                 $fileName = $file->getFilename() . time() . "." . $file->getClientOriginalExtension();
             }
             $img = \Img::make($file_path)->crop((int) ($slider_img_w * $ratio), (int) ($slider_img_h * $ratio), (int) ($slider_img_x * $ratio), (int) ($slider_img_y * $ratio));
             $img = $img->resize(300, 300);
             $tmpFile = $fileUploadDir . "tmp_slider_img" . time();
             $img->save($tmpFile);
             //merge two images to one
             $this->merge('img/deze.png', $tmpFile, $fileUploadDir . $fileName, $slider_title, $request);
             //delete tmp file
             File::delete($tmpFile);
             return $fileName;
         } catch (Exception $e) {
             return false;
         }
     }
     return false;
 }
Пример #3
0
 /**
  * Execute the job.
  *
  * @param Request $request
  * @return string
  */
 public function handle(Request $request)
 {
     $file = $request->file('slider_img');
     if ($file && isset($_FILES["slider_img"]["tmp_name"])) {
         try {
             $preview_img_x = $_POST['x_texture'];
             $preview_img_y = $_POST['y_texture'];
             $preview_img_w = $_POST['w_texture'];
             $preview_img_h = $_POST['h_texture'];
             $display_w = $_POST['display_w_texture'];
             $file_path = $file->getPathname();
             $orig_w = getimagesize($_FILES["slider_img"]["tmp_name"])[0];
             $ratio = $orig_w / $display_w;
             $fileUploadDir = 'files/uploads/';
             $img = \Img::make($file_path)->crop((int) ($preview_img_w * $ratio), (int) ($preview_img_h * $ratio), (int) ($preview_img_x * $ratio), (int) ($preview_img_y * $ratio));
             $img->resize(300, 143);
             $img->save($fileUploadDir . $this->fileName);
         } catch (Exception $e) {
         }
     }
 }
 public function saveCroppedImage(Request $request, $i)
 {
     $file = $request->file('product_preview_img_' . $i);
     if ($file && isset($_FILES["product_preview_img_" . $i]["tmp_name"])) {
         if ($_POST['w_' . $i] != "") {
             try {
                 $preview_img_x = $_POST['x_' . $i];
                 $preview_img_y = $_POST['y_' . $i];
                 $preview_img_w = $_POST['w_' . $i];
                 $preview_img_h = $_POST['h_' . $i];
                 $display_w = $_POST['display_w_' . $i];
                 $file_path = $file->getPathname();
                 $orig_w = getimagesize($_FILES["product_preview_img_" . $i]["tmp_name"])[0];
                 $ratio = $orig_w / $display_w;
                 $fileUploadDir = 'files/uploads/';
                 $fileName = $file->getFilename() . time() . "." . $file->getClientOriginalExtension();
                 $origFileName = $file->getFilename() . time() . "_orig." . $file->getClientOriginalExtension();
                 if (File::exists($fileUploadDir . $fileName)) {
                     $fileName = $file->getFilename() . time() . "." . $file->getClientOriginalExtension();
                 }
                 $img = \Img::make($file_path)->crop((int) ($preview_img_w * $ratio), (int) ($preview_img_h * $ratio), (int) ($preview_img_x * $ratio), (int) ($preview_img_y * $ratio));
                 $img->resize(300, 300);
                 $img->save($fileUploadDir . $fileName);
                 //save orig image
                 $orig_img = \Img::make($file_path);
                 $orig_img->save($fileUploadDir . $origFileName);
                 return [$fileName, $origFileName];
             } catch (Exception $e) {
                 return false;
             }
         } else {
             return false;
         }
     }
     return false;
 }
Пример #5
0
 public function saveCroppedTextureImage(Request $request, $fileName)
 {
     $file = $request->file('product_texture_img');
     if ($file) {
         $preview_img_x = $_POST['x_texture'];
         $preview_img_y = $_POST['y_texture'];
         $preview_img_w = $_POST['w_texture'];
         $preview_img_h = $_POST['h_texture'];
         $display_w = $_POST['display_w_texture'];
         $file_path = $file->getPathname();
         $orig_w = getimagesize($_FILES["product_texture_img"]["tmp_name"])[0];
         $ratio = $orig_w / $display_w;
         $fileUploadDir = 'files/uploads/';
         $img = \Img::make($file_path)->crop((int) ($preview_img_w * $ratio), (int) ($preview_img_h * $ratio), (int) ($preview_img_x * $ratio), (int) ($preview_img_y * $ratio));
         $img->resize(300, 300);
         $img->save($fileUploadDir . $fileName);
         return $fileName;
     }
     return false;
 }