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

我如何使用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条回答 默认 最新

    报告相同问题?