Image resizing or conversion works on Windows but not on Linux VPS

See all posts Reply

Image resizing or conversion works on Windows but not on Linux VPS new!
by surz, 8 years, 5 months ago
I've this piece of code which works perfectly on Windows but does not work in Linux VPS. On Windows I can overwrite the image with a new one, convert to 'jpg' and also resize to 128x128. I checked the logs

$foo->log says
-no image processing wanted

image 'upload' directory has permission set to 755
drwxr-xr-x 3 apache apache 4096 May 26 15:03 uploads

My php.ini
memory_limit = 128M

$foo = new upload ( $file );
if ($foo->uploaded) {
	if ($info [2] !== IMAGETYPE_JPEG) {
		$foo->image_convert = 'jpg';
	}
	// check width and height
	if ($info [0] > 750 || $info [1] > 540) {
		$foo->image_resize = true;
		$foo->image_ratio_crop = true;
		$foo->image_x = 750;
		$foo->image_y = 540;
	}
	// save uploaded image with a new name
	$foo->file_new_name_body = $fileName;
	$foo->file_overwrite = true;
	$foo->process ( $filePathOnServer );
	if (! $foo->processed) {
		reportErrorAndExit ( $foo->error );
	}

	// profile - 128px, others - 38px
	$foo->file_new_name_body = $fileName . '_thumbnail';
	$foo->file_overwrite = true;
	$foo->image_convert = 'jpg';
	$foo->image_resize = true;
	$foo->image_ratio_crop = true;
	$foo->image_x = 128;
	$foo->image_y = 128;
	$foo->process ( $filePathOnServer );
	if ($foo->processed) {
		$foo->clean ();
		echo JSON_SUCCESS;
	} else {
		reportErrorAndExit ( $foo->error );
	}
}
Reply
Re: Image resizing or conversion works on Windows but not on Linux VPS new!
by surz, 8 years, 5 months ago
[root@vps 2]# php -i | grep memory
memory_limit => 128M => 128M
Collecting memory statistics => No
opcache.memory_consumption => 128 => 128
opcache.preferred_memory_model => no value => no value
opcache.protect_memory => 0 => 0


Log File:

system information
- class version : 0.33dev
- operating system : Linux
- PHP version : 7.0.6
- GD version : GD not present
- supported image types : none
- open_basedir : no restriction
- upload_max_filesize : 2M (2097152 bytes)
- language : en_GB
source is an uploaded file
- upload OK
- file name OK
determining MIME type
- Fileinfo PECL extension deactivated
- Checking MIME type with UNIX file() command
    UNIX file() command failed
- Checking MIME type with mime.magic file (mime_content_type())
    MIME type detected as image/png by mime_content_type()
- MIME validated as image/png
source variables
- You can use all these before calling process()
    file_src_name : images.png
    file_src_name_body : images
    file_src_name_ext : png
    file_src_pathname : /tmp/phpALfJTC
    file_src_mime : image/png
    file_src_size : 8298 (max= 2097152)
    file_src_error : 0
process file to /var/www/uploads/2/
- file size OK
- file mime OK : image/png
- new file name body : profile
- file name safe format
- destination variables
    file_dst_path : /var/www/uploads/2/
    file_dst_name_body : profile
    file_dst_name_ext : png
- no auto_rename if same filename exists
- destination file details
    file_dst_name : profile.png
    file_dst_pathname : /var/www/uploads/2/profile.png
- no overwrite checking
- no image processing wanted
- process OK
process file to /var/www/uploads/2/
- file size OK
- file mime OK : image/png
- new file name body : profile_thumbnail
- file name safe format
- destination variables
    file_dst_path : /var/www/uploads/2/
    file_dst_name_body : profile_thumbnail
    file_dst_name_ext : png
- no auto_rename if same filename exists
- destination file details
    file_dst_name : profile_thumbnail.png
    file_dst_pathname : /var/www/uploads/2/profile_thumbnail.png
- no overwrite checking
- no image processing wanted
- process OK
cleanup
- delete temp file /tmp/phpALfJTCReply
Re: Image resizing or conversion works on Windows but not on Linux VPS new!
by colin, 8 years, 5 months ago
GD is not installed on your VPSReply
Re: Image resizing or conversion works on Windows but not on Linux VPS new!
by surz, 8 years, 5 months ago
Sorry but I did not get what GD meansReply
Re: Image resizing or conversion works on Windows but not on Linux VPS new!
by colin, 8 years, 5 months ago
You need to install/enable GD, a library for PHP, on your VPS.
http://php.net/manual/en/book.image.phpReply
Re: Image resizing or conversion works on Windows but not on Linux VPS new!
by surz, 8 years, 5 months ago
Many thanks Colin,
You were right, I've installed the php-gd module and it has started working like charm.
WOW! you saved my day :) wish you have a great time ahead!Reply
Re: Image resizing or conversion works on Windows but not on Linux VPS new!
by surz, 8 years, 5 months ago
Now that you have seen the code and the log file, do you suggest any code improvement or it looks good to you?Reply
Re: Image resizing or conversion works on Windows but not on Linux VPS new!
by colin, 8 years, 5 months ago
Looks good to me!Reply