本文整理匯總了PHP中SimpleImage::ext方法的典型用法代碼示例。如果您正苦於以下問題:PHP SimpleImage::ext方法的具體用法?PHP SimpleImage::ext怎麽用?PHP SimpleImage::ext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SimpleImage
的用法示例。
在下文中一共展示了SimpleImage::ext方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: makeProfilePicture
function makeProfilePicture($photo_id)
{
$this->layout = 'blue_full_block';
if (!empty($this->data)) {
$this->loadModel('MemberProfile');
$this->loadModel('PhotoUpdate');
$this->loadModel('Album');
$member_id = $this->Session->read('Member.id');
$photo = $this->Photo->getPhotoInfo($photo_id);
$albumName = $this->Photo->Album->getAlbumInfo($photo['Photo']['album_id'], 'name');
$imageDir = $this->getUploadDir($member_id, $albumName);
$imageFile = $imageDir . '/' . $photo['Photo']['picture_path'];
//measurements used in cropping
$x1 = $this->data['Photo']['x1'];
$y1 = $this->data['Photo']['y1'];
$width = $this->data['Photo']['width'];
$height = $this->data['Photo']['height'];
//location of the images.. directory of profile pictures
$profileDir = $this->getUploadDir($member_id, $this->profileAlbum);
$picturePath = $this->randomString();
//create cropped copy of image
$cropCopy = new SimpleImage();
$cropCopy->load($imageFile);
$cropCopy->crop($x1, $y1, $width, $height);
$ext = $cropCopy->ext();
//extension name
$profileCrop = $profileDir . '/profile_thumb_' . $picturePath . $ext;
//the cropped copy of image file
$cropCopy->save($profileCrop);
/*//create full copy of image
$fullCopy = new SimpleImage();
$fullCopy->load($imageFile);
$profileFull = $profileDir . '/' . $picturePath . $ext; //the full copy of image file
$fullCopy->save($profileFull);*/
//create thumbnail copy of image
$thumbCopy = new SimpleImage();
$thumbCopy->load($profileCrop);
$thumbCopy->resize(155, 115);
$profileThumb = $profileDir . '/thumb_' . $picturePath . $ext;
//the cropped copy of image file
$thumbCopy->save($profileThumb);
//save picture_path on members profile.. table used to get the profile picture
$member = $this->MemberProfile->find('first', array('conditions' => array('member_id' => $member_id), 'fields' => array('MemberProfile.id'), 'recursive' => -1));
$this->MemberProfile->id = $member['MemberProfile']['id'];
$this->MemberProfile->saveField('picture_path', '' . $picturePath . $ext);
//save path to profile picture folder..
$profile = $this->Photo->Album->find('first', array('conditions' => array('Album.member_id' => $member_id, 'Album.name' => $this->profileAlbum), 'fields' => array('Album.id'), 'recursive' => -1));
/*$this->Photo->id = $photo_id;
$this->Photo->saveField('profile_pic', 1);*/
$photo['Photo']['id'] = null;
//reset the id to create new record
$photo['Photo']['album_id'] = $profile['Album']['id'];
$photo['Photo']['picture_path'] = $picturePath . $ext;
$photo['Photo']['profile_pic'] = 1;
//assign cover picture if no photo was set yet
if ($this->Album->getCoverPicture($photo['Photo']['album_id']) == false) {
$photo['Photo']['cover_pic'] = 1;
}
//save update..
if ($this->Photo->save($photo)) {
$album_id = $this->Photo->getPhotoInfo($photo_id, 'album_id');
$this->Album->saveUpdate($album_id, 1);
}
$this->redirect(array('controller' => 'photos', 'action' => 'view', $member_id));
} else {
$this->redirect(array('controller' => 'photos', 'action' => 'view', $member_id));
}
}