Imagick stopped working in xampp - php

Installed Imagick in Xampp using this link. It was working properly but stopped working all of sudden.
Only thing I did in between, tried to configure gmail stmp setting in zend 3. Though I am not sure but it stopped working after that.
This is the error
Fatal error: Uncaught ImagickException: Imagick::__construct(): SSL
operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate
verify failed in C:\xampp\htdocs\restau\restau\public\image.php:55
Stack trace: #0 C:\xampp\htdocs\restau\restau\public\image.php(55):
Imagick->__construct('https://storage...') #1 {main} Next
ImagickException: Failed to read the file in
C:\xampp\htdocs\restau\restau\public\image.php:55 Stack trace: #0
C:\xampp\htdocs\restau\restau\public\image.php(55):
Imagick->__construct('https://storage...') #1 {main} thrown in
C:\xampp\htdocs\restau\restau\public\image.php on line 55
Edit 1
Followed this link and changed
curl.cainfo ="C:\xampp\perl\vendor\lib\Mozilla\CA\cacert.pem"
openssl.cafile="C:\xampp\perl\vendor\lib\Mozilla\CA\cacert.pem"
this is the error I am getting now
Fatal error: Uncaught ImagickException: Failed to read the file in C:\xampp\htdocs\restau\restau\public\image.php:55 Stack trace: #0 C:\xampp\htdocs\restau\restau\public\image.php(55): Imagick->__construct('https://storage...') #1 {main} thrown in C:\xampp\htdocs\restau\restau\public\image.php on line 55
Below is the code in which image is not getting loaded, this was working properly until few days ago.
<img src="/image.php?filename=https://storage.googleapis.com/xxxxxx/uploads_56ea606ea4685.jpg&width=380&height=255" alt="">
Thanks in advance!!

This is how I fixed this problem.
I replaced this part of code
if(filter_var($imagePath, FILTER_VALIDATE_URL)) {
$imagick = new Imagick($imagePath);
} else {
$imagick = new Imagick(getcwd().$imagePath);
}
with this
if(filter_var($imagePath, FILTER_VALIDATE_URL)) {
$tempFile = 'temp/file-'.uniqid().'.jpg';
copy($imagePath, $tempFile);
$imagick = new Imagick(getcwd().'/'.$tempFile);
unlink(getcwd().'/'.$tempFile);
} else {
$imagick = new Imagick(getcwd().$imagePath);
}

Related

How can I solve this fatal error in my microweber/screen package that I installed in my php project?

I try to use https://packagist.org/packages/microweber/screen this PHP package, I just installed it in my project and I run the index.php file but there is an error : Any idea ?
Here is my code in my index.php file:
$url = 'https://github.com';
$screenCapture = new Capture($url);
$screenCapture->setWidth(1200);
$screenCapture->setHeight(800);
$fileLocation = 'files';
$screenCapture->save($fileLocation);
echo $screenCapture->getImageLocation();
Here is the error I had received:
[15-Feb-2023 20:51:43 UTC] PHP Fatal error: Uncaught Screen\Exceptions\PhantomJsException: sh:
/home/bloggors/capturewebpage.bloggors.com/vendor/microweber/screen/bin/phantomjs: Permission denied in
/home/bloggors/capturewebpage.bloggors.com/vendor/microweber/screen/src/Capture.php:259
Stack trace:
#0 /home/bloggors/capturewebpage.bloggors.com/controller/index.php(12): Screen\Capture->save('files')
#1 /home/bloggors/capturewebpage.bloggors.com/router.php(46): include_once('/home/bloggors/...')
#2 /home/bloggors/capturewebpage.bloggors.com/router.php(7): route('/', 'controller/inde...')
#3 /home/bloggors/capturewebpage.bloggors.com/routes.php(14): get('/', 'controller/inde...')
#4 {main}
thrown in /home/bloggors/capturewebpage.bloggors.com/vendor/microweber/screen/src/Capture.php on line 259
Any help will be of great help to me ☺

Uncaught ImagickException: UnableToOpenBlob 'uploads/Datapath.pdf': No such file or directory # error/blob.c/OpenBlob/3315

I am trying to use ImageMagick to covert the first page of pdf to image but it is not working, I tried all the solutions from Stack Overflow and some other websites such as using real path but none is working.
<?php
$image=new Imagick();
$image->readImage('uploads/Datapath.pdf[0]');
$image->writeImages('uploads/ima.jpg');
?>
This is the code but not working and is giving error
Fatal error: Uncaught ImagickException: UnableToOpenBlob 'uploads/Datapath.pdf': No such file or directory # error/blob.c/OpenBlob/3315 in F:\xampp\htdocs\Web_Engineering\webproj\try.php:3 Stack trace: #0 F:\xampp\htdocs\Web_Engineering\webproj\try.php(3): Imagick->readImage('uploads/Datapat...') #1 {main} thrown in F:\xampp\htdocs\Web_Engineering\webproj\try.php on line 3

PHP code run in terminal but not working in chrome

I have used pdf-to-image to build my new package. and I got some problem here:
<?php
// die(echo getenv('HOME'););
require_once(__DIR__.'/vendor/autoload.php');
$fileone = realpath('demo.pdf');
$pdf = new Spatie\PdfToImage\Pdf($fileone);
$pdf->saveImage(__DIR__.'upload/');
?>
I required it into index file but I can't run this code on Chrome but it working when I run by terminal, how can I fix it?
UPDATE Adding error shared in comments:
Fatal error: Uncaught ImagickException: Failed to read the file in /opt/lampp/htdocs/pdf2Image/vendor/spatie/pdf-to-image/src/Pdf.php:44 Stack trace: #0 /opt/lampp/htdocs/pdf2Image/vendor/spatie/pdf-to-image/src/Pdf.php(44): Imagick->__construct('/opt/lampp/htdo...') #1 /opt/lampp/htdocs/pdf2Image/index.php(6): Spatie\PdfToImage\Pdf->__construct('/opt/lampp/htdo...') #2 {main} thrown in /opt/lampp/htdocs/pdf2Image/vendor/spatie/pdf-to-image/src/Pdf.php on line 44

simpleexcel : I get an error when I changed the host

Recently I have changed my host. On the previous host, every thing was ok, but now on the new host I get following error..
Please direct me to the host so I can solve this problem ASAP???
Fatal error: Uncaught exception 'Exception' with message 'Document namespace isn't a valid Excel XML 2003 Spreadsheet' in /home/jalali/public_html/admin/SimpleExcel/Parser/XMLParser.php:198
Stack trace:
#0 /home/jalali/public_html/admin/SimpleExcel/Parser/XMLParser.php(305): SimpleExcel\Parser\XMLParser->parseDOM(Object(SimpleXMLElement))
#1 /home/jalali/public_html/admin/#dmin.php(28): SimpleExcel\Parser\XMLParser->loadFile('../archive/1371...')
#2 {main} thrown in /home/jalali/public_html/admin/SimpleExcel/Parser/XMLParser.php on line 198

Imagick: unable to open file

When simply calling the Imagick class:
$image = new Imagick('/images/magick/atmsk.png');
I get the error message:
Fatal error: Uncaught exception 'ImagickException' with message
'unable to open file `/images/magick/atmsk.png' #
png.c/ReadPNGImage/2889' in .../imag.php:4 Stack trace: #0
.../imag.php(4): Imagick->__construct('/images/magick/...') #1 {main}
thrown in .../imag.php
I have checked memory available as per another posting here and that is ok!
Use the full path to the image, for example:
$image = new Imagick($_SERVER['DOCUMENT_ROOT'] . '/images/magick/atmsk.png');

Categories