Imagekit 未返回转换 url

Imagekit not returing transformed url

我的应用程序中有以下代码可以将图片上传到 imagekit。 我正在使用这个 official package

        function uploadImage ($base64Img, $fileName, $folder, $h, $w, $aratio){
        $imageKit = new ImageKit(
            "public_key,
            "private_key",
            "urlEndpoint"
        );
        $config = [
            'file' => $base64Img, //imageconverted to Base64
            'fileName' => $fileName,
            'folder' => $folder, //foldername
            "transformation" => array(
                array(
                    "height" => "300",
                    "width" => "400",
                )
            )
        ];

        // if (isset($h) && isset($w)) {
        //     $config['transform'] = [
        //         [
        //             "height" => $h,
        //             "width" => $w
        //         ]
        //     ];
        // }
        
        // if (isset($aratio)) {
        //     $config['transform'] = [
        //         [
        //             "ar" => '1:1',
        //         ]
        //     ];
        // }

        // Upload Image - base64
        $uploadFile = $imageKit->upload($config);

        return($uploadFile->success->url);
}

根据官方文档 return url 应该是这样的:

https://ik.imagekit.io/your_imagekit_id/endpoint/tr:h-300,w-400/my_file_name.jpg;

但我得到的只是 url 没有转换:

https://ik.imagekit.io/your_imagekit_id/endpoint/file_name.jpg

谁能帮我解决这个问题?

根据他们的文档,他们 return 一个 json 响应:

{
    "fileId" : "598821f949c0a938d57563bd",
    "name": "file1.jpg",
    "url": "https://ik.imagekit.io/your_imagekit_id/images/products/file1.jpg",
    "thumbnailUrl": "https://ik.imagekit.io/your_imagekit_id/tr:n-media_library_thumbnail/images/products/file1.jpg",
    "height" : 300,
    "width" : 200",
    "size" : 83622,
    "filePath": "/images/products/file1.jpg",
    "tags": ["t-shirt","round-neck","sale2019"],
    "isPrivateFile" : false,
    "customCoordinates" : null,
    "fileType": "image"
}

来源:https://docs.imagekit.io/api-reference/upload-file-api/server-side-file-upload#response-code-and-structure-json

现在根据您使用的包的文档,您可以使用 url 生成方法生成带有转换的 url:

$imageURL = $imageKit->url(array(
    "path" => "/default-image.jpg",
    "transformation" => array(
        array(
            "height" => "300",
            "width" => "400",
        )
    )
));

来源:https://github.com/imagekit-developer/imagekit-php#url-generation