本文整理汇总了PHP中photo::getImgData方法的典型用法代码示例。如果您正苦于以下问题:PHP photo::getImgData方法的具体用法?PHP photo::getImgData怎么用?PHP photo::getImgData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类photo
的用法示例。
在下文中一共展示了photo::getImgData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createMyPhoto
public function createMyPhoto($imgFilename)
{
$result = array("error" => true);
$imgFilename_ext = pathinfo($imgFilename, PATHINFO_EXTENSION);
$imgNewName = helper::generateHash(7);
$imgOrigin = "origin_" . $imgNewName . "." . $imgFilename_ext;
$imgNormal = "normal_" . $imgNewName . "." . $imgFilename_ext;
$imgPreview = "preview_" . $imgNewName . "." . $imgFilename_ext;
if ($this->checkImg($imgFilename)) {
list($w, $h, $type) = getimagesize($imgFilename);
if (rename($imgFilename, "../../" . TEMP_PATH . $imgOrigin)) {
$imgFilename = "../../" . TEMP_PATH . $imgOrigin;
}
if ($type == IMAGETYPE_JPEG) {
$this->img_resize($imgFilename, "../../" . TEMP_PATH . $imgNormal, 800, 0);
$photo = new photo($this->db, $imgFilename, 512);
imagejpeg($photo->getImgData(), "../../" . TEMP_PATH . $imgPreview, 100);
unset($photo);
$result['error'] = false;
} elseif ($type == IMAGETYPE_PNG) {
//PNG
$this->img_resize($imgFilename, "../../" . TEMP_PATH . $imgNormal, 800, 0);
$photo = new photo($this->db, $imgFilename, 512);
imagepng($photo->getImgData(), "../../" . TEMP_PATH . $imgPreview);
unset($photo);
$result['error'] = false;
} else {
$result['error'] = true;
}
}
if ($result['error'] === false) {
$cdn = new cdn($this->db);
$response = array();
$response = $cdn->uploadMyPhoto("../../" . TEMP_PATH . $imgOrigin);
if ($response['error'] === false) {
$result['originPhotoUrl'] = $response['fileUrl'];
}
$response = $cdn->uploadMyPhoto("../../" . TEMP_PATH . $imgNormal);
if ($response['error'] === false) {
$result['normalPhotoUrl'] = $response['fileUrl'];
}
$response = $cdn->uploadMyPhoto("../../" . TEMP_PATH . $imgPreview);
if ($response['error'] === false) {
$result['previewPhotoUrl'] = $response['fileUrl'];
}
@unlink("../../" . TEMP_PATH . $imgOrigin);
@unlink("../../" . TEMP_PATH . $imgNormal);
@unlink("../../" . TEMP_PATH . $imgPreview);
}
return $result;
}