Imagick не возвращает разрешение изображения - PullRequest
0 голосов
/ 25 мая 2018

для прикрепленных типов изображений Imagick не возвращает разрешение (Получение только высоты и ширины)

Вот мой код.

$image = new Imagick($tempPath);
$resolutions = $image->getImageResolution();
$imageGeometry = $image->getImageGeometry();
if ($ext == 'bmp' || $ext == 'png') {
                        $xresolution = $resolutions['x'] * 2.54;
                        $yresolution = $resolutions['y'] * 2.54;
                    } else {
                        $xresolution = $resolutions['x'];
                        $yresolution = $resolutions['y'];
                    }
$msg = array("status" => "success", "imageHeight" => $imageGeometry['height'], "imageWidth" => $imageGeometry['width'], "HorizontalResolution" => $xresolution, "VerticalResolution" => $yresolution);

1 Ответ

0 голосов
/ 25 мая 2018

Я запустил это:

#!/usr/local/bin/php -f
<?php
$image = new Imagick("thing.jpg");
$resolutions = $image->getImageResolution();
$imageGeometry = $image->getImageGeometry();
var_dump($resolutions);
var_dump($imageGeometry)
?>

И получил это, что мне кажется правильным:

array(2) {
  ["x"]=>
  float(72)
  ["y"]=>
  float(72)
}
array(2) {
  ["width"]=>
  int(2362)
  ["height"]=>
  int(1476)
}

Вы не говорите ни то, что получили, ни то, что ожидали.Возможно, проверьте, правильно ли установлено и обновлено ваше программное обеспечение.

Exiftool согласен:

exiftool thing.jpg | more
ExifTool Version Number         : 10.80
File Name                       : thing.jpg
Directory                       : .
File Size                       : 640 kB
File Modification Date/Time     : 2018:05:25 17:11:21+01:00
File Access Date/Time           : 2018:05:25 17:11:39+01:00
File Inode Change Date/Time     : 2018:05:25 17:11:21+01:00
File Permissions                : rw-r--r--
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Resolution Unit                 : inches
X Resolution                    : 72          <--- HERE
Y Resolution                    : 72          <--- HERE
Image Width                     : 2362
Image Height                    : 1476
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Image Size                      : 2362x1476
Megapixels                      : 3.5
iMac:~/StackOverflow: exiftool -v3 thing.jpg | more
  ExifToolVersion = 10.80
  FileName = thing.jpg
  Directory = .
  FileSize = 655131
  FileModifyDate = 1527264681
  FileAccessDate = 1527264720
  FileInodeChangeDate = 1527264681
  FilePermissions = 33188
  FileType = JPEG
  FileTypeExtension = JPG
  MIMEType = image/jpeg
JPEG APP0 (14 bytes):
    0006: 4a 46 49 46 00 01 01 01 00 48 00 48 00 00       [JFIF.....H.H..]
  + [BinaryData directory, 9 bytes]
  | JFIFVersion = 1 1
  | - Tag 0x0000 (2 bytes, int8u[2]):
  |     000b: 01 01                                           [..]
  | ResolutionUnit = 1
  | - Tag 0x0002 (1 bytes, int8u[1]):
  |     000d: 01                                              [.]
  | XResolution = 72                         <--- HERE
  | - Tag 0x0003 (2 bytes, int16u[1]):
  |     000e: 00 48                                           [.H]
  | YResolution = 72                         <--- HERE
...