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.
Related
I'm using Laravel Vapor to host a site. Up until now, I've not had a problem with the lack of a filesystem, but now I've hit a brick wall.
I'm trying to optimize .png and .jpeg files, and the libraries I found require a filesystem to write the compressed files:
Image Optimizer (https://github.com/spatie/image-optimizer)
PHP Image Cache (https://nielse63.github.io/php-image-cache/)
I'm guessing that I can set up an external service that runs on an additional traditional server... But I'd prefer to make it work with Vapor.
Any ideas?
Have you tried using GD Library or Imagick directly?
Using Imagick with files on s3 you can do something like this:
$s3 = \Storage::disk('s3');
$file = $s3->get('tmp/'.$uuid); // assuming Vapor upload to S3 here
$imagick = new \Imagick(); // extension can be added to Vapor.
$imagick->readImageBlob($file);
$imagick->thumbnailImage(200,200);// whatever size you are looking for.
$s3->put('path/on/s3/for/your/optimized/file',$imagick->getImageBlob(),['CacheControl' => 'max-age=10000000, public', 'ACL' => 'public-read']) // whatever options you need
Note both read and write are from/to s3 directly. No need to write to local disk
i have installed browsershot in my laravel project
I have installed puppeteer, installed chromium , my npm version is updated, but still i am unable to get the PDF of my simple html input , i have tried to take screenshot by URL method and save as image(It works), but my requirement is to generate PDF of my html.
This is my code in controller
$output=Browsershot::html($html)
->setNodeModulePath("/var/www/html/ProjectName/node_modules/")
->setChromePath("/usr/bin/chromium-browser")
->setNodeBinary('/usr/local/bin/node')
->setNpmBinary('/usr/local/bin/npm')
->showBackground()
->noSandbox()->timeout(60)
->save(public_path("DevTest.pdf");
Error Message:
"message": "The process "PATH=$PATH:/usr/local/bin NODE_PATH='/var/www/html/ProjectName/node_modules/' /usr/local/bin/node '/var/www/html/benesprint/vendor/spatie/browsershot/src/../bin/browser.js' '{"url":"file:\/\/\/tmp\/1933874416-0068512001600765779\/index.html","action":"pdf","options":{"path":"\/var\/www\/html\/ProjectName\/public\/DevTest.pdf","args":["--no-sandbox"],"viewport":{"width":800,"height":600},"displayHeaderFooter":false,"executablePath":"\/usr\/bin\/chromium-browser","timeout":60000,"printBackground":true}}'" exceeded the timeout of 60 seconds.",
**i would be grateful if you can help me out.**
i have similiar problem when browsershot inside container. and my step to resolve is like this:
Manual generate PDF from html using laravel tinker. if there is an error, try reinstall chromium and puppeteer library.
If success, then try remove all css and javascript links from html, and check for the result.
If success, then add --proxy-server="direct://" and --proxy-bypass-list=* into browsershot args
If step 3 is not working, then you can put css and javascript directly into view template or using php code to inclue those files like
<?php include public_path('css/styles.css') ?>
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!
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
I have a problem when using cloudinary in codeigniter. At first, i integrate the library by following answers from
Upload image to Cloudinary using PHP Codeigniter
It worked when i uploaded online image. But failed when i tried to upload local image. The error is
Error in loading http://localhost/admin-simple/assets/img/avatar1_small.jpg - 503 Service Unavailable
Here is my code :
Cloudinary::config(array( "cloud_name" => "my_cloud_name", "api_key" => "1234", "api_secret" => "ABCD" ));
$data['upload'] = \Cloudinary\Uploader::upload("http://localhost/admin-simple/assets/img/avatar1_small.jpg");
$this->load->view('partials/sukses_upload_gambar',$data);
Can anyone help me ? Because i've been stuck for hours. Thanks.
According to Cloudinary documentation, when uploading a file from your computer, you should specify the filepath instead of the URL of your local server:
\Cloudinary\Uploader::upload("/home/my_image.jpg")
http://cloudinary.com/documentation/php_integration