我与订书机的自动旋转功能有些不一致,希望有人能解释发生了什么。
我的样式在 Eloquent 模型上定义如下:
'styles' => [
'thumbnail' => [
'dimensions' => '300',
'auto_orient' => true,
'convert_options' => ['quality' => 100],
],
'standard' => [
'dimensions' => 'x275',
'auto_orient' => true,
'convert_options' => ['quality' => 100],
],
'zoom' => function($file, $imagine) {
$image = $imagine
->setMetadataReader(new \Imagine\Image\Metadata\ExifMetadataReader)
->open($file->getRealPath());
// Auto rotate the image
$filter = new \Imagine\Filter\Basic\Autorotate;
$filter->apply($image);
// Get the current size
$size = $image->getSize();
// Scale down to zoom size only if
// image is wide enough.
if ($size->getWidth() > 1280) {
$newSize = $size->widen(1280);
$image->resize($newSize);
}
return $image;
}
]
问题是,对于特定图像,zoom
样式无法正常工作。即使原件已经直立,它也会将图像旋转 90 度。
这是原始图像的屏幕截图,您可以看到它是直立的:
这是经过zoom
样式处理后的图像截图。它旋转了 90 度:
如您所见,我也将and样式autorotate
设置为 true ,但是这些图像没有被旋转 90 度并且在处理后正确显示。thumbnail
standard
奇怪的是,当我检查原始图像的 exif 方向数据时,它的值为 6,这意味着图像应该旋转 90 度。如果是这样,为什么其他样式也不旋转?
$imagine = new Imagine\Imagick\Imagine;
$image = $imagine->open('https://s3.amazonaws.com/path/to/original/image.jpg');
echo $image->metadata()->toArray()['ifd0.Orientation'];
// Output is 6
所以我想知道如果这个图像已经是直立的,为什么 exif 方向是 6。另外,为什么图像只为zoom
样式旋转?