Imgedit
is a package that performs image processing such as resizing and trimming available on both CLI and GUI.
- resize
- trim
- tile (lay down images)
- reverse (
vertical
,horizon
) grayscale- add string
- filter (
gray
,sepia
) - interactive file format conversion (
png
,jpeg
,gif
)
resize | trim | tile |
reverse horizon | reverse vertical | add string |
filter gray | filter sepia | |
$ go get github.com/icemint0828/[email protected]
An example with file conversion is as follows.
package main
import (
"github.com/icemint0828/imgedit"
)
func main() {
fc, _, err := imgedit.NewFileConverter("srcImage.png")
if err != nil {
panic(err)
}
fc.Filter(imgedit.GrayModel)
err = fc.SaveAs("dstImage.png", imgedit.Png)
if err != nil {
panic(err)
}
}
It can also work with just convert bytes through io.Writer and io.Reader.
package main
import (
"bytes"
"os"
"github.com/icemint0828/imgedit"
)
func main() {
srcFile, err := os.Open("srcImage.png")
if err != nil {
panic(err)
}
defer srcFile.Close()
bc, _, err := imgedit.NewByteConverter(srcFile)
bc.ResizeRatio(0.5)
buffer := bytes.NewBuffer([]byte{})
_ = bc.WriteAs(buffer, imgedit.Jpeg)
dstFile, err := os.Create("dstImage.png")
if err != nil {
panic(err)
}
defer dstFile.Close()
_, _ = buffer.WriteTo(dstFile)
}
It can also work with just convert image.
package main
import (
"image/png"
"os"
"github.com/icemint0828/imgedit"
)
func main() {
srcFile, err := os.Open("srcImage.png")
if err != nil {
panic(err)
}
defer srcFile.Close()
srcImage, err := png.Decode(srcFile)
if err != nil {
panic(err)
}
c := imgedit.NewConverter(srcImage)
c.Resize(500, 500)
dstImage := c.Convert()
dstFile, err := os.Create("dstImage.png")
if err != nil {
panic(err)
}
defer dstFile.Close()
err = png.Encode(dstFile, dstImage)
if err != nil {
panic(err)
}
}
You can download the executable file from the link below.
Or if you can use brew
on mac OS.
$ brew install icemint0828/tap/imgedit
For more information, please use the help command:
$ imgedit -help
You can also run the CLI on docker. This procedure can only convert files under the current working directory(WD).
$ docker run --rm -e WD=$(pwd) -v $(pwd):/mnt ghcr.io/icemint0828/imgedit:latest filter srcImage.png -mode gray
For more information, please use the help command:
$ docker run --rm -e WD=$(pwd) -v $(pwd):/mnt ghcr.io/icemint0828/imgedit:latest -help
You can also use a sample GUI tool that is created with WASM
by this package.
-
Check out the image edit tool
This project is currently at early stages and is being developed by internal members.
- Report your issues through GitHub issues.
imgedit
is under MIT license.