Forums

[resolved] Selecting head from photograph (3 posts)

  1. Johnny T
    Member
    Posted 3 years ago #

    Hi,
    I have a WordPress installation that has been modified slightly. It allows people to upload a picture of themselves using the following code:

    public function update_image($ID, $image){
    			$uploaddir 		= wp_upload_dir();
    			$persondir		= $uploaddir['basedir'].'/person/';
    			$persondirurl	= $uploaddir['baseurl'].'/person/';
    
    			if(!file_exists($persondir)){
    				mkdir($persondir);
    				chmod($persondir, 0777);
    			}
    			$info = getimagesize($image);
    			switch($info[2]):
    				case 1 : $img =imagecreatefromgif($image); break;
    				case 2 : $img =imagecreatefromjpeg($image); break;
    				case 3 : $img =imagecreatefrompng($image); break;
    			endswitch;
    			$w = 89;
    			$h = 119;
    			$res_img = picture_resizeto($img,$w,$h);
    
    			$res_img_thimbnail = picture_resizeto($img,64,86);
    
    			imagepng($res_img, ($persondir.'/'.$ID.'.png'));
    
    			imagepng($res_img_thimbnail, ($persondir.'/'.$ID.'_small.png'));
    
    			chmod(($persondir.'/'.$ID.'.png'), 0777);
    			chmod(($persondir.'/'.$ID.'_small.png'), 0777);
    
    			imagedestroy($res_img);
    			imagedestroy($res_img_thimbnail);
    			imagedestroy($img);
    			update_post_meta($ID, '_image_small', $persondirurl.$ID.'_small.png');
    			return update_post_meta($ID, '_image', $persondirurl.$ID.'.png');
    		}

    I would like to allow visitors to select just their face when they upload a picture and then it fits better in the thumbnail (89x119 pixels).

    I installed "scissors" plugin thinking this would give me the functionaility but it only works when uploading photos to the blog.

    Is there any way of acheiving the "crop" functionality of scissors when someone uploads a picture of themselves?

    I hope you can decipher what I'm after from reading this post. If you need anymore information then please ask. I'd be very grateful if someone can help me with this.

    Many thanks

    John ;-)

  2. Mark / t31os
    Moderator
    Posted 3 years ago #

    You'd be lucky to get someone to just whip that up for you...

    Might wish to try here.
    http://jobs.wordpress.net/

  3. Johnny T
    Member
    Posted 3 years ago #

    Thanks for the heads-up about the jobs section, I'd not seen that before.

    I really just need to get the "crop" functionality of scissors in a self-contained function that could be called whenever someone uploads any photo on to the site....

    I'm probably over-simplifying it but (in my head at least) it shouldn't be too difficult for someone who has knowledge of how scissors works..??

    Cheers

    John ;-)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.