I am using Zikula with a modulestudio generated module.
The configuration of liip is the following:
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
The modulestudio generated code where the file is shrinked is here:
$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);
}
}
}
My webhosting has enabled the php extension for exif.
My question:
Is it possible to keep the EXIF data inside the jpg file if it becomes a new thumbnail file? Or must it be the original file which has to be shrinked?
This has been solved by reading out EXIF data before creating the thumbnail image.