在 liipimaginebundle 中使用调整大小选项时如何保留 exif 数据

how to keep exif data when using resize option in liipimaginebundle

我将 Zikula 与 modulestudio 生成的模块一起使用。

liip的配置如下:

liip_imagine:
    resolvers:
        default:
            web_path:
                web_root: "%kernel.root_dir%/../"
                cache_prefix: "web/imagine/cache"
    loaders:
        zikula_root:
            filesystem:
                data_root: "%kernel.root_dir%/../"
    filter_sets:
        cache: ~
        my_thumb: # sample
            jpeg_quality: 90
            png_compression_level: 7
            filters:
                thumbnail: { size: [120, 90], mode: outbound }
                background: { size: [124, 94], position: center, color: '#000000' }
        zkroot: # sample using zikula root
            data_loader: zikula_root
            jpeg_quality: 90
            png_compression_level: 7
            filters:
                thumbnail: { size: [100, 100], mode: inset }
        # add more filters as required for your personal application

压缩文件的modulstudio生成代码在这里:

$isImage = in_array($extension, $this->imageFileTypes);
if ($isImage) {
    // check if shrinking functionality is enabled
    $fieldSuffix = ucfirst($objectType) . ucfirst($fieldName);
    if (isset($this->moduleVars['enableShrinkingFor' . $fieldSuffix]) && true === (bool)$this->moduleVars['enableShrinkingFor' . $fieldSuffix]) {
        // check for maximum size
        $maxWidth = isset($this->moduleVars['shrinkWidth' . $fieldSuffix]) ? $this->moduleVars['shrinkWidth' . $fieldSuffix] : 800;
        $maxHeight = isset($this->moduleVars['shrinkHeight' . $fieldSuffix]) ? $this->moduleVars['shrinkHeight' . $fieldSuffix] : 600;
        $thumbMode = isset($this->moduleVars['thumbnailMode' . $fieldSuffix]) ? $this->moduleVars['thumbnailMode' . $fieldSuffix] : ImageInterface::THUMBNAIL_INSET;

        $imgInfo = getimagesize($destinationFilePath);
        if ($imgInfo[0] > $maxWidth || $imgInfo[1] > $maxHeight) {
            // resize to allowed maximum size
            ini_set('memory_limit', '1G');
            $imagine = new Imagine();
            $image = $imagine->open($destinationFilePath);
            $image->thumbnail(new Box($maxWidth, $maxHeight), $thumbMode)
                  ->save($destinationFilePath);
        }
    }
}

我的虚拟主机为 exif 启用了 php 扩展。

我的问题:

如果成为新的缩略图文件,是否可以将 EXIF 数据保留在 jpg 文件中?还是一定要压缩原文件?

已通过在创建缩略图之前读取 EXIF 数据解决此问题。