Coder Social home page Coder Social logo

icemint0828 / imgedit Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 1.0 8.43 MB

Imgedit is a package that performs image processing such as resizing and trimming.

License: MIT License

Makefile 3.66% Go 96.20% Dockerfile 0.14%
cli go golang image-processing grayscale resize reverse trim file-conversion tile

imgedit's Introduction

imgedit

GitHub go.mod Go version Go project version Go Go Report Card codecov CodeFactor golang example License: MIT

Overview

Imgedit is a package that performs image processing such as resizing and trimming available on both CLI and GUI.

Features

  • 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
resize trim tile
reverse horizon reverse vertical add string
reverse horizon reverse vertical add string
filter gray filter sepia
filter gray filter sepia

Usage (Package)

$ 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)
    }
}

Usage (CLI)

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

Usage (CLI on docker)

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

Usage (GUI)

You can also use a sample GUI tool that is created with WASM by this package.

Contributing

This project is currently at early stages and is being developed by internal members.

License

imgedit is under MIT license.

imgedit's People

Contributors

icemint0828 avatar pouriyajamshidi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

pouriyajamshidi

imgedit's Issues

Add text on image like logo

It's just an idea that came to me quickly, so maybe it will go away.
It would be nice if it were possible to specify the details of the text to be placed, but I'll think about that later.

release v1.3.0 check list

Please review the following tasks.

  • Ensure milestones are at 100%.
  • Cut out the working branch.
    git checkout -b release-v1.3.0
  • Update the version of cmd/main.go.
  • Update CHANGELOG.md.
  • Push changes related to the release.
    git push origin
  • Create new version of tag.
    git tag v1.3.0
    git push origin v1.3.0
  • Create release note according to CHANGELOG.md.
  • Attach binaries to release note.
    make build

release v1.4.0 check list

Please review the following tasks.

  • Ensure milestones are at 100%.
  • Cut out the working branch.
    git checkout -b release-v1.4.0
  • Update the version of cmd/main.go.
  • Update CHANGELOG.md.
  • Push changes related to the release.
    git push origin
  • Create new version of tag.
    git tag v1.4.0
    git push origin v1.4.0
  • Create release note according to CHANGELOG.md.
  • Attach binaries to release note.
    make build
  • Update homebrew-tap file.

The color of the gif is not smooth

In some cases, when the final image file is generated as a gif, the color change is not smooth.

This is probably due to the fact that palette.Plan9 is used for the palette and 256 colors are not used effectively.
We need a way to use 256 colors effectively.

Added the feature of converting images into sepia colors

This is similar to the already existing GrayScale function.

Therefore, we create a function called Filter and implement it so that Sepia and Gray can be passed as arguments.

The Grayscale function is deprecated and will be retained during one minor version next v1.3.0.

Combine ReverseX and ReverseY into Reverse

ReverseX and ReverseY both have the same functionality.
Therefore, they are grouped together in Reverse and supported by an argument.

Note that ReverseX and ReverseY should be deprecated.

release v1.5.0 check list

Please review the following tasks.

  • Ensure milestones are at 100%.
  • Cut out the working branch.
    git checkout -b release-v1.5.0
  • Update the version of cmd/main.go.
  • Update the version of README.md.
  • Update CHANGELOG.md.
  • Push changes related to the release.
    git push origin
  • Create new version of tag.
    git tag v1.5.0
    git push origin v1.5.0
  • Create release note according to CHANGELOG.md.
  • Attach binaries to release note.
    make build
  • Update homebrew-tap file.

Transparency processing in gif images is not working well

When a transparent gif is processed, the transparent area is filled with black.
The same thing happens when a transparent png is converted to a transparent gif.

However, this does not occur with transparent png.
So I think the problem is in the vicinity of gif.Encode.

Add ByteConverter

We would like to be able to handle this package in io.Writer and io.Reader as well.

Support for multiple lines for AddString

Currently, AddString only supports single rows.
If we detect line breaks and draw letters in the appropriate positions, we would be able to handle multiple lines.

Add text on image like logo with CLI

Our package supports Add text on image.
This feature may be added to the CLI as well.

Because of the complexity of implementing all options, the options are limited to the following.

required

  • text

optional

  • ttf
  • size
  • left
  • top
  • color(Specified by several strings. e.g)Black, white, red, blue, etc.)

Outlines are currently not supported.

release v1.6.0 check list

Please review the following tasks.

  • Ensure milestones are at 100%.
  • Cut out the working branch.
    git checkout -b release-v1.6.0
  • Update the version of cmd/main.go.
  • Update the version of README.md.
  • Update CHANGELOG.md.
  • Push changes related to the release.
    git push origin
  • Create new version of tag.
    git tag v1.6.0
    git push origin v1.6.0
  • Create release note according to CHANGELOG.md.
  • Attach binaries to release note.
    make build
  • Update homebrew-tap file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.