imagejpeg在生产服务器上无法正常工作

问题描述:

我在WordPress中拥有以下功能,可以抓取组中所有用户的图片,将它们缝合在一起并创建一个合成图像,然后将其保存在主题文件夹中。imagejpeg在生产服务器上无法正常工作

这对我的开发服务器非常有用,但对生产服务器没有任何作用。

这是权限问题吗?开发服务器运行php 5.5.12和活服务器运行5.5.23,所以不应该导致问题(我不相信imagejpeg已被弃用?)。两者都运行最新版本的WordPress。开发服务器是WAMP,生产服务器是LAMP。下面

功能:

function group_thumbnail($post_id) { 

     // Generates a composite thumbnail, a la Spotify playlists, to use in the group layout. 

       $user_portraits = array(); 
       if(!empty($_POST['wpcf']['allowed-users'])) : 
        $allowed_users = $_POST['wpcf']['allowed-users']; // For the back end 
       else : 
        $allowed_users = get_post_meta($post_id,'wpcf-allowed-users',false); // For the front end 
       endif; 

       $allowed_users = sort_pictures_by_name($allowed_users); 

       $group_size = count($allowed_users); 

       if($group_size < 4) : $limit=1; $row_size = 1; endif; 
       if($group_size >= 4 && $group_size < 9) : $limit=4; $row_size = 2; endif; 
       if($group_size >= 9 && $group_size < 16) : $limit=9; $row_size = 3; endif; 
       if($group_size >= 16) : $limit=16; $row_size = 4; endif; 
       $square_size = 200/$row_size; 
       foreach ($allowed_users as $u_id) : 
        $u_portrait=get_user_meta($u_id, 'wpcf-portrait', true); 
        $u_file = imagecreatefromjpeg($u_portrait); 
        $user_portraits[] = $u_file; 
       endforeach; 
       $group_image = imagecreatetruecolor (200 , 200); 
       $postion = array('x'=>0,'y'=>0); 
       for($i=0; $i<$limit; $i++) :  
        if($i % $row_size == 0 && $i<>0) : 
         $postion['x']=0; 
         $postion['y']+=$square_size; 
        endif; 
        imagecopyresized($group_image,$user_portraits[$i],$postion['x'],$postion['y'],0,0,$square_size,$square_size,180,180); 
        imagedestroy($user_portraits[$i]); 
        $postion['x']+=$square_size; 
       endfor;   
       // Output and free from memory 
       imagejpeg($group_image,get_template_directory().'/img/groups/'.$post_id.'.jpg',60); 
       imagedestroy($group_image); 
       clearstatcache(); 

    } 

这是最终很简单 - 在生产服务器上的文件夹是不可写的。通过FTP快速整理。