Can you share one of the urls that fails, so we can try it out?
Jan 18, 2023
15
Level 1
Image intervention - image source not readable
I am using file_get_contents() php function to get images from the url (importing products to database and fetching images url from the excel sheet) and then using image intervention to upload to my server. Some images are downloaded and then uploaded but some throughs exception 'image source not readable', Kindly look at my code and help me
$image = null;
if (!empty($value[1]) AND @fopen($value[1], 'r')) {
$image = @file_get_contents($value[1]);
}
$product_image = '';
if ($image) {
$directory = 'products';
$name = $this->runCode() . '-' . Str::slug($value[0]) . time();
$image_url = $directory . $name;
$product_image = env('OBJECT_URL') . $image_url . '.png';
UploadHelper::base64($directory, $image, $name, 'png');
}
my upload helper:
public static function base64($directory, $image, $name, $format)
{
$imageRender = Image::make($image)->encode($format);
Storage::disk('linode')->put($directory . $name . '.' . $format, $imageRender, 'public');
}
Please or to participate in this conversation.