Esempio n. 1
0
$images[] = $file;
logSection(file_exists($file), 'is created file exists', 'mark');
$data = $image->getPathInfo('/тестовый/путь/к.jpg');
logSection(is_array($data), 'is array result', 'pathinfo');
foreach ($data as $k => &$part) {
    logSection($part, '"' . $k . '"', 'pathinfo');
}
@mkdir($fixtures . '/mcr', 0777);
$thumbs = $image->createThumbs($fixtures . '/FordMustang.jpg', array('mcr/' => array('width' => 50, 'height' => 50, 'type' => 'width', 'crop' => 'left-top'), 'thumb_' => array('width' => 100, 'height' => 100, 'type' => 'height', 'crop' => 'left-top')));
$images = array_merge($thumbs, $images);
foreach ($thumbs as $tmb) {
    logSection(file_exists($tmb), 'is file exists', 'thumbs');
}
try {
    $file = $fixtures . '/FordMustang.rotate90.jpg';
    $oldWidth = $image->getData('width');
    $oldHeight = $image->getData('height');
    $image->rotate(90)->save($file);
    logSection($oldWidth == $image->getData('height') && $oldHeight == $image->getData('width'), 'is rotated', 'rotate');
    $images[] = $file;
} catch (Exception $e) {
    logSection(false, $e->getMessage(), 'error');
}
$file = $fixtures . '/FordMustang.polygonMask.jpg';
$w = $image->getData('width');
$h = $image->getData('height');
$image->mask('polygon', array(0, 100, 100, 0, $w - 100, 0, $w, 100, $w, $h - 100, $w - 100, $h, 100, $h, 0, $h - 100), 100, array(0, 255, 0))->save($file);
$images[] = $image->getSavedName();
logSection(file_exists($file), 'image was masked with #0f0 color');
removeCreated($images);
logSection($count, '(recursive) number of items in fixtures dir = ' . $count);
$dir = $fs->readDir($fixtures, 'r', array('flags' => 0));
$count = count($dir);
logSection($count, '(recursive) number of files in fixtures dir = ' . $count);
$dir = $fs->readDir($fixtures, 'r', array('skip' => '/jpe?g$/i'));
$count = count($dir);
logSection($count, '(skip jpeg) number of items in fixtures dir = ' . $count);
$result = $fs->stat($file);
logSection(is_array($result), 'stat for file "' . basename($file) . '"');
$result = $fs->dynamicFileName($file);
logSection(basename($file), sprintf('dynamic file name "%s"', basename($result)));
$file = $fixtures . '/test_file_(3)';
$fs->touch($file);
$result = $fs->dynamicFileName($file);
logSection(basename($file), sprintf('dynamic file name "%s"', basename($result)));
$files[] = $file;
$fs->mirror($fixtures, $fixtures . '/mirror', array('image' => array('width' => 300, 'height' => 300, 'type' => 'width', 'crop' => 'left-top')));
logSection(is_dir($fixtures . '/mirror'), 'mirror fixtures directory');
echo "remove created dir? (yes/no)\n";
$result = fgets(STDIN);
$result = trim($result);
if (is_dir($fixtures . '/mirror') && $result == 'yes') {
    $fs->remove($fs->readDir($fixtures . '/mirror', 'r', array('sort' => true)));
}
$pathinfo = '/бла/путь/к/файлу.бах';
logSection(true, 'Check path info for utf8 characters');
foreach ($fs->getPathInfo($pathinfo) as $k => $part) {
    logSection($k, $part);
}
removeCreated($files);