Jump to content

wrecked server woes


ajoo

Recommended Posts

Hi all !

 

I just recreated an ubuntu web server since I lost the earlier one and I am consistently getting these messages when I try and display / save images 

 

 

[Wed May 17 14:30:15.717043 2017] [:error] [pid 1362] [client 103.232.151.16:62901]

 PHP Warning:  imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error:
 \b\n in /var/www/path/to/fr_function.php on line 151,
 
[Wed May 17 14:30:15.717179 2017] [:error] [pid 1362] [client 103.232.151.16:62901]
 PHP Fatal error:  imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error:
 Unsupported marker type 0x7e in /var/www/path/to/fr_function.php on line 151,
 
and line 151 happens to be 
 
if($mime==="image/jpeg" || $mime==="image/jpg" ) $src = imagecreatefromjpeg($tmp_filename);

and mysqli gives the 1406 error code (data too long for the column ). The datatype I am using is the blob and the image size is less than 500K always. 

 

I have checked $tmp_filename and that path is correct. Even $src returns true and yet this is crashing. 

 

 

I have checked my image files and they are not corrupt or so I think since they display correctly in any image editor or windows image  viewer. There is plenty of space on my disk so this is not a disk space issue.

 

If anyone can shed some light on this.

 

Thanks loads !

 

PS. This code was working perfectly well earlier ( till about 2 days ago). There have been no changes in the code at all.  Only a new server and configuration.

 

 

 

 

 

 

Link to comment
Share on other sites

Hi all, 

 

I am at a dead end with these errors that I am getting consistently :

 

 

 
[Fri May 19 09:55:02.376485 2017] [:error] [pid 9592] [client 103.232.151.16:56171] PHP Fatal error:  imagecreatefrompng(): gd-png: fatal libpng error:
 invalid code lengths set\n in /var/www/path/to/fr_function.php on line 152,
 
 
[Fri May 19 09:59:51.842798 2017] [:error] [pid 9589] [client 103.232.151.16:56196] PHP Fatal error:  imagecreatefrompng(): gd-png: fatal libpng error:
 invalid stored block lengths\n in /var/www/path/to/fr_function.php on line 152,
 
 
[Fri May 19 10:07:03.234707 2017] [:error] [pid 9630] [client 103.232.151.16:56234] PHP Fatal error:  imagecreatefrompng(): gd-png: fatal libpng error:
 invalid distance code\n in /var/www/path/to/fr_function.php on line 152,
 
 

 

and this is the block of code where this occurs :

$tmp_filename=$_FILES['image']['tmp_name']; // temporary file	
.
.
if($mime==="image/jpeg" || $mime==="image/jpg" ) $src = imagecreatefromjpeg($tmp_filename);
elseif($mime==="image/png") $src = imagecreatefrompng($tmp_filename);
else $src = imagecreatefromgif($tmp_filename);

if I modify this to check the value of $src like below :-

 if($mime==="image/jpeg" || $mime==="image/jpg" ) {
                                $src = imagecreatefromjpeg($tmp_filename);
                                if($src) echo "True returned:";
                                else echo "False Returned";
                        }
elseif($mime==="image/png") $src = imagecreatefrompng($tmp_filename);
else $src = imagecreatefromgif($tmp_filename);
exit();
 

then I get !! True Returned !!!!???? Now how is that possible ? if the function returns a true value why does it fail otherwise in the normal flow and the errors all occur at line 151 or 152  which is the if-else block above depending upon whether I upload a jpeg or png image ?

 

Kindly someone please help with this issue. I am completely baffled ! 

 

Thanks all !

 

P.S. The same code works absolutely fine on a xampp with no issues at all but that's on an earlier php version (5) while this is the 7.0 version running on aws server on ubuntu1604, php version.  

Link to comment
Share on other sites

Hi all !

 

I have been trying to find some way out of this issue and i tried the code from the manual for the functions imagecreatefromjpeg() and imagecreatefrompng() and to my great surprise it worked with my files.

 

So that makes me even more clueless if anything.

 

Guru kindly may come to the rescue !

 

Thanks loads ! 

Link to comment
Share on other sites

By the way, this is exactly why storing images in a database is really not such a great idea. File storage is much more robust, because as long as your filesystem doesn't get corrupted, nothing will happen to the data. In a database, many things can happen: wrong types, wrong settings, wrong queries, bugs etc.

 

So I strongly recommend you export the images to the filesystem (after a full database backup, of course).

Link to comment
Share on other sites

Hi all !!

 

Thanks for the replies !

 

@ Requinix : Please find the links below to the images !

 

http://imgur.com/OSKre45

http://imgur.com/6ellxzk

http://imgur.com/JUUHMCj

http://imgur.com/PMOg065

http://imgur.com/luvetMs

http://imgur.com/qTt65GW

http://imgur.com/0k3hBrh

http://imgur.com/KprdyeJ

http://imgur.com/LohPDSC

http://imgur.com/X7HtD92

http://imgur.com/66GvnTm

http://imgur.com/vO3UcDu

http://imgur.com/laDjYGx

http://imgur.com/cYjv691

http://imgur.com/MPAFZpY

 

@DulongC : Hi, Here is the output of the gd_info:

 

array(12) { ["GD Version"]=> string(5) "2.1.1" ["FreeType Support"]=> bool(true) ["FreeType Linkage"]=> string(13) "with freetype" ["GIF Read Support"]=> bool(true) ["GIF Create Support"]=> bool(true) ["JPEG Support"]=> bool(true) ["PNG Support"]=> bool(true) ["WBMP Support"]=> bool(true) ["XPM Support"]=> bool(true) ["XBM Support"]=> bool(true) ["WebP Support"]=> bool(true) ["JIS-mapped Japanese Font Support"]=> bool(false) }

 

@ Guru Jacques !

 

Definitely I will do it sir. However, the error occurs while I am just readying the file for resizing to fit in the preview window and before I submit it for saving it on the disk in the uploads folder. Once this works I will simply save the filename in the DB instead of saving the image_data (blob). 

createimagefromjpeg($file) triggers the area and is baffling since in an example from the PHP manual it gives the correct output.

 

 

Thanks loads all for the inputs ! Hoping to resolve this soon with your help.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.