Welcome Guest, Not a member yet? Register   Sign In
12 hours spent: Image resize problem
#1

[eluser]tryacc[/eluser]
Alright, here is my first message on this forum. On my current project, I began using CodeIgniter. Things are going very well, it fastened me.

But I have a huge problem on image resizing.

Situation: User uploads up to 3 files, each of them goes to the controller seperately. (Uploadify) So, we should imagine in the controller that the user actually uploaded only one file. We have $_POST['email'] info; we create a user profile for it if there is not. Then we first upload the $_FILES to the server (if there is a file and the extension is OK). Then I get the getimagesize of Temporary File, if it's ok for the standart, then go on. If it's a new registered user, we create a folder in the gallery for him/her. Then move the upladed file on it.

If the image is too large, we resize it down to a standart image size. Then we create a thumbnail out of it. Then insert the info to the DB.

Everything goes OK. Everything. I have added LOTS OF DEBUGS on almost every line for over 12 hours yesterday night and morning. It is certainly about the "$this->image_lib->resize()" function.

Image_lib is loaded, initalized but not resized. I debugged source image, it is there. Permissions are 755. Server has GD - bundled 2.xx comp-. Here is the resizing part of the function:

Code:
if (in_array($fileParts['extension'],$typesArray)) {
                 log_message('debug', 'extension uyuyor');
                // Uncomment the following line if you want to make the directory if it doesn't exist
                $size = getimagesize($tempFile);
                
                log_message('debug', 'temp file şurda:'.$tempFile);
                
                if($size[0] > 640 OR $size[1] > 480) {
                log_message('debug', 'ok imaj yeterince büyük');
                
                if($newreg == 1) { log_message('debug', 'yeni reg olduğu için yeni dizin yrat'); mkdir(str_replace('//','/',$targetPath), 0755, true); }
                
                if(move_uploaded_file($tempFile,$targetFile)) log_message('debug', 'dosya taşındı şuraya:'.$targetFile);
                
                
                log_message('debug', 'width:'.$size[0].'height:'.$size[1]);
                
                
                
                if($size[0] > 1280 OR $size[1] > 1024) {
                log_message('debug', 'entered resize. target file: '.$targetFile.' target PATH: '.$targetPath);
                $config['image_library'] = 'GD2';
                $config['source_image']    = $targetPath.$filename; //$targetFile;
                $config['maintain_ratio'] = TRUE;
                $config['width']     = 1280;
                $config['height']    = 1024;
                if($this->image_lib->initialize($config)) { log_message('debug', 'NORMAL RESIZE INITIALIZED OK'); } else { log_message('debug', $this->image_lib->display_errors()); }
                log_message('error', 'what the hell is going ooooooooooon!!! '.$this->image_lib->display_errors());
                if( ! $this->image_lib->resize()) { log_message('debug', 'NORMAL RESIZE RESIZE DONE');  } else { log_message('debug', $this->image_lib->display_errors()); }
                if($this->image_lib->clear()) { log_message('debug', 'NORMAL RESIZE clear TAMAM');  } else { log_message('debug', $this->image_lib->display_errors()); }
                }
                
                log_message('debug', 'RESIZEEEEEEEEEEE sonrasıııııııııııııııııııııı');
                $config['image_library'] = 'gd2';
                $config['source_image']    = $targetFile;
                log_message('debug', 'BEFORE REPLACE, TARGET PATH: '.$targetPath);
                $config['new_image'] = "thumb_".$filename;
                log_message('debug', 'AFTER REPLACE, TARGET PATH: '.str_replace('//', '/', $targetPath));
                log_message('debug', 'NEW IMAGE FILE: '.$config['new_image']);
                $config['create_thumb'] = TRUE;
                $config['maintain_ratio'] = TRUE;
                $config['width']     = 150;
                $config['height']    = 100;
                
                $this->load->library('image_lib');
                if($this->image_lib->initialize($config)) { log_message('debug', 'thumb resize INITIALIZED'); } else { log_message('debug', 'thumb resiz INITIALIZE ERROOORR!!!'); }
                if($this->image_lib->resize()) { log_message('debug', 'thumb resize done'); } else { log_message('debug', 'thumb resiz ERROOOORRR!'); }

Ok... DEBUG results:

Everything works ok.
Image_lib loaded.
Initializing done.
Never executes $this->image_lib->resize() ..... No errors. On IF CONDITION, it doesnt give TRUE or FALSE. (I tried it out of the IF, alone; same.)

PLUS: it works on my localhost. I tried "gd", "gd2", "GD", "GD2" for the image library. No change.

Any ideas, please? :'(
#2

[eluser]Twisted1919[/eluser]
Just an idea to save you from the future usage of image lib from ci:
http://phpthumb.gxdlabs.com/

Also, things like:
if($this->image_lib->initialize($config)) OR if($this->image_lib->clear()) are useless, the initialize()/clear() method returns nothing .
#3

[eluser]tryacc[/eluser]
Hi,

Thanks for the link -it's one of the best designed image lib web site, I'll try it right now...

And yes, I guessed they return just nothing but... I tried every single thing....

Thank you,
#4

[eluser]tryacc[/eluser]
Could this be a server memory problem?

It popped up in my mind, I will test it out.
#5

[eluser]tryacc[/eluser]
max_execution_time 120 120
max_file_uploads 20 20
max_input_nesting_level 64 64
max_input_time 60 60
memory_limit 16M 16M

post_max_size 8M 8M
precision 14 14
realpath_cache_size 16K 16K

upload_max_filesize 4M 4M



GD INFO:

gd
GD Support enabled
GD Version bundled (2.0.34 compatible)
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.3.7
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
XBM Support enabled


is the server OK for resizing? I don't really have much knowledge on server things.
#6

[eluser]tryacc[/eluser]
The phpthumb library Twisted1919 gave doesn't work on my server either... It works well on localhost.
#7

[eluser]tryacc[/eluser]
Solved:
It was a server issue. They allocated more memory, i suppose. Then it is solved.




Theme © iAndrew 2016 - Forum software by © MyBB