The problem isnt in script timeout, I set it long enough and it never reached this time. But GD wont handle 350kb jpegs, which looks like max file size setting, because smaller files, even if they are in high resolution up to 1000x500 pixels, are processed with no doubts. This script works on other server without this problem, so I compared phpinfo of two servers but havent found the catch, so maybe is set somewhere else, thats what I ask for, maybe someone will know it.