ProductPromotion
Logo

Go.Lang

made by https://0x3d.site

GitHub - noelyahan/mergi: go library for image programming (merge, crop, resize, watermark, animate, ease, transit)
go library for image programming (merge, crop, resize, watermark, animate, ease, transit) - noelyahan/mergi
Visit Site

GitHub - noelyahan/mergi: go library for image programming (merge, crop, resize, watermark, animate, ease, transit)

GitHub - noelyahan/mergi: go library for image programming (merge, crop, resize, watermark, animate, ease, transit)

Mergi

Result Terminal Code
Intro mergi -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 go library plus cross platform CLI tool.

โšก Features

  • ๐Ÿ›  Merge
  • โœ‚๏ธ Crop
  • ๐Ÿ’ฃ Resize
  • ๐Ÿ–ƒ Watermark
  • ๐Ÿ’– Animate
  • ๐Ÿ”ฅ Easing
  • ๐ŸฆŽ Transition

๐Ÿš€ 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

๐Ÿ›  Merge

Image 1 Image 2 Result Image
dstImage srcImage dstImage
dstImage srcImage dstImage
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"))

โœ‚๏ธ Crop

Image Result Image
srcImage dstImage
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"))

๐Ÿ’ฃ Resize

Image Result Image
srcImage dstImage
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"))

๐Ÿ–ƒ Watermark

Image Watermark Image Result Image
srcImage dstImage dstImage
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"))

๐Ÿ’– Animate

Image 1 Image 2 Result Animation
srcImage dstImage dstImage
srcImage dstImage dstImage
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"))

๐Ÿ”ฅ Easing

dstImageInBounce dstImageInBack dstImageInOutQuad dstImageInSine
dstImageInCubic dstImageInElastic dstImageInOutExpo dstImageLinear
dstImageInOutBounce dstImageInCirc dstImageInOutCubic dstImageInOutQuart
dstImageInOutBack dstImageInCubic dstImageInOutCirc dstImageInOutSine
dstImageInExpo dstImageOutBounce dstImageInQuint
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"))

๐ŸฆŽ Transition

dstImageSlideBar dstImageInk1 dstImageInk2 dstImageInk3
dstImageScaleUpFastRect dstImageScaleDownFastRect dstImageScaleUpFastCircle dstImageScaleDownFastCircle

Learn more examples

๐Ÿ’ป Contribute

  • Clone the repository
$ go get github.com/noelyahan/mergi
  • Run unit tests
  • Fix bug
  • Add new feature
  • Push

๐ŸŒ  Contributors

Noel๐Ÿ’ป ๐Ÿ“– ๐Ÿ’ฌ ๐Ÿ‘€ ๐Ÿค” ๐ŸŽจ

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

Star History

Star History Chart

๐Ÿ”ต License

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

Articles
to learn more about the golang concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Queries
or most google FAQ's about GoLang.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory