Jump to content

Keybit

New Members
  • Posts

    1
  • Joined

  • Last visited

Keybit's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Could anyone please help solve an issue I'm having whist trying to put together a little webpage to allow (a facebook) group members to easily be able to generate personalised "The Group™" profile pics! I feel I'm soooo close but i believe i need to auto resize (and possibly crop) to a set size (the same as the overlay) the uploaded pic before the overlay does its work which will solve the issue of the overlay sitting too high or low (depending on the size of the uploaded picture) You can take a look at the progress thus far at the following link.. The Group Profile Pic Maker - If you dont know, get to know! Just need to iron out this bug then I can make it look a bit more attractive! Code Snippet.. public function overlay( $uploaded ){ $this->checkConfig(); $this->uploaded = $uploaded; $overlay = $this->rootPath . $this->resourcesFolder . $this->overlay; $overlaySize = getimagesize( $overlay ); if( empty( $this->uploaded ) || $uploaded['size'] < 1 ){ $this->throwErr( "You have not chosen an image to upload!" ); return false; } $this->uploadedInfo = getimagesize( $this->uploaded['tmp_name'] ); if( $this->uploaded['size'] > ( $this->maxFileSize * 1000000 ) || filesize( $this->uploaded['tmp_name'] ) > ( $this->maxFileSize * 1000000 ) ){ $this->throwErr( "The file you have chosen to upload is too big." ); return false; } if( $this->uploadedInfo['mime'] != "image/jpeg" && $this->uploadedInfo['mime'] != "image/jpg" ){ $this->throwErr( "The file you have chosen to upload is the wrong file type. Please choose a JPG or JPEG file only." ); return false; } $new = array(); $new[0] = $this->fbWidth; $new[1] = ( $new[0] * $this->uploadedInfo[1] ) / $this->uploadedInfo[0]; if( ( $new[1] + $overlaySize[1] ) > $this->fbHeight ) $canvasH = $this->fbHeight; else $canvasH = $new[1]; $src = imagecreatefromjpeg( $this->uploaded['tmp_name'] ); $tmp = imagecreatetruecolor( $new[0], $canvasH ); imagecopyresampled( $tmp, $src, 0, 0, 0, 0, $new[0], $new[1], $this->uploadedInfo[0], $this->uploadedInfo[1] ); imagealphablending( $tmp, true ); $overlayRes = imagecreatefrompng( $overlay ); do{ $filename = time() . "-processed.jpg"; $file = $this->rootPath . $this->processedFolder . $filename; }while( file_exists( $file ) ); imagecopy( $tmp, $overlayRes, 0, ( ( $new[1] + $this->offset ) - $overlaySize[1] ), 0, 0, $overlaySize[0], $overlaySize[1] ); imagejpeg( $tmp, $file, $this->quality ); if( !file_exists( $file ) ) $file = $this->rootPath . $this->resourcesFolder . $this->oops; imagedestroy( $src ); imagedestroy( $tmp ); imagedestroy( $overlayRes ); return ( $this->processedFolder . $filename ); }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.