Laravel image intervention on localhost not working - image

I tried to use this code
$image = new ImageManager();
$image = $image->make($path);
and namespace is use Intervention\Image\ImageManager;
and I get this error
localhost is currently unable to handle this request.
what is the problem?

you need to specify which version of intervention you are using.
Still check your namespace it needs Intervention\Image\ImageServiceProvider.

Related

Laravel upload .heic image

I have added Imagick library and tried to upload .heic image
$image = new \Imagick();
$image->readImage($request->image);
And always return this error
NoDecodeDelegateForThisImageFormat `HEIC' # error/constitute.c/ReadImage/509
I tried a lot of solutions but nothing works.
phpinfo
I solved the problem by adding this library then I make shell_exec(convert $path $newPath), Then Image::make($newPath)and finally upload the image after converted it from the serve.

how use Image::make Laravel parse in ftp server using Storage

`
My Problem is the upload image laravel still error.
Internal server error, IDK where is wrong in my code
I'm using FTP cause it should be upload to external storage
Image intervention stream() facade used for upload image:
http://image.intervention.io/api/stream
$getFile = Image::make($request->file('image')->path())->resize(320, 240);
$image_thumb = $getFile->stream();
Storage::disk('ftp')->put($filenametostore, $image_thumb->__toString());

laravel XMLHttpRequest cannot load https://website.com/images/1554690945.png. No 'Access-Control-Allow-Origin' header is present

I'm having problem with my laravel file system CORS, I'm trying to cache the image from the url (which is also my website) in my ionic application but it's failing because of the error. I tried the image from https://reqres.in/api/users/1 and there is no problem caching the image in my ionic application. I guess the problem here is in my laravel website
In one of my current projects I have to save 200+ images in my Ionic App from a request to my server.
The way I handled this problem was converting the image to Base64 using Image Intervention and responding to the request with back to the app to then save the Base64 in the Ionic Storage like so.
Laravel Controller
public function grabImages(Request $request){
$image = (string) Image::make('public/bar.png')->encode('data-url');
$data = {
'base64' : $image,
'file_name' : 'test'
}
return $data;
}
Ionic
After receiving the data you can just store it in the Ionic Storage and access it wherever you would like to, even offline.
To display it all you have to do is set the image source to the Base64.
Using this method also solves a few problems, such as the user cannot see the images in the image gallery, as well as allows you to store them and use them offline for as long as you would like and remove them whenever.
As ImJT said I am using the barryvdh's laravel-cors plugin as well.
Hope this answered your question, good luck!

Laravel - Can't download file from storage at Ubuntu server with Nginx

So I'm testing that a Laravel app that I just deployed to an Ubuntu server with Nginx works correctly, and I reached a point where I need to download some files that were upload from the front end using Angular.
I can upload files with no problem and I made sure that those are actually in the server and yeah, they are saved as expected.
However when I need to download them I get the error: "Failed to create the file"
It worked on my local machine, so I'm guessing is kind of a configuration problem but I'm not sure what to change yet.
The file is being requested through a GET request with Http with the header: { responseType: ResponseContentType.Blob }, the latter being part of Angular.
And in Laravel this is how I'm returning the file:
public function download($activityId) {
$activity = $activity = Activity::find($activityId, ['student_id', 'file_storage']);
$file = public_path() . '/storage/activityFiles/' . $activity['student_id'] . '/' . $activity['file_storage'];
return response()->download($file);
}
What can I be missing?
I decided to take a look at the laravel logs to see a little further the problem.
The problem was that I forgot to create the symbolic link to the storage.
That fixed the issue.

Laravel Intervention Image: Save image directly from dropbox url

I was trying to store image from dropbox url to my local folder with laravel Intervention , but with it i am getting errors after error.
Can anyone please tell me how can i do so ?
My code is this
$path = 'https://www.dropbox.com/s/vwswp91fiz0m1wd/1200px-Good_Food_Display_-_NCI_Visuals_Online.jpg?dl=0';
$filename = explode('?',basename($path))[0];
Image::make($path)->save('images/'.$filename);
The error i am getting for this is
Unable to init from given binary data.
So i tried the solution from of of stackoverflow post
$path = 'https://www.dropbox.com/s/vwswp91fiz0m1wd/1200px-Good_Food_Display_-_NCI_Visuals_Online.jpg?dl=0';
$filename = explode('?',basename($path))[0];
$path = base64_decode($path);
Image::make($path)->save('images/'.$filename);
But that gave me another error.
I tried looking on goggle but i didn't find any solid answer that works for my case
Can anyone please help me on this how to download image from dropbox url and save to loacal storage ? Or do i have to add dropbox api or something??
The dropbox link that you used https://www.dropbox.com/s/vwswp91fiz0m1wd/1200px-Good_Food_Display_-_NCI_Visuals_Online.jpg?dl=0 is a image preview page, which is not a valid image content. You can use force download mode to fetch the image content from dropbox, by editing the query parameter from ?dl=0 to ?raw=1.
$path = 'https://www.dropbox.com/s/vwswp91fiz0m1wd/1200px-Good_Food_Display_-_NCI_Visuals_Online.jpg?raw=1';
Image::make($path)->save('images/'.$filename);
See also: Force a file or folder to download, or to render on dropbox.com

Resources