JPEG๊ฐ ์์ต๋๋ค.
PNG๋ฅผ ์ฝ์ ํ๊ณ ์ถ์ต๋๋ค.
JPEG์ ์์น 128x128.
ํ ๋
vips insert tile.jpg pin.png newimage.jpg 128 128
pin.jpg์๋ ์ํ ์ฑ๋์ด ์๊ณ tile.jpg์๋ ์๊ธฐ ๋๋ฌธ์ Error Output: insert: images must have the same number of bands, or one must be single-band
๋ฅผ์ค๋๋ค.
๊ทธ๋์ jpg๋ฅผ png๋ก ๋ณํํฉ๋๋ค.
convert tile.jpg png32:tile.png
์ด์ ์ํ ์ฑ๋์ด์๋ tile.png๊ฐ ์์ต๋๋ค.
ํ์ง๋ง ์ง๊ธ ์ ํํ๋ฉด :
vips insert tile.png pin.png newimage.png 128 128
๋ค์์ ์ป์ต๋๋ค.
์ฝ์ ๋ pin.png์ ๋ฐฐ๊ฒฝ์ ํฐ์์ ๋๋ค.
vips insert --help-all
ํ์ง๋ง ์ค์ ๋ก ์ ์ฉํ ๋ช
๋ น ์ค ๋งค๊ฐ ๋ณ์๋ฅผ ์ฐพ์ง ๋ชปํ์ต๋๋ค. ๋ ์ด๋ฏธ์ง ๋ชจ๋ ์ํ ์ฑ๋์ด ์์ต๋๋ค. ๋ด ์ง๋ฌธ :
insert
๋ช
๋ น์ ํฌ๋ช
ํ ๋ฐฐ๊ฒฝ์ ์ง์ํฉ๋๊น?LG
์ฝ๋ ์๋ฏผ
์๋ ํ์ธ์ @codecitizen ,
insert
์ (๋) ๋งค์ฐ ๋ฎ์ ์์ค์ ์์
์
๋๋ค. ํ๋์ ์ด๋ฏธ์ง๋ฅผ ๋ค๋ฅธ ์ด๋ฏธ์ง ์์ ๋๊ธฐ ๋งํ๊ณ ์ด๋ค ๋ธ๋ ๋ฉ๋ ์ํํ์ง ์์ต๋๋ค.
ํ์ฌ libvips์์๋ blend
์ต์
๊ณผ ํจ๊ป ifthenelse
๋ฅผ ์ฌ์ฉํด์ผํฉ๋๋ค. ๊ฝค ๋์ฐํฉ๋๋ค.
# get the alpha channel from the overlay
vips extract_band marker.png alpha.png 3 --n 1
# get RGB from the overlay
vips extract_band marker.png rgb.png 0 --n 3
# find the size of the overlay
width=$(vipsheader -f width marker.png)
height=$(vipsheader -f height marker.png)
# cut out an area the size of marker from the background
vips extract_area background.jpg bg.png 128 128 $width $height
# blend the marker on top of the chunk of background
vips ifthenelse alpha.png rgb.png bg.png blended.png --blend
# insert the blended image back into the background
vips insert background.jpg blended.png final.jpg 128 128
์ด๊ฒ์ ์์ฑํ๋ ค๋ฉด :
libvips 8.6์๋ ๋ชจ๋ ์ผ๋ฐ์ ์ธ ๋ธ๋ ๋ฉ ๋ชจ๋๋ฅผ ์ํ ํ ์์๋ ๋ฉ์ง ์ composite
์ฐ์ฐ์๊ฐ ์์ต๋๋ค. ๋ ํ ์์์ด:
vips composite "background.jpg marker.png" final.jpg 2
2
๋ over
๋ธ๋ ๋ ๋ชจ๋๋ฅผ ์๋ฏธํฉ๋๋ค. ๋ชจ๋ PDF ํผํฉ ๋ชจ๋๋ฅผ ์ง์ํฉ๋๋ค. ์ผ์ฃผ์ผ ์ ๋๋ฉด ๋์ฌ ๊ฒ๋๋ค.
@jcupitt ์๋
ํ์ธ์, ๊ฐ์ฌํฉ๋๋ค. libvips 8.6์ ์ค์นํ๊ณ vips composite
๋ ํ๋ฅญํ๊ฒ ์๋ํ์ต๋๋ค. ๊ฐ๋ฅํ ๊ฒฝ์ฐ ๋ ๋ฒ์งธ ์ด๋ฏธ์ง์ ์์น๋ฅผ โโ์ง์ ํ๋ ๋ฐฉ๋ฒ์ ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค.
ํฐ ์ด๋ฏธ์ง์ ๋ง๊ฒ ์ค๋ฒ๋ ์ด๋ฅผ ํ๋ ํ ๋ค์ ๋ค์์ ๊ตฌ์ฑ ํ ์ ์์ต๋๋ค.
width=$(vipsheader -f width background.jpg)
height=$(vipsheader -f height background.jpg)
vips embed marker.png overlay.png 128 128 $width $height
vips composite "background.jpg overlay.png" final.jpg 2
๋๋ ๋ฐฐ๊ฒฝ์ ์ผ๋ถ๋ฅผ ์๋ผ ๋ด๊ณ ๊ตฌ์ฑํ ๋ค์ ๋ค์ ์ฝ์ ํฉ๋๋ค (์์ ๊ฐ์ด).
์ด๊ฒ์ ์ผ๋ฐ์ ์ผ๋กํ๊ณ ์ถ์ ์ผ์ฒ๋ผ ๋ณด์ด๋ฉฐ, ์๋ง๋ ์์น๋ฅผ ์ง์ ํ๋ ์ต์ ์ด์์ ๊ฒ์ ๋๋ค.
๋๋ฐ! ๋น ๋ฅธ ๋์์ ๊ฐ์ฌ๋๋ฆฝ๋๋ค!
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
ํฐ ์ด๋ฏธ์ง์ ๋ง๊ฒ ์ค๋ฒ๋ ์ด๋ฅผ ํ๋ ํ ๋ค์ ๋ค์์ ๊ตฌ์ฑ ํ ์ ์์ต๋๋ค.
๋๋ ๋ฐฐ๊ฒฝ์ ์ผ๋ถ๋ฅผ ์๋ผ ๋ด๊ณ ๊ตฌ์ฑํ ๋ค์ ๋ค์ ์ฝ์ ํฉ๋๋ค (์์ ๊ฐ์ด).
์ด๊ฒ์ ์ผ๋ฐ์ ์ผ๋กํ๊ณ ์ถ์ ์ผ์ฒ๋ผ ๋ณด์ด๋ฉฐ, ์๋ง๋ ์์น๋ฅผ ์ง์ ํ๋ ์ต์ ์ด์์ ๊ฒ์ ๋๋ค.