mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
31f336d690 | |||
0e4365795b | |||
96769f52cf |
35
scripts/fix-dimensions
Executable file
35
scripts/fix-dimensions
Executable 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);
|
@ -1,6 +1,9 @@
|
||||
<?php
|
||||
namespace Szurubooru\Services\ImageManipulation;
|
||||
|
||||
\Imagick::setResourceLimit(\Imagick::RESOURCETYPE_MEMORY, 33554432);
|
||||
\Imagick::setResourceLimit(\Imagick::RESOURCETYPE_MAP, 33554432);
|
||||
|
||||
class ImagickImageManipulator implements IImageManipulator
|
||||
{
|
||||
public function loadFromBuffer($source)
|
||||
|
@ -98,8 +98,8 @@ class Validator
|
||||
throw new \DomainException('Tags cannot be empty.');
|
||||
|
||||
//: causes problems with complex search (e.g. id:5).
|
||||
if (strpos($tag, ':') > 0)
|
||||
throw new \DomainException('Colon in tag may appear only at the beginning.');
|
||||
if (strpos($tag, ':') !== false && strpos($tag, ':') !== 0 && strpos($tag, ':') !== strlen($tag) - 1)
|
||||
throw new \DomainException('Colon in tag may appear only at the beginning or end.');
|
||||
|
||||
$this->validateMaxLength($tag, 64, 'Tag');
|
||||
|
||||
|
Reference in New Issue
Block a user