Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

前后端代码做了很多优化,增加了功能说明,后端性能提升,减少内存占用,加了一些注释。 #10

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

askme-gpt
Copy link

No description provided.

Copy link
Author

@askme-gpt askme-gpt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以看看

require_once("sandphoto.inc");

$filename = "/var/www/sandcomp/apache/htdocs/sandphoto/sample.jpg";
$temp_path = "/var/www/sandcomp/apache/htdocs/sandphoto/temp";
$temp_path = __DIR__ . '/temp';
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改成动态地址,避免写死目录,换地地方部署不需要创建对应目录,支持部署多个应用

$p->set_target_size($tw, $th);
$n = $p->put_photo($filename, $bgcolorid);
$p->preview_image($cachePath);
exec('/usr/bin/optipng ' . $cachePath . " >/dev/null 2>/dev/null");
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exec相对system来说安全一点

$pos_x = $w_start + ($this->target_width + $GAP) * $i;
for ($j = 0; $j < $hn; $j++) {
$pos_y = $h_start + ($this->target_height + $GAP) * $j;
imagecopy($this->im, $temp, $pos_x, $pos_y, 0, 0, $this->target_width, $this->target_height);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

性能提升,内存占用降低

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants