![](/img/trans.png)
[英]How to pass Imagemagick montage output and image properties to the convert command without using any temporary files?
[英]How to improve image output from montage in ImageMagick?
我使用蒙太奇加入圖像,但圖像輸出的分辨率低於圖像輸入的分辨率。
我的圖像輸入的尺寸為640x480
但我得到的輸出是256x378
我在網上搜索,找不到提高輸出圖像質量的解決方案。
我正在使用的蒙太奇命令
montage -tile 2x3 1.png 2.png 3.png 4.png 5.png 6.png -resize 1024x1024 montage_png.png
任何人都知道如何獲得更好的輸出分辨率?
將操作模式( -mode
)設置為concatenate
值( 如文檔中所示 )。
例如:
montage -mode concatenate file1.jpg file2.jpg output.jpg
建議1
試試這種方式......讓montage
將圖像整理成蒙太奇,然后傳遞結果進行convert
以調整結果的大小。
montage -tile 2x3 1.png 2.png 3.png 4.png 5.png 6.png miff:- | convert miff:- -resize 1024x1024 montage.png
中間圖像作為MIFF(Magick圖像文件格式)傳遞,其保留所有細節和元數據和質量。
建議2
如果它總是只有5或6個圖像而不是數百個,你也可以一次性使用這樣的convert
。 您需要知道的是, +append
連接圖像並且-append
將圖像連接到列中。 所以我連續加入1和2,連續加入3和4,連續加入5和6,然后將三行放入堆棧並調整結果大小。
convert [12].png +append \( [34].png +append \) \( [56].png +append \) -append -resize 1024x1024 result.png
蒙太奇很容易使用,如下所示:
montage -mode concatenate -tile 2x3 *.png -resize 1024x1024 outfile.png
但是,如果你第二次運行它,這個命令也將包括outfile.png作為新蒙太奇的一部分,當然。
蒙太奇足夠聰明,可以正確地更改格式,因此命令可以更改為:
montage -mode concatenate -tile 2x3 *.png -resize 1024x1024 outfile.jpg
這導致文件寬度為2048像素。
如果輸入文件大小均勻,最簡單的方法是使用它:
montage -mode concatenate -tile 2x3 *.jpg outfile.jpg
至於問題的關鍵點:
在帶有png
終端的gnuplot
,默認畫布大小為640x480,因此對於正確的JPG
,2x3蒙太奇會產生1280像素寬的文件。
顯示在太寬而無法打印的網頁上。 打印邊界大約為640像素寬(取決於邊距的設置方式),因此它通常適用於:
montage -mode concatenate -tile 2x3 -resize 320x240 *.png outfile.jpg
使用320x240可保留原始圖的縱橫比。
如果這是期望的結果,則應該在gnuplot
內的set terminal
命令中強制它為正方形。
圖像后處理的最佳實踐是避免使圖像扭曲超出生成原件的程序的意圖。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.