3 Commits
1.1.0 ... 1.x

Author SHA1 Message Date
rr-
31f336d690 Added script for fixing image dimensions 2016-07-28 19:14:43 +02:00
rr-
0e4365795b Reduced Imagick memory consumption 2016-07-28 19:14:23 +02:00
rr-
96769f52cf Allowed colons at the end of tags 2016-06-18 22:01:03 +02:00
3 changed files with 40 additions and 2 deletions

35
scripts/fix-dimensions Executable file
View File

@ -0,0 +1,35 @@
#!/usr/bin/php
<?php
require_once(__DIR__
. DIRECTORY_SEPARATOR . '..'
. DIRECTORY_SEPARATOR . 'src'
. DIRECTORY_SEPARATOR . 'Bootstrap.php');
use Szurubooru\Injector;
use Szurubooru\Dao\PublicFileDao;
use Szurubooru\Dao\PostDao;
use Szurubooru\Services\ImageConverter;
use Szurubooru\Services\ImageManipulation\ImageManipulator;
$publicFileDao = Injector::get(PublicFileDao::class);
$postDao = Injector::get(PostDao::class);
$imageConverter = Injector::get(ImageConverter::class);
$imageManipulator = Injector::get(ImageManipulator::class);
if (!isset($argv[1]))
{
echo "No post ID specified.";
return;
}
$postId = intval($argv[1]);
$post = $postDao->findById($postId);
if (!$post)
{
echo "Post with this ID was not found in the database.";
return;
}
$image = $imageConverter->createImageFromBuffer($post->getContent());
$post->setImageWidth($imageManipulator->getImageWidth($image));
$post->setImageHeight($imageManipulator->getImageHeight($image));
$postDao->save($post);

View File

@ -1,6 +1,9 @@
<?php <?php
namespace Szurubooru\Services\ImageManipulation; namespace Szurubooru\Services\ImageManipulation;
\Imagick::setResourceLimit(\Imagick::RESOURCETYPE_MEMORY, 33554432);
\Imagick::setResourceLimit(\Imagick::RESOURCETYPE_MAP, 33554432);
class ImagickImageManipulator implements IImageManipulator class ImagickImageManipulator implements IImageManipulator
{ {
public function loadFromBuffer($source) public function loadFromBuffer($source)

View File

@ -98,8 +98,8 @@ class Validator
throw new \DomainException('Tags cannot be empty.'); throw new \DomainException('Tags cannot be empty.');
//: causes problems with complex search (e.g. id:5). //: causes problems with complex search (e.g. id:5).
if (strpos($tag, ':') > 0) if (strpos($tag, ':') !== false && strpos($tag, ':') !== 0 && strpos($tag, ':') !== strlen($tag) - 1)
throw new \DomainException('Colon in tag may appear only at the beginning.'); throw new \DomainException('Colon in tag may appear only at the beginning or end.');
$this->validateMaxLength($tag, 64, 'Tag'); $this->validateMaxLength($tag, 64, 'Tag');