I have the following code in my app to upload image to imagekit. And i'm using this 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);
}
According to the official docs the return url should be like this:
https://ik.imagekit.io/your_imagekit_id/endpoint/tr:h-300,w-400/my_file_name.jpg;
But all I get is url without transformation:
https://ik.imagekit.io/your_imagekit_id/endpoint/file_name.jpg
Can anyone help me out on this ?
According to their docs they return a json response:
Source: https://docs.imagekit.io/api-reference/upload-file-api/server-side-file-upload#response-code-and-structure-json
Now according to the docs of the package you are using you can generate an url with transformation using the url generation method:
Source: https://github.com/imagekit-developer/imagekit-php#url-generation