-4
A
回答
1
你可以使用GD庫。
// Load the three image files:
$images[1]=imagecreatefromjpeg("file1.jpg");
$images[2]=imagecreatefromjpeg("file2.jpg");
$images[3]=imagecreatefromjpeg("file3.jpg");
// Determine their dimensions.
$totalx=$totaly=0;
for ($ix in $images) {
$img=$images[$ix];
$totalx+=imagesx($img); // get total width
$totaly=max($totaly,imagesy($img)); // get maximum height
}
$xm=20; // side and in-between margin
$ym=20; // top and bottom margin
$totalx+=$xmargin*4; // 2 for the outsides and 2 for the in-betweens
$totaly+=$ymargin*2; // for top and bottom
$i=imagecreatetruecolor($totalx,$totaly);
$xstart=0; // where to place the next image
for ($ix in $images) {
$img=$images[$ix];
$xstart+=$imagesx($img)+$xm; // increase by this image's width plus buffer
imagecopy($i,$img,$xstart,$ym,0,0,imagesx($img),imagesy($img));
}
imagepng($i); // this outputs the image data. if you want to write it to a file you can do that with imagepng($i,$filename).
+0
請記住,您需要使用正確的圖像加載功能。例如,如果源圖像是PNG,那麼您需要使用imagecreatefrompng()而不是imagecreatefromjpeg()。您可以掃描文件名或使用MIME類型來確定圖像格式,然後從*()函數調用相應的圖像 - 有趣的是,這些函數的結尾與MIME類型值匹配!同樣,如果你想輸出非PNG的東西,你必須使用例如imagejpeg($ i)而不是imagepng($ i)。 –
+0
此外,如果您希望圖像在最終圖像中的大小相同,則可以在imagecopy()調用中使用所需的w/h值而不是圖像()和imagesy()。在我的例子中,我推測你想要的圖像尺寸與原來相同。 –
相關問題
- 1. Glance image create stuck in SAVING status
- 2. 調度ec2-create-image cron作業
- 3. php Image Resize Over-Compressing
- 4. PHP Image Generation
- 5. Php Twitter Post Image
- 6. php image upload
- 7. PHP Image上傳
- 8. PHP Image Resize(gallery)
- 9. PHP Image Upload
- 10. PHP - tcpdf multiCell image
- 11. PHP get image src
- 12. php image gallery
- 13. PHP GD Image問題
- 14. opensource php image gallery/manager
- 15. image magick php,安裝
- 16. PHP text over image foreach
- 17. PHP Image Upload檢查尺寸
- 18. PHP Image Resize,Thumbnailer問題
- 19. PHP MYSQL CREATE TABLE問題
- 20. CREATE標識符----使用PHP
- 21. $ path =「Image /".$_ FILES [」image「] [」name「];
- 22. image profile facebook to base64 PHP
- 23. Summernote Image Upload Not Working(PHP)
- 24. PHP Image上傳通過JQUERY
- 25. php image type,mozila和IE7
- 26. PHP BASE64 to Image轉換
- 27. php image上傳到mysql
- 28. isset image upload php not working
- 29. PHP imagick convert svg to image issue
- 30. 在php image中的會話
的[PHP:GD](http://php.net/manual/en/book.image.php)文檔,[A相關的問題](HTTP://計算器。 com/questions/645582 /如何在圖表中繪製圖表)和[通用Google搜索](https://www.google.com/search?q=php%20make%20graph)可能做好出發點 – castis
這是如此的廣泛?他很清楚自己想做什麼:製作一張包含三張帶邊框圖像的圖像。如果你沒有看到他給出的示例圖像,它只是廣泛的。 –