本文整理汇总了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));
}
}