Gregwar / ImageBundle

Image manipulation bundle for Symfony 2
MIT License
195 stars 50 forks source link

save failed but i can't get exception or error info? #112

Closed lcp0578 closed 6 years ago

lcp0578 commented 6 years ago
class ImageService
{
    private $appRoot;
    private $handling;

    public function __construct($appRoot, ImageHandling $handling)
    {
        $this->appRoot = $appRoot;
        $this->handling = $handling;
    }

    /**
     * 打水印,并生成缩略图
     * @param unknown $address
     * @param string $thumb 默认为false,不生成缩略图
     */
    public function run($filePath, $address, $thumb = false)
    {
        $fullPath = $this->appRoot . '/../web/' . $filePath;
        $font = $this->appRoot . '/../web/public/fonts/yahei.ttf';
        $image = $this->handling->open($fullPath);
        dump($image);
        $image->write($font, $address, 10, 20, 12, 0, 'white');
        $image->write($font, date('Y-m-d H:i:s'), $image->width() - 150, 20, 12, 0, 'white');
        dump($fullPath.'.jpg');
        $image->saveJpeg($fullPath.'.jpg', 80);
        dump($image);
        if($thumb){
            $image->zoomCrop(50, 50, 0xffffff, 'center', 'center')->saveJpeg($fullPath.'.min.jpg', 30);
        }
        dump($image);
    }
}

service define

    base.image_service:
        class: BaseBundle\Service\ImageService
        arguments: ["%kernel.root_dir%", "@image.handling"]

image bundle configure in config.yml

    gregwar_image:
        cache_dir: image_cache
        throw_exception: true

the debug output info: debug

It has been saved several times and then failed. I can't find the valid error information.

thx

lcp0578 commented 6 years ago

version info: compser.json

"gregwar/image": "^2.0",
"gregwar/image-bundle": "dev-master",

php7 & symfony info:

chunpengs-MacBook-Pro:adjust lcp0578$ php7 -v
PHP 7.2.4 (cli) (built: Apr  4 2018 09:44:31) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.4, Copyright (c) 1999-2018, by Zend Technologies
chunpengs-MacBook-Pro:adjust lcp0578$ php7 bin/console
Symfony 3.4.11 (kernel: app, env: dev, debug: true)