0
A
回答
1
如果你喜欢使用GD
了ImageMagick的,你可以做这样的:
<?php
// Load the PNG image
$im = imageCreateFromPng("image.png");
// Ensure true colour
imagepalettetotruecolor($im);
// Iterate over all pixels
for ($x = 0; $x < imagesx($im); $x++) {
for ($y = 0; $y < imagesy($im); $y++) {
// Get color, and transparency of this pixel
$col=imagecolorat($im,$x,$y);
// Extract alpha
$alpha = ($col & 0x7F000000) >> 24;
// Make black with original alpha
$repl=imagecolorallocatealpha($im,0,0,0,$alpha);
// Replace in image
imagesetpixel($im,$x,$y,$repl);
}
}
imagePNG($im,"result.png");
?>
2
你可以让所有的颜色去黑头使用ImageMagick的一个门槛功能是这样的:
<?php
// Load the PNG image
$im = new Imagick("image.png");
// Make everything black
$im->thresholdimage(65536);
$im->writeImage("result.png");
?>
它可能会更合适做虽然这样说,万一您曾经使用每通道量化超过16位:
#!/usr/local/bin/php -f
<?php
// Load the PNG image
$im = new Imagick("image.png");
// Work out quantum range - probably 255 or 65535
$m=$im->getQuantumRange();
$m=$m["quantumRangeLong"];
// Make everything darker than that black
$im->thresholdimage($m);
$im->writeImage("result.png");
?>
相关问题
- 1. UWP透明png颜色叠加
- 2. CSS背景图像颜色叠加
- 3. jQuery的图像悬停颜色叠加
- 4. 图像颜色叠加在HTML5/JS
- 5. php Imagick颜色叠加
- 6. 更改png图像的颜色
- 7. SWF图像(JPG,PNG,...)与PHP
- 8. AS3颜色叠加
- 9. 叠加图像MATLAB(带颜色的灰色)
- 10. 如何控制重叠图像颜色?
- 11. 如何在图像上添加颜色叠加层
- 12. VB.net透明PNG彼此叠加..获取表单背景颜色
- 13. 合并透明PNG图像与其他PNG图像 - PHP
- 14. CSS中的图片颜色叠加
- 15. 加载RGB PNG导致黑色图像
- 16. Windows Phone 7 - 来自URL的图像颜色叠加
- 17. 将背景图像叠加到背景颜色上
- 18. 在图像上显示颜色叠加层NOT in selector
- 19. 颜色叠加图像使用文本的样式效果
- 20. 每个图像悬停的css颜色叠加
- 21. 在OPEN CV中叠加图像的颜色强度Python
- 22. 用颜色叠加WriteableBitmap
- 23. 颜色叠加在悬停
- 24. 从PNG图像中提取像素颜色
- 25. PHP GD:用色调颜色乘以图像颜色
- 26. PNG ++读取像素颜色值
- 27. PNG颜色问题
- 28. PHP imagecopy删除PNG的颜色
- 29. 即时更改PNG颜色(PHP/JS)
- 30. 颜色重叠
创建另一个图像,并相应地显示出来。 –
嗯....我需要使用php自动化进程。 – remtsoy
所以试过了吗? –