PHP Classes

Modifying method LoadImage

Recommend this page to a friend!

      ThumbnaiI Image  >  All threads  >  Modifying method LoadImage  >  (Un) Subscribe thread alerts  
Subject:Modifying method LoadImage
Summary:LoadImage wasn't working if the image was opened by URL
Messages:8
Author:Luis I. Larrateguy
Date:2005-04-02 16:13:21
Update:2007-05-25 20:27:56
 

  1. Modifying method LoadImage   Reply   Report abuse  
Picture of Luis I. Larrateguy Luis I. Larrateguy - 2005-04-02 16:13:21
I modified the LoadImage because in PHP 4.3.X was getting problem with getsize and with file existense.

I'll be using your class in one of my package. If you introduce this modification or other that let URL image work properly, let me know. For now, I'll be using your class modified and publishing it with my app.

regards,

Luis L.

Modification

function LoadImage ( $image_file, &$image_width, &$image_height ) {
//slightly modified By Luis ignacio Larrateguy
$image_width = 0;
$image_height = 0;

$image_data = file_get_contents( $image_file );

$image = imagecreatefromstring ( $image_data );
if ( ! $image ) {
$err = sprintf( E_004, $image_file );
trigger_error( $err, E_USER_ERROR );
}
$image_width = imagesx( $image );
$image_height = imagesy( $image );
return $image;
}

  2. Re: Modifying method LoadImage   Reply   Report abuse  
Picture of Vagharshak Tozalakyan Vagharshak Tozalakyan - 2005-04-05 11:09:01 - In reply to message 1 from Luis I. Larrateguy
Thanks, the changes were done in new edition of class.

  3. Re: Modifying method LoadImage   Reply   Report abuse  
Picture of Arapian Arapian - 2007-05-22 15:23:07 - In reply to message 2 from Vagharshak Tozalakyan
Hay!
I have a problem every time I'm uploading pictures bigger than 800ko. I'm receiving this message : Fatal error: Allowed memory size of 12582912 bytes exhausted (tried to allocate 2804 bytes) in..
Don't know what to do. Except that, the class is wonderful, shat lav!
Armenak from Swizerland

  4. Re: Modifying method LoadImage   Reply   Report abuse  
Picture of Vagharshak Tozalakyan Vagharshak Tozalakyan - 2007-05-22 15:47:47 - In reply to message 3 from Arapian
Barev! Try to change the memory limit for the current script by including at the top of the code something like this:

ini_set('memory_limit', '50M');


  5. Re: Modifying method LoadImage   Reply   Report abuse  
Picture of Arapian Arapian - 2007-05-23 16:24:20 - In reply to message 4 from Vagharshak Tozalakyan
Shad shad scheneragaliem Your script is wonderfull, come and visit my website, done before I began with php. www.arapian.com

  6. Re: Modifying method LoadImage   Reply   Report abuse  
Picture of Arapian Arapian - 2007-05-25 19:20:29 - In reply to message 5 from Arapian
kisher pari
I have 3 websites, on 2 of them , set_ini is working very well, on the last one, there is a pb because memory_limit is disabled, and the provider says that they will do the same on every server. The class needs 12Mo and 12ko to work perfectly. The server allocates 12Mo. Is there a way to spare those 12ko which are too much? sedesootyoon

  7. Re: Modifying method LoadImage   Reply   Report abuse  
Picture of Vagharshak Tozalakyan Vagharshak Tozalakyan - 2007-05-25 20:26:15 - In reply to message 6 from Arapian
If you are working with big images, then you may try to use PEAR package, which I think is more memory-optimized.

  8. Re: Modifying method LoadImage   Reply   Report abuse  
Picture of Vagharshak Tozalakyan Vagharshak Tozalakyan - 2007-05-25 20:27:56 - In reply to message 6 from Arapian