Imagick PHP Exception 1630 on Chrome: Read exception - php

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.

Related

Google\Cloud\Storage\StorageObject->downloadAsString() uncaught error

I have a PHP script that reads files from Cloud Storage. It works fine in local dev. But when it's run in App Engine standard environment, it outputs this error message:
Fatal error: Uncaught Google\Cloud\Core\Exception\ServiceException in /srv/vendor/google/cloud/Core/src/RequestWrapper.php:362
Stack trace:
#0 /srv/vendor/google/cloud/Core/src/RequestWrapper.php(206): Google\Cloud\Core\RequestWrapper->convertToGoogleException(Object(GuzzleHttp\Exception\RequestException))
#1 /srv/vendor/google/cloud/Storage/src/Connection/Rest.php(224): Google\Cloud\Core\RequestWrapper->send(Object(GuzzleHttp\Psr7\Request), Array)
#2 /srv/vendor/google/cloud/Storage/src/StorageObject.php(643): Google\Cloud\Storage\Connection\Rest->downloadObject(Array)
#3 /srv/vendor/google/cloud/Storage/src/StorageObject.php(574): Google\Cloud\Storage\StorageObject->downloadAsStream(Array)
#4 /srv/modules/profile/controllers/getresource.class.php(69): Google\Cloud\Storage\StorageObject->downloadAsString()
This doesn't happen to most of the files. The file causing this issue is about 250KB. I am wondering is there some kind of size limitation with downloadAsString()?
One of the files causing this issue is https://www.justjeans.com.au/wcsstore/JustJeansAuroraStorefrontAssetStore/css/main.css?timestamp=2019070295000
The downloadAsString() method downloads the file using stream, and then casts it to a string before returning it.
Link to the SDK code
There should not be any issues with file sizes unless you are running out of memory in your PHP process.
Is there a file that causes the issue every time? If so, maybe adding that to the question would be a good idea.

PhpThumb error - PHP Fatal error: Class 'PhpThumb' not found

I had downloaded from official website, uploaded to my hosting server. I got this error message.
[08-Mar-2012 21:26:07] PHP Fatal error: Class 'PhpThumb' not found in /home/sokad
/public_html/libs/phpthumb/thumb_plugins/gd_reflection.inc.php on line 179
Fatal error: Uncaught exception 'RuntimeException' with message 'Cannot show image, headers
have already been sent' in /home/sokad/public_html/libs/phpthumb/GdThumb.inc.php:569 Stack
trace: #0 /home/sokad/public_html/resize.php(14): GdThumb->show() #1 {main} thrown in
/home/sokad/public_html/libs/phpthumb/GdThumb.inc.php on line 569
require_once 'libs/phpthumb/ThumbLib.inc.php';
$thumb = PhpThumbFactory::create($url);
$thumb->adaptiveResize($width, $height);
$thumb->show();
I found that a lot of website also got same problem. Any idea how to solve it?
scan your "phpthumb" directory for all "error_log" files or "_notes" directories, and delete them. In my case I had an error_log file at the thumb_plugins, as soon as I deleted it, it worked on the remote side.
I came to this conclusion because there was no reason why it whould work differently locally and remotely, the only difference? these files.
Good Luck

Dropbox API and PHP

I am gelling following error while trying to read file content which is residing in a subfolder rather than a parent folder.
Fatal error: Uncaught exception 'Exception' with message 'Invalid
signature. Expected signature base string:
GET&https%3A%2F%2Fapi-content.dropbox.com%2F1%2Ffiles%2Fdropbox%2FProjects%2FMAC%2520Error.rtf&oauth_consumer_key%3Dbdagb07uu6zq827%26oauth_nonce%3D46d063d5815a0972d63cf72359c0349f%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1324449973%26oauth_token%3D7f2cr9kppqo2hxz%26oauth_version%3D1.0
(Status Code: 403)' in
/Applications/MAMP/htdocs/dbcatalog/BenTheDesigner-Dropbox-88e3876/Dropbox/OAuth/Consumer/Curl.php:133
Stack trace: #0
/Applications/MAMP/htdocs/dbcatalog/BenTheDesigner-Dropbox-88e3876/Dropbox/API.php(109):
Dropbox\OAuth\Consumer\Curl->fetch('GET', 'https://api-con...',
'files/dropbox/P...', Array) #1
/Applications/MAMP/htdocs/dbcatalog/BenTheDesigner-Dropbox-88e3876/check.php(21):
Dropbox\API->getFile('Projects/MAC Er...') #2 {main} thrown in
/Applications/MAMP/htdocs/dbcatalog/BenTheDesigner-Dropbox-88e3876/Dropbox/OAuth/Consumer/Curl.php
on line 133
I am using Ben's Dropbox Library for php
https://github.com/BenTheDesigner/Dropbox
Thanks
If you are looking for a simple PHP-API you can find one here:
https://github.com/hawaiianchimp/Dropbox-PHP-API/
This is the message thats returned when a OAuth request is signed incorrectly. This is likely the fault of the library you're using. At first glance, it looks like it may be encoding the name of your "MAC Error.rtf" file incorrectly. Checkout the PHP SDK dropbox mentions on its website as an alternative and raise this issue with the library's owner.
The code that generates this would help too.

PHP Imagick PDF to JPEG Problem

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.

why is new SimpleXMLElement($tags) causing my php script to crash;

I am trying to run some client code to call a server side API.
I put various put statements to see where the code crashes and the line crashing it is
$tagXml = new SimpleXMLElement($tags);
(where tags is the result of a file_get_contents call)
I downloaded php5 and I am running it from the php source file from the command line.
Why is this crashing the code.
Perhaps there is an addon for php I need to add to use new SimpleXMLElement($param)
edit I got error reporting working
Warning: simplexml_load_file(): I/O warning : failed to load external entity "https://api.domain/v2/andy/tags" in C:\java\domain-api-v2\simple\list-
tags.php on line 30
working line 30
Fatal error: Uncaught exception 'Exception' with message 'String could not be pa
rsed as XML' in C:\java\domain-api-v2\simple\list-tags.php:37
Stack trace:
0 C:\java\domain-api-v2\simple\list-tags.php(37): SimpleXMLElement->__const
ruct('')
1 {main}
thrown in C:\java\domain-api-v2\simple\list-tags.php on line 37
I would check your error log. There are two immediate possibilities:
You are not including the SimpleXMLElement class in the file that you are running
$tags is some kind of format that SimpleXMLElement doesn't like.
If you check your error log (and have error reporting turned on) then you should see whats going on.
I was experienced this problem before. How much size of $tags contents ?
You have to use simplexml_load_file() instead of file_get_contents() , if file's size are bigger and server performance is low.

Categories