Imagick: unable to open file - php

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');

Related

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

Imagick stopped working in xampp

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);
}

PhpPowerpoint fatal error

I was in the process of viewing an existing pptx file using the reader of Powerpoint2007 but
i get this fatal error:
Fatal error: Uncaught exception 'Exception' with message 'File ./resources/phppowerpoint_logo.gif not found!' in C:\xampp\PHPPresentation-master\src\PhpPresentation\Shape\Drawing.php:107 Stack trace: #0 C:\xampp\PHPPresentation-master\samples\Sample_Header.php(49): PhpOffice\PhpPresentation\Shape\Drawing->setPath('./resources/php...') #1 C:\xampp\htdocs\sanagumana.php(8): include_once('C:\xampp\PHPPre...') #2 {main} thrown in C:\xampp\PHPPresentation-master\src\PhpPresentation\Shape\Drawing.php on line 107
I already check the resources folder and phppowerpoint_logo.gif is there. What can I do??

Path to access file with php

I have my files into /var/www but i need access sqlite file into folder
/home/my/words
I'm trying do this:
$dir = 'sqlite:../../home/my/words/bd.sqlite';
But path doesn't work.
Error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [14] unable to open database file' in /var/www/db.php:20 Stack trace: #0 /var/www/db.php(20): PDO->__construct('sqlite:..\..\ho...') #1 /var/www/Details.php(14): require_once('/var/www/db.php') #2 /var/www/controller/Controller.php(14): require_once('/var/www/Detail...') #3 /var/www/index.php(5): require_once('/var/www/contro...')
If i use, for example: $dir = 'sqlite:test\db.sqlite'; it works great.
What i'm doing wrong?

Imagick giving me Fatal error: Uncaught exception 'ImagickException' with message 'unable to open image

I'm pretty sure I've installed my imagick correctly.
When I try and run something as simple as displaying an image with no changes to it like so:
header('Content-type: image/jpeg');
$image = new Imagick('image.jpg');
echo $image;
It displays a broken image.
When I attempt to display it without the header it gives me an error
Fatal error: Uncaught exception 'ImagickException' with message 'unable to open image `image.jpg': No such file or directory # error/blob.c/OpenBlob/2642' in [my-php-file-uri]:4 Stack trace: #0 [my-php-file-uri](4): Imagick->__construct('image.jpg') #1 {main} thrown in [my-php-file-uri] on line 4
The reason was because I had to include the full file-path URI

Categories