Home

Awesome

Mergi

<p> <img src="https://img.shields.io/badge/imaging-4%20terminal%20lovers-00afef.svg?longCache=true&style=for-the-badge"/> </p>
ResultTerminal Code
Intromergi -t TT -i https://raw.githubusercontent.com/ashleymcnamara/gophers/master/Facepalm_Gopher.png -r "131 131" -i https://raw.githubusercontent.com/ashleymcnamara/gophers/master/Facepalm_Picard_Gopher.png -r "131 131" -a "sprite 50"

Go Doc Build Status codecov Go Report Card Teligram Chat

:tada: Basic Overview

Image manipulation <b>go library</b> plus <b>cross platform CLI tool</b>.

⚡ Features

<br />

🚀 Getting started

Install via go get

To install Mergi, use go get, or download the binary file from Releases page.

$ go get github.com/noelyahan/mergi

Usage:

 ╔╦╗╔═╗╦═╗╔═╗╦
 ║║║║╣ ╠╦╝║ ╦║
 ╩ ╩╚═╝╩╚═╚═╝╩
 let's go & make imaging fun
 http://mergi.io
 version 1.0.0

  -a string
    	Enter animation type=[sprite, slide] and the delay to get mergi gif animation ex: smooth 10
  -c value
    	Enter crop points and height and width ex: x y w h
  -f string
    	Enter true if you want to process the final output
  -i value
    	Enter images that want to merge ex: /path/img1 or url
  -o string
    	Enter image outputs file ex: out.png or out.jpg (default "out.png")
  -r value
    	Enter resize width and height of the output ex: 100 200
  -t string
    	Enter a merge template string ex: TBTBTB (default "T")
  -w value
    	Enter watermark image and points to place it, [-r w h] is optional  ex: /path/img -r w h x y

<br />

🛠 Merge

Image 1Image 2Result Image
dstImagesrcImagedstImage
dstImagesrcImagedstImage
Mergi Tool
Horizontal
mergi \
-t TT \
-i testdata/mergi_bg_1.png \
-i testdata/mergi_bg_2.png
Vertical
mergi \
-t TB \
-i testdata/mergi_bg_1.png \
-i testdata/mergi_bg_2.png
Mergi Library
image1, _ := mergi.Import(impexp.NewFileImporter("./testdata/mergi_bg_1.png"))
image2, _ := mergi.Import(impexp.NewFileImporter("./testdata/mergi_bg_2.png"))

horizontalImage, _ := mergi.Merge("TT", []image.Image{image1, image2})
mergi.Export(impexp.NewFileExporter(horizontalImage, "horizontal.png"))

verticalImage, _ := mergi.Merge("TB", []image.Image{image1, image2})
mergi.Export(impexp.NewFileExporter(verticalImage, "vertical.png"))
<br />

✂️ Crop

ImageResult Image
srcImagedstImage
Mergi Tool
mergi \
-i testdata/mergi_bg_1.png \
-c "10 40 200 110"
Mergi Library
img, _ := mergi.Import(impexp.NewFileImporter("./testdata/mergi_bg_1.png"))
res, _ := mergi.Crop(img, image.Pt(10, 40), image.Pt(200, 110))
mergi.Export(impexp.NewFileExporter(res, "crop.png"))
<br />

💣 Resize

ImageResult Image
srcImagedstImage
Mergi Tool
mergi \
-i testdata/mergi_bg_1.png \
-r "180 80"
Mergi Library
img, _ := mergi.Import(impexp.NewFileImporter("./testdata/mergi_bg_1.png"))
res, _ := mergi.Resize(img, uint(180), uint(80))
mergi.Export(impexp.NewFileExporter(res, "resize.png"))
<br />

🖃 Watermark

ImageWatermark ImageResult Image
srcImagedstImagedstImage
Mergi Tool
mergi \
-i testdata/mergi_bg_1.png \
-w "testdata/mergi_logo_watermark_90x40.png 250 10"
Mergi Library
originalImage, _ := mergi.Import(impexp.NewFileImporter("./testdata/mergi_bg_1.png"))
watermarkImage, _ := mergi.Import(impexp.NewFileImporter("./testdata/glass-mergi_logo_watermark_90x40.jpg"))

res, _ := mergi.Watermark(watermarkImage, originalImage, image.Pt(250, 10))
mergi.Export(impexp.NewFileExporter(res, "watermark.png"))
<br />

💖 Animate

Image 1Image 2Result Animation
srcImagedstImagedstImage
srcImagedstImagedstImage
Mergi Tool
Sprite Animation
mergi \
-t "TT" \
-i testdata/mergi_bg_1.png \
-i testdata/mergi_bg_2.png \
-a "sprite 50"
Smooth Animation
mergi \
-t "TT" \
-i testdata/mergi_bg_1.png \
-i testdata/mergi_bg_2.png \
-a "smooth 5"
Mergi Library
image1, _ := mergi.Import(impexp.NewFileImporter("./testdata/mergi_bg_1.png"))
image2, _ := mergi.Import(impexp.NewFileImporter("./testdata/mergi_bg_2.png"))

gif, _ := mergi.Animate([]image.Image{image1, image2}, 50)
mergi.Export(impexp.NewAnimationExporter(gif, "out.gif"))
<br />

🔥 Easing

dstImage<br/><center>InBounce</center>dstImage<br/><center>InBack</center>dstImage<br/><center>InOutQuad</center>dstImage<br/><center>InSine</center>
dstImage<br/><center>InCubic</center>dstImage<br/><center>InElastic</center>dstImage<br/><center>InOutExpo</center>dstImage<br/><center>Linear</center>
dstImage<br/><center>InOutBounce</center>dstImage<br/><center>InCirc</center>dstImage<br/><center>InOutCubic</center>dstImage<br/><center>InOutQuart</center>
dstImage<br/><center>InOutBack</center>dstImage<br/><center>InCubic</center>dstImage<br/><center>InOutCirc</center>dstImage<br/><center>InOutSine</center>
dstImage<br/><center>InExpo</center>dstImage<br/><center>OutBounce</center>dstImage<br/><center>InQuint</center>
Mergi Library

Note: Ease function can be applied with any function, in this example it's applied with Watermark function

// Load background and the square images
square, _ := mergi.Import(impexp.NewFileImporter("./testdata/square.jpg"))
bg, _ := mergi.Import(impexp.NewFileImporter("./testdata/white_bg.jpg"))

// Init images frames to add applied ease frames
frames := make([]image.Image, 0)

// Init the limts of the Ease
to := bg.Bounds().Max.X - square.Bounds().Max.X
posY := bg.Bounds().Max.Y/2 - square.Bounds().Max.Y/2
speed := 4

// Ease from 0 to width of background
for i := 0; i < to; i += speed {
  // Apply Easeing function InBounce
  posX := mergi.Ease(float64(i), 0, float64(to), mergi.InBounce)
  img, _ := mergi.Watermark(square, bg, image.Pt(int(posX), posY))
  frames = append(frames, img)
}

// For preview example, save as a gif
gif, _ := mergi.Animate(frames, 1)
mergi.Export(impexp.NewAnimationExporter(gif, "out.gif"))
<br />

🦎 Transition

dstImage<br/><center>SlideBar</center>dstImage<br/><center>Ink1</center>dstImage<br/><center>Ink2</center>dstImage<br/><center>Ink3</center>
dstImage<br/><center>ScaleUpFastRect</center>dstImage<br/><center>ScaleDownFastRect</center>dstImage<br/><center>ScaleUpFastCircle</center>dstImage<br/><center>ScaleDownFastCircle</center>

Learn more examples

💻 Contribute

$ go get github.com/noelyahan/mergi
<br />

🌠 Contributors

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<img src="https://avatars1.githubusercontent.com/u/6106461?s=460&v=4" width="100px;"/><br /><sub>Noel</sub><br />💻 📖 💬 👀 🤔 🎨
<!-- ALL-CONTRIBUTORS-LIST:END --> <br/>

This project follows the all-contributors specification. Contributions of any kind are welcome!

<br />

🔵 License

This project is licensed under the MIT License - see the LICENSE.md file for details