コード例 #1
0
ファイル: index.php プロジェクト: phrenetictales/eman
 if ($size_x) {
     $columns[] = $db->raw('ABS(' . (int) $size_x . ' - width) as wdiff');
     $q->orderBy('wdiff', 'asc');
 }
 if ($size_y) {
     $columns[] = $db->raw('ABS(' . (int) $size_y . ' - height) as hdiff');
     $q->orderBy('hdiff', 'asc');
 }
 $q->select($columns);
 $picture = $q->first();
 if (empty($picture)) {
     die('FOOBAR');
 }
 if ($size_x && $picture->wdiff && !$size_y) {
     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]);
         $img->resize($size_x, null, true);
         $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 && $picture->hdiff && !$size_x) {
コード例 #2
0
ファイル: store-clear.php プロジェクト: phrenetictales/eman
#!/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();
            }
        }
    }
}