Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在php中获取.ai文件的维度_Php_Imagemagick - Fatal编程技术网

如何在php中获取.ai文件的维度

如何在php中获取.ai文件的维度,php,imagemagick,Php,Imagemagick,我创建了一个用于图像转换的页面。我想将图像从.ai转换为.jpg。但问题是如何获取ai文件的尺寸(宽度和高度)。我一直尝试getimagesize(),但它不起作用,它会给我空白响应 这是我的php代码 if($fileType == 'psd' || $fileType == 'ai' || $fileType == 'eps' || $fileType == 'pdf'){ $source_file_name = get_file_name(basename($_FILES[

我创建了一个用于图像转换的页面。我想将图像从.ai转换为.jpg。但问题是如何获取ai文件的尺寸(宽度和高度)。我一直尝试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;
if($fileType=='psd'| |$fileType=='ai'| |$fileType=='eps'| |$fileType=='pdf'){
$source_file_name=get_file_name(basename($_FILES[“sfile”][“name”]);
如果(移动上传的文件($上传文件[“sfile”][“tmp上传文件名”],源上传路径。$源上传文件名)){
//获取图像的尺寸
$dimensions=getimagesize(源\上传\路径。$SOURCE\文件\名称);
回声“;
<?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";
打印($dimensions);退出;
您可以使用


请发布一些代码。请发表评论,但不要降级问题。如果您有任何疑问,我会在这里提供支持。嘿,Danon,谢谢您的回答,但我想将转换文件的维度设置为与源文件维度相同的维度。所以我需要它才能进行转换。为什么您不能在转换之前运行此代码?我粘贴的代码仅供使用获取宽度和高度。