PHP Imagick PDF to JPEG Problem - php

I am having this error that comes up when I try to convert certain pdfs into JPEgs
The error message is:
[28-Mar-2011 13:24:02] PHP Fatal error: Uncaught exception '
Stack trace:
#0 /home/bobdole/public_html/viewfile.php(41): Imagick->__con
#1 {main}
thrown in /home/bobdole/public_html/viewfile.php on line 41
The code is:
$im = new imagick($file_location);//Line 41 is here
$im->setImageFormat( "jpg" );
$pdf_pages=$im->getNumberImages();
Any idea what is causing the problem and how to fix it? It does not happen all the time, only with certain PDFs.
GhostScript is installed.

I spent a lot of time playing around with all kinds of PDF-files and imagemagick. This might help others trying to get it all to work. I've found so many solutions here, wouldn't even know how to thank everyone, so here it goes ;)
After a lot of useless tinkering, I figured it wasn't imagemagick which didn't work, but Ghostsript. I had to get the latest version of Ghostscript (i had to build it from source, the packages weren't new enough). I tested it all with pretty much all the available PDF-versions. Updating ghostscript worked pretty well, but still some PDF's were not accepted.
In the end I checked out the logs and discovered that ghostscript fonts are key to the issue. I updated those. After this, it all went smooth. Actually have a site which converts any PDF, right now.

Related

Convert pdf to jpg using php Magick

I am looking for a solution to that problem, I am trying to convert pdf to image using php image magic, here is the code, I have tried many solutions but still I am not able to understand why it shows same issue every time
$FILE = realpath(__DIR__ . '/file.pdf');
$im = new Imagick();
$im->pingImage($FILE);
$pageCount = $im->getNumberImages();
echo $pageCount;
If I put jpg file in it, works fine, but if I add file.pdf it shows this error
Fatal error: Uncaught ImagickException: PDFDelegateFailed `The system
cannot find the file specified. ' # error/pdf.c/ReadPDFImage/794
Note: I have installed ghost script 9.52 64 bit , Imagick 7. something! , I am looking for the help
I had the same problem and after a week trying to fix, I discovered that this problem seems to be related to the recents Ghostscript version.
I solved removing it and installing the version 9.26 after trying all of those.

connecting PHP to MSSQL error

I'm currently trying to connect to a MSSQL database, but from what i've read so far, there are actually extensions and files that i need to download from microsoft itself which i've went and download it here.
https://www.microsoft.com/en-us/download/details.aspx?id=20098
The error that i'm receiving currently receiving is the following.
Fatal error: Uncaught Error: Call to undefined function sqlsrv_connect() in C:\xampp\htdocs\index.php:5 Stack trace: #0 {main} thrown in C:\xampp\htdocs\index.php on line 5
As far as i understand, i know that i'm supposed to append some extensions into the php.ini located in my xampp\php\php.ini file. However, even after appending the file from microsoft, i still can't seem to get connected.
I heard some people mentioned that the php version that i'm using which is currently PHP Version 7.1.1 has some issues connecting back to MSSQL databases but i'm not entirely sure.
Would someone be able to point me to right direction? i've tried looking up and down appending different files into the extension but i still can't seem to do it.
Thank you very much in advance.
edit:
PHP 7 on IIS: Call_user_function could not be located
i've also visited this link, however i'm unsure whether if this is related to the issue I have as i'm on 7.1

Imagick PHP Exception 1630 on Chrome: Read exception

I have trouble resolving an issue with Imagick (php version of imagemagick) while generating a new image.
I retrieve my image via a $_POST
I convert the string with base64
I stock in on the server
I generate a new Imagick() with the newly created image
Weirdly, the script works perfectly fine on Firefox + IE (a new image is generated) but it generates a fatalerror on Googgle Chrome (desktop + mobile):
Fatal error: Uncaught exception 'ImagickException' with message 'Read
Exception `MYSERVERPATH/10562112e9c44d0.png' #
error/png.c/MagickPNGErrorHandler/1630' in MYSERVERPATH/result.php:41
Stack trace: #0
MYSERVERPATH/result.php(41):
Imagick->__construct('/httpdjail/var/...') #1 {main} thrown in
MYSERVERPATH/result.php on line 41
My line 41 is:
$image = new Imagick(MY SERVER PATH. $file);
I'm quite new at coding PHP, then any help would be very appreciated :).
Thanks a lot for your help!
I retrieve my image via a $_POST
This feels very bad,
Your error seems to hint at MYSERVERPATH is not getting converted to the string that you should have in there hence imagemagik doesn't know where it is hence errors out.

how to fix the magecreatefromjpeg() error in php?

before posting this, I've already tried searching for answers and even bumped into this
old thread solution
but it didn't helped at all. I am very sure that I am passing a .jpg image, but then I am getting this error
imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error:
some say use ini_set("memory_limit", -1) , it didn't help also. I don't think this issue has somethign to do with memory right?, so how to fix this?

MongoCursorException 'couldn't get response header'

I am developing a website using PHP and mongodb. I access the mongodb with PECL-mongo, and have run into an annoyance. Every now and then, I get an error like this (I've anonymized the paths)
Fatal error: Uncaught exception 'MongoCursorException' with message 'couldn't get response header' in
/PATH/index.php:38 Stack trace: #0
/PATH/index.php(38): MongoCursor->rewind() #1
/PATH/template.inc(29): get_sidebar() #2
/PATH/index.php(13):
require_once('PATH/...') #3 {main} thrown in PATH/index.php on line 38
According to the documentation, this means:
The driver could not fetch a reply header from the database, so it
gave up. Check if the database is still up and the network is
connected and try the query again.
But I know that the database is up because I am doing this locally on my own machine over loopback. No connection is made to the outside world.
Simply trying again often works. Is this a possibly a bug in PHP's driver for mongo? Could this be a "miscompile" issue (I compiled from source, but with very benign flags, -march=native -O2)?
Has anyone seen this before?
Searching around, I only see references to some stupid facebook game having the same error.
EDIT: I just downgraded my PECL driver to version 1.1.4 and so far, the problem seems have gone away. So this may simply be a bug in the 1.2.x series. If anyone can shed any light on it, that would be great.
EDIT: I am not doing anything complex here, the code that is having the issue litterally looks like this:
$m = new Mongo();
$collection = $m->my_db->collection;
$results = $collection->find(array("favorite"=>true))->limit(5);
i solved this problem with get new version mogodb.dll
you can see http://www.mongodb.org/display/DOCS/PHP+Language+Center

Categories