Giter Club home page Giter Club logo

img2texture's Introduction

PyPI version shields.io Generic badge Generic badge Downloads

Command line utility for converting images to seamless tiles. It overlays images with an alpha gradient.

The resulting tiles can be used as textures in games, compositing and 3D modeling applications, etc.

⚠️ If the images below are not displayed, check out the original of this document on GitHub.

Original image x4

Source tiled

Orion galaxy by NASA/ESA, in four copies side by side.

We cannot use the original image as an endless space background: the seams are visible.

Converted image x4

Converted tiled

The result of img2texture, in four copies side by side.

The image is slightly reduced in size and the edges are modified with alpha-blending.

The converted image can be tiled and panned in any direction. It will feel endless and seamless.

Install

The easiest way is to download and extract a binary executable:

Or install as a Python package:

pip3 install img2texture

Run

Create new seamless.jpg from source.jpg.

img2texture /path/to/source.jpg /path/to/seamless.jpg 

--overlap

The --overlap option determines how much of the image will be used to hide the seams.

For example, the following command uses 25% of the width and 25% of the height of the original image:

img2texture source.jpg seamless.jpg --overlap 0.25 

Increasing the value makes the seam less visible. However, the image becomes smaller.

Sample images

⚠️ If the images below are not displayed, check out the original of this document on GitHub.

--overlap 0.05

5% of the width and 5% of the height are used to mask the seam.

--overlap 0.05

--overlap 0.4

40% of the width and 40% of the height are used to mask the seam.

--overlap 40

--tile

The --tile option will create a 2x2 tiled version in addition to the converted image.

The following command will create seamless.jpg and seamless_2x2.jpg.

img2texture source.jpg seamless.jpg --tile 

All the samples on this page were created with --tile.

Use programmatically

If you don't need CLI but need to create seamless image in your own program:

from PIL import Image
from img2texture import image_to_seamless

# load PIL image
src_image = Image.open("/path/to/source.png")

# convert to seamless PIL image
result_image = image_to_seamless(src_image, overlap=0.1)

# save
result_image.save("/path/to/result.png")

overlap=0.1 means 10%, and overlap=(0.1, 0.2) means 10% horizontal, 20% vertical.

License

Copyright © 2021 Artёm iG. Released under the MIT License.

img2texture's People

Contributors

github-actions[bot] avatar rtmigo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

img2texture's Issues

Syntax for CLI on readme is out of date, -o doesnt accept two arguments

It seems like the syntax in the github readme is out of date. from the readme
img2texture source.jpg seamless.jpg --overlap 0.25
but from the CLI itself
img2texture [-h] [-o OVERLAP] [-t] [--version] source target

Also there doesnt seem to be a way to onlu pass the horizontal tile option in the CLI

[Request] Non CLI Usage

There is a real lack of seamless texture generators for Python, especially ones that don't destroy the original image through warping and internal repeating.

Is there any chance you could provide a import route for running the functions? Currently there is only CLI which is useful programmatically without obtrusive system exec calls.

Additionally, for my current workflow, the IO time to save/load images kills the real-time effect. Seems I could get [low but decent] frame-rate if the processing wasn't utilizing disk writing and reading.

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.