doutuo7156 2018-11-16 05:44 采纳率: 100%
浏览 181

我如何使用ImageMagick将Adobe Illustrator艺术品(AI)文件调整为增加尺寸而不会降低PHP的质量?

When user upload AI file then if Dimension of an uploaded file is less than or equal to (180 x 180) then I want to resize this file to increased dimension (277 x 277) and then convert it to JPG. I tried code mentioned below. I tried all ways which are commented in the code.

    $image_rs = new Imagick();
    $image_rs->readimage(realpath(SOURCE_UPLOAD_PATH.$source_file_name));
    if($fileType == "ai"){
        $image_rs->setIteratorIndex(0);
    }
    $dimensions = $image_rs->getImageGeometry();
    $width = $dimensions['width'];
    $height = $dimensions['height'];
    if($width <= 180 && $height <= 180){
        //$image_rs->magnifyImage();
        $image_rs->setImageFormat($source_file_ext);
        $image_rs->scaleImage(277,0); 
        // $image_rs->adaptiveResizeImage(277,277);
        // $image_rs->resizeImage(277,277,\Imagick::FILTER_CATROM, 1, true); 
        $image_rs->writeImage(realpath(RESIZED_UPLOAD_PATH)."/". $source_file_name);

        $image = new Imagick();
        $image->readimage(realpath(RESIZED_UPLOAD_PATH.$source_file_name));
        if($fileType == "ai"){
            $image->setIteratorIndex(0);
        }
        $dimensions = $image->getImageGeometry();
        $width = $dimensions['width'];
        $height = $dimensions['height'];
        $image->thumbnailImage($width, $height);
        $image->writeImage(realpath(CONVERTED_UPLOAD_PATH)."/". $source_file_name_without_ext.".jpg");
    }

Issue: By using this code image is resized successfully but resized AI file also becomes blurry. because of Imagick library when resizing the image it converts AI file to jpg. AI file is vector file so there is no chance to become blurry even if we increase dimension. So how I can do this by imagemagick?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料