Example #1
0
 /**
  * Process images
  * @return string
  */
 protected function imageFile($path)
 {
     $params = array_intersect_key($_GET, array('x' => '', 'y' => '', 'adapt' => '', 'crop' => ''));
     $params['path'] = $path;
     /* Adaptive imgs */
     $resMax = 0;
     if (isset($params['adapt']) && isset($_COOKIE['DW']) && isset($_COOKIE['DH']) && isset($_COOKIE['DPR'])) {
         $resMax = max($_COOKIE['DW'], $_COOKIE['DH']) * (int) $_COOKIE['DPR'];
         $resMax = $params['adapt'] = ceil($resMax / 100) * 100;
         /* to limit amount of cached images versions */
         if (isset($params['x']) && $params['x'] > $resMax) {
             $params['x'] = $resMax;
         }
     }
     $cachePath = 'var/cache/' . str_replace('/', '_', http_build_query($params, '', '_'));
     /* get only allowed vars and secure generated path */
     if (!is_file($cachePath)) {
         /* if cache doesn't exists */
         include 'modules/core/classes/img.php';
         $img = new img($path);
         if (isset($params['x']) && isset($params['y'])) {
             if (isset($params['crop'])) {
                 $img->crop($params['x'], $params['y']);
             } else {
                 $img->resize($params['x'], $params['y']);
             }
         } elseif ($resMax > 0) {
             /* If there isn't x and y params we resize img to max Resolution of user's screen */
             $img->resize($resMax, 9999);
         }
         $img->save($cachePath, 80);
     }
     return $cachePath;
 }
Example #2
0
 if (!is_dir($root_month)) {
     mkdir($root_month, 777);
 }
 $images = $itemhtml->find("div[class=cover-container] img[0]")[0]->src;
 $image_data = file_get_contents($images);
 // Get image data
 $filename = preg_replace('/[^a-z0-9]/ui', '-', vnit_change_title($title));
 // Create image file name
 if (strpos($filename, ".png") === false && strpos($filename, ".jpg") === false) {
     $filename .= ".png";
 }
 file_put_contents($root_month . $filename, $image_data);
 $image = $filename;
 $image_ = explode('.', $image);
 $ext = $image_[count($image_) - 1];
 $img->crop($root_month . $filename, $root_month . vnit_change_title($title) . '150x150.' . $ext, 150, 150, 150, 150);
 $img->crop($root_month . $filename, $root_month . vnit_change_title($title) . '300x300.' . $ext, 300, 300, 300, 300);
 $img->crop($root_month . $filename, $root_month . vnit_change_title($title) . '300x160.' . $ext, 60, 60, 60, 60);
 $img->crop($root_month . $filename, $root_month . vnit_change_title($title) . '220x180.' . $ext, 220, 180, 220, 180);
 $img->crop($root_month . $filename, $root_month . vnit_change_title($title) . '70x70.' . $ext, 70, 70, 70, 70);
 $img->crop($root_month . $filename, $root_month . vnit_change_title($title) . '300x192.' . $ext, 300, 192, 300, 192);
 $img->crop($root_month . $filename, $root_month . vnit_change_title($title) . '188x144.' . $ext, 188, 144, 188, 144);
 /*
 $resizeObj1 = new resize($root_month . $image);
 $resizeObj1->resizeImage(150, 150, 'crop');
 $resizeObj1->saveImage($root_month . vnit_change_title($title) . '150x150.' . $ext, 100);
 unset($resizeObj1);
 
 $resizeObj8 = new resize($root_month . $image);
 $resizeObj8->resizeImage(300, 300, 'crop');
 $resizeObj8->saveImage($root_month . vnit_change_title($title) . '300x300.' . $ext, 100);