Php Imagick未返回图像分辨率
这是我的密码Php Imagick未返回图像分辨率,php,imagemagick,imagick,imagemagick-convert,Php,Imagemagick,Imagick,Imagemagick Convert,这是我的密码 $image = new Imagick($tempPath); $resolutions = $image->getImageResolution(); $imageGeometry = $image->getImageGeometry(); if ($ext == 'bmp' || $ext == 'png') { $xresolution = $resolutions['x'] * 2.54;
$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);
我运行了以下命令:
#!/usr/local/bin/php -f
<?php
$image = new Imagick("thing.jpg");
$resolutions = $image->getImageResolution();
$imageGeometry = $image->getImageGeometry();
var_dump($resolutions);
var_dump($imageGeometry)
?>
你没有说你得到了什么,也没有说你期望得到什么。可能需要检查您的软件是否正确安装并处于最新状态
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
exiftool thing.jpg |更多
ExifTool版本号:10.80
文件名:thing.jpg
目录:。
文件大小:640KB
文件修改日期/时间:2018:05:25 17:11:21+01:00
文件访问日期/时间:2018:05:25 17:11:39+01:00
文件索引节点更改日期/时间:2018:05:25 17:11:21+01:00
文件权限:rw-r--r--
文件类型:JPEG
文件扩展名:jpg
MIME类型:图像/jpeg
JFIF版本:1.01
分辨率单位:英寸
我的回答解决了你的问题吗?如果是这样,请考虑接受它作为您的答案-点击空心蜱/支票旁边的选票计数。如果没有,请说出什么不起作用,以便我或其他人可以进一步帮助您。谢谢对谢谢,再次谢谢。
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