如何使用PHP創建帶有白色3px邊框的縮略圖圖像?如何使用PHP創建帶有白色3px邊框的縮略圖圖像?
0
A
回答
2
實際上還沒有試過,但我覺得這樣的事情可能會奏效
<?php
/*
* Function to create a border around an image
*/
function drawBorder($image_name, $r = 0, $g = 0, $b = 0, $thickness = 1)
{
$image = ImageCreateFromJPEG($image_name);
$color = ImageColorAllocate($img, $r, $g, $b);
$x1 = 0;
$y1 = 0;
$x2 = ImageSX($image) - 1;
$y2 = ImageSY($image) - 1;
for($i = 0; $i < $thickness; $i++)
{
ImageRectangle($image, $x1++, $y1++, $x2--, $y2--, $color);
}
return $image;
}
?>
然後運行像
<?php
header('Content-type: image/jpeg');
ImageJPEG(drawBorder("images/foo.jpg", 128, 128, 0, 3));
?>
0
創建一個jpg(或gif/png),它是6px高度和6px比給定的縮略圖更多。採取所需的邊框顏色作爲背景顏色。那麼在它的縮略圖複製與startingpos的3px,3px的;-)
最佳實踐使用imagick庫
0
function addBorderpng($add){
$border=5;
$im=imagecreatefrompng($add);
$width=imagesx($im);
$height=imagesy($im);
$img_adj_width=$width+(2*$border);
$img_adj_height=$height+(2*$border);
$newimage=imagecreatetruecolor($img_adj_width,$img_adj_height);
$border_color = imagecolorallocate($newimage, 255, 255, 255);
imagefilledrectangle($newimage,0,0,$img_adj_width,
$ img_adj_height,$ border_color);
imagecopyresized($newimage,$im,$border,$border,0,0,
$ width,$ height,$ width,$ height); imagepng($ newimage,$ add,9); chmod(「$ add」,0666);
}
相關問題
- 1. php縮略圖 - 創建一個顆粒狀的背部和白色圖像
- 2. 在圖像上沒有白色邊框
- 3. 使用ffmpeg創建帶有播放圖標的縮略圖
- 4. PHP:使用X,Y座標創建縮略圖圖像
- 5. 使用GridFS + MongoDB + PHP創建縮略圖
- 6. 使用PHP創建縮略圖
- 7. PHP的圖像壓縮和縮略圖創建
- 8. Jquery Mobile動態縮略圖列表 - 如何創建邊框?
- 9. 在Safari中使用webkitTransform縮放iframe會創建白色邊框
- 10. 創建帶圓角的圖像縮略圖
- 11. 如何使用PHP創建圖像縮略圖並插入數據庫?
- 12. AvalancheImagineBundle無法創建縮略圖圖像?
- 13. 爲圖像網格創建縮略圖
- 14. 通過ffmpeg.exe創建縮略圖圖像
- 15. 爲燈箱圖像創建縮略圖
- 16. 如何創建邊框圖像?
- 17. Mapbox白色邊框地圖
- 18. 使用PHP創建圖像的縮略圖10-20同時並行與PHP
- 19. PHP縮略圖圖像
- 20. 如何在我的模板中創建縮略圖縮略圖
- 21. 如何用白色墊/邊框與magickwand圖像?
- 22. 用Symfony或PHP創建縮略圖
- 23. 如何在Slick.js中創建帶圖像預覽的縮略圖旋轉木馬?
- 24. ExtJS FormPanel帶文件上傳旁邊的圖像縮略圖
- 25. 在編輯框上創建帶有邊距的背景圖像
- 26. ALAsset縮略圖沒有向內的黑色半透明邊框
- 27. php創建服務器上的圖像縮略圖
- 28. PHP:創建裁剪圖像的縮略圖,問題
- 29. 創建縮略圖
- 30. 創建縮略圖
爲什麼不使用CSS來添加邊框? – 2010-06-11 08:50:08
'' – jigfox 2010-06-11 08:55:32
請參閱[各種縮略圖問題](http://stackoverflow.com/search?q=thumbnail+php)和[給圖像創建邊界以PHP](http://stackoverflow.com/questions/ 3006007 /給邊界到圖像創建的php) – Gordon 2010-06-11 09:10:58