- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前正在使用intervention/image调整图像大小并将其另存为JPG。
我在Windows中本地运行,在Ubuntu 20.20中远程运行相同的代码。
在Windows中,它将PNG转换为JPG,将透明背景转换为白色。但是,在Ubuntu中,在白色背景之上添加了黑色噪音。
我运行的代码是:
$resize = Image::make($img)->encode('jpg');
$resize->height() > $resize->width() ? $width = null : $height = null;
$resize->resize($width, $height, function ($constraint) {
$constraint->aspectRatio();
});
我是否应该在
encode
之前添加其他内容,以确保透明度变为白色?
最佳答案
来自:image.intervention.io/getting_started/configuration
Memory Settings
Image manipulation in PHP is a very memory consuming task. Since most tasks in PHP don't exhaust default memory limits, you have to make sure your PHP configuration is able to allocate enough memory to handle large images.
The following php.ini directives are important.
memory_limit
Sets a maximum amount of memory in bytes that a script is allowed to allocate. Resizing a 3000 x 2000 pixel image to 300 x 200 may take up to 32MB memory.
gd
或
imagick
。
关于laravel - 将PNG另存为JPG时,图像干预会在背景上添加黑噪声,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62952108/
我有 json 数据: { "products": [ { "productId" : 0, "productImg" : "../img/product-ph
我是一名优秀的程序员,十分优秀!