Пример #1
0
         $img->save($store->filename($resized->resizedname));
         $resized->width = $img->width;
         $resized->height = $img->height;
         $resized->save();
     } catch (Exception $e) {
         die('ERROR: ' . $e->getMessage());
     }
     $response = $app->response();
     $response['Content-Type'] = $resized->type;
     $response->body($store->get($resized->resizedname));
     return;
 } else {
     if ($size_y && $size_x && ($picture->hdiff || $picture->wdiff)) {
         try {
             $img = Intervention\Image\Image::make($store->filename($picture->storename));
             $resized = new RMAN\Models\ORM\Picture(['type' => $picture->type, 'name' => $picture->name, 'storename' => $picture->storename, 'resizedname' => $store->add($picture->storename), 'default' => 0]);
             if ($picture->width < $picture->height) {
                 $img->resize($size_x, null, true);
             } else {
                 $img->resize(null, $size_y, true);
             }
             $img->crop($size_x, $size_y);
             $img->save($store->filename($resized->resizedname));
             $resized->width = $img->width;
             $resized->height = $img->height;
             $resized->save();
         } catch (Exception $e) {
             die('ERROR: ' . $e->getMessage());
         }
         $response = $app->response();
         $response['Content-Type'] = $resized->type;
Пример #2
0
#!/usr/bin/env php
<?php 
require_once __DIR__ . '/../init.php';
$step = 256;
$count = RMAN\Models\ORM\Picture::where('default', '=', 0)->count();
$store = new Phrenetic\StoreFile('pictures');
for ($offset = 0; $offset < $count; $offset += $step) {
    $pictures = RMAN\Models\ORM\Picture::where('default', '=', 0)->limit($step)->offset($offset)->get();
    foreach ($pictures as $picture) {
        $fname = $store->filename($picture->resizedname);
        if (is_file($fname)) {
            if (@unlink($fname)) {
                $picture->delete();
            }
        }
    }
}