Image resize problem.

See all posts Reply

Image resize problem. new!
by Egor, 14 years, 7 months ago
Hi, i test this class on my localhost and it work, but when i upload it in web - image uploaded and renaming, but not resizing.
$handle->file_new_name_body   = 'thumb_'.$rand_name;
$handle->image_resize         = true;
$handle->image_ratio_crop 	  = 'T';
$handle->image_x              = 100;
$handle->image_y              = 100;
$handle->process($settings_patch);

and log:
system information
- class version : 0.28
- GD version : 2.0.34
- supported image types : png jpg gif bmp
- open_basedir : /home/true/data:.
- language : ru_RU
source is an uploaded file
- upload OK
- file name OK
determining MIME type
- Checking MIME type with Fileinfo PECL extension
Fileinfo PECL extension not available
- Checking MIME type with UNIX file() command
MIME returned as audio/x-mod
MIME type detected as audio/x-mod by UNIX file() command
source variables
- You can use all these before calling process()
file_src_name : a_63e923d5.jpg
file_src_name_body : a_63e923d5
file_src_name_ext : jpg
file_src_pathname : /home/true/data/tmp/phppyCdum
file_src_mime : audio/x-mod
file_src_size : 7723 (max= 7340032)
file_src_error : 0
process file to ../uploads/
- file size OK
- file mime OK : audio/x-mod
- new file name body : full_1254695015
- file name safe format
- destination variables
file_dst_path : ../uploads/
file_dst_name_body : full_1254695015
file_dst_name_ext : jpg
- no image operation, keep extension
- checking for auto_rename
- destination file details
file_dst_name : full_1254695015.jpg
file_dst_pathname : ../uploads/full_1254695015.jpg
- full_1254695015.jpg doesn't exist already
- no image processing wanted
- process OK
process file to ../uploads/
- file size OK
- file mime OK : audio/x-mod
- new file name body : thumb_1254695015
- file name safe format
- destination variables
file_dst_path : ../uploads/
file_dst_name_body : thumb_1254695015
file_dst_name_ext : jpg
- no image operation, keep extension
- checking for auto_rename
- destination file details
file_dst_name : thumb_1254695015.jpg
file_dst_pathname : ../uploads/thumb_1254695015.jpg
- thumb_1254695015.jpg doesn't exist already
- no image processing wanted
- process OK
Reply
Re: Image resize problem. new!
by Egor, 14 years, 7 months ago
Hm, but in other web server it`s work... Where the problem?Reply
Re: Image resize problem. new!
by colin, 14 years, 7 months ago
Your system doesn't detect MIME type properly:
MIME returned as audio/x-mod

Try to deactivate MIME detection with the Unix file command:
$handle->mime_file = false;

Or even, deactivate MIME detection altogether:
$handle->mime_check = false;
Reply
Re: Image resize problem. new!
by Egor, 14 years, 7 months ago
Don`t help =(Reply
Re: Image resize problem. new!
by colin, 14 years, 7 months ago
What does the log say in each case?Reply
Re: Image resize problem. new!
by Egor, 14 years, 7 months ago
$handle->mime_check = false;
$handle->file_new_name_body   = 'thumb_'.$rand_name;
$handle->image_resize         = true;
$handle->image_ratio_crop 	  = 'T';
$handle->image_x              = 100;
$handle->image_y              = 100;
$handle->process($settings_patch);

system information
- class version : 0.28
- GD version : 2.0.34
- supported image types : png jpg gif bmp
- open_basedir : /home/true/data:.
- language : ru_RU
source is an uploaded file
- upload OK
- file name OK
determining MIME type
- Checking MIME type with Fileinfo PECL extension
Fileinfo PECL extension not available
- Checking MIME type with UNIX file() command
MIME returned as audio/x-mod
MIME type detected as audio/x-mod by UNIX file() command
source variables
- You can use all these before calling process()
file_src_name : canonimage.jpg
file_src_name_body : canonimage
file_src_name_ext : jpg
file_src_pathname : /home/true/data/tmp/phpzzHLf6
file_src_mime : audio/x-mod
file_src_size : 183468 (max= 7340032)
file_src_error : 0
process file to ../uploads/
- file size OK
- file mime (not checked) : audio/x-mod
- new file name body : full_1254840895
- file name safe format
- destination variables
file_dst_path : ../uploads/
file_dst_name_body : full_1254840895
file_dst_name_ext : jpg
- no image operation, keep extension
- checking for auto_rename
- destination file details
file_dst_name : full_1254840895.jpg
file_dst_pathname : ../uploads/full_1254840895.jpg
- full_1254840895.jpg doesn't exist already
- no image processing wanted
- process OK
process file to ../uploads/
- file size OK
- file mime (not checked) : audio/x-mod
- new file name body : thumb_1254840895
- file name safe format
- destination variables
file_dst_path : ../uploads/
file_dst_name_body : thumb_1254840895
file_dst_name_ext : jpg
- no image operation, keep extension
- checking for auto_rename
- destination file details
file_dst_name : thumb_1254840895.jpg
file_dst_pathname : ../uploads/thumb_1254840895.jpg
- thumb_1254840895.jpg doesn't exist already
- no image processing wanted
- process OK
Reply
Re: Image resize problem. new!
by colin, 14 years, 7 months ago
Yes, mime_check will not do anything in this case. mime_check just skips the checks against the list of allowed MIME types.

What happens in your case is that your system returns a wrong MIME type for your file. So the class cannot consider the file as an image, and therefore skips all image processing.

Try to deactivate MIME detection with the Unix file command:
$handle->mime_file = false;

But you should also check the implementation of MIME types on your system, as they are obviously wrong.Reply
Re: Image resize problem. new!
by Egor, 14 years, 6 months ago
I still could not solve this problem =(Reply
Re: Image resize problem. new!
by colin, 14 years, 6 months ago
As I say above, you have to check your server configuration. Your server reports audio/x-mod as a MIME type for a JPEG file, which is obviously wrong.

Try to deactivate MIME detection with the Unix file command:
$handle->mime_file = false;
Reply
Re: Image resize problem. new!
by Egor, 14 years, 6 months ago
$handle->mime_file = false; don`t help =(Reply
Re: Image resize problem. new!
by Egor, 14 years, 6 months ago
i`m write to my hosting support, but they say than "server config correct".Reply
Re: Image resize problem. new!
by Egor, 14 years, 6 months ago
i solved this problem.
When i use $handle->mime_file = false; in this place:

$handle = new upload($_FILES['Filedata'], 'ru_RU');
$handle->mime_file = false; // (insert here)
  if ($handle->uploaded) {
    $handle->mime_file = false; // (or here)

Checking MIME type with UNIX file() command still work and not deactivated.

determining MIME type
- Checking MIME type with Fileinfo PECL extension
Fileinfo PECL extension not available
- Checking MIME type with UNIX file() command
MIME returned as audio/x-mod
MIME type detected as audio/x-mod by UNIX file() command



But when i change default variable in class file (line 1945) $this->mime_file = true; replace with $this->mime_file = false; - script work and image resizing

determining MIME type
- Checking MIME type with Fileinfo PECL extension
Fileinfo PECL extension not available
- UNIX file() command is deactivated
- Checking MIME type with mime.magic file (mime_content_type())
mime_content_type() is not available
- Checking MIME type with getimagesize()
MIME type detected as image/jpeg by PHP getimagesize() function
Reply
Re: Image resize problem. new!
by colin, 14 years, 5 months ago
There may be a bug. I will check this out.Reply
Re: Image resize problem. new!
by Egor, 14 years, 5 months ago
thanks for your reply :)Reply