我们如何在 php 中获取 .ai 文件的尺寸
How we can get dimensions of .ai file in php
我为图像创建了一个页面 conversion.I 想将图像从 .ai 转换为 .jpg.But 问题是如何获得 AI 的尺寸(宽度和高度)file.I已经尝试过 getimagesize() 但它不起作用,它给了我空白的回应。
这是我的 php 代码
if($fileType == 'psd' || $fileType == 'ai' || $fileType == 'eps' || $fileType == 'pdf'){
$source_file_name = get_file_name(basename($_FILES["sfile"]["name"]));
if (move_uploaded_file($_FILES["sfile"]["tmp_name"],SOURCE_UPLOAD_PATH.$source_file_name)) {
//get dimensions of image
$dimensions = getimagesize(SOURCE_UPLOAD_PATH.$source_file_name);
echo "<pre>";
print_r($dimensions);exit;
您可以使用Imagick
<?php
$image = new Imagick();
$image->readimage($imagePath);
if ($fileType == "psd" || $fileType == "ai"){
$image->setIteratorIndex(0);
}
$dimensions = $image->getImageGeometry();
$width = $dimensions['width'];
$height = $dimensions['height'];
echo "Your image is $width by $height pixels";
我为图像创建了一个页面 conversion.I 想将图像从 .ai 转换为 .jpg.But 问题是如何获得 AI 的尺寸(宽度和高度)file.I已经尝试过 getimagesize() 但它不起作用,它给了我空白的回应。
这是我的 php 代码
if($fileType == 'psd' || $fileType == 'ai' || $fileType == 'eps' || $fileType == 'pdf'){
$source_file_name = get_file_name(basename($_FILES["sfile"]["name"]));
if (move_uploaded_file($_FILES["sfile"]["tmp_name"],SOURCE_UPLOAD_PATH.$source_file_name)) {
//get dimensions of image
$dimensions = getimagesize(SOURCE_UPLOAD_PATH.$source_file_name);
echo "<pre>";
print_r($dimensions);exit;
您可以使用Imagick
<?php
$image = new Imagick();
$image->readimage($imagePath);
if ($fileType == "psd" || $fileType == "ai"){
$image->setIteratorIndex(0);
}
$dimensions = $image->getImageGeometry();
$width = $dimensions['width'];
$height = $dimensions['height'];
echo "Your image is $width by $height pixels";