Coder Social home page Coder Social logo

9-patchedit's Introduction

9pedit

Batch edit 9patch files from the command line.

Usage

9pedit - Batch editing for 9-patch pngs

Syntax:
	9pedit {command options} file...

Each file is processed in order and the commands given on the command
line are applied to each.  When all commands are applied to a file it
is saved.  If the commands result in a 9-patch, a .9.png will be saved.
If the commands result in a regular .png, then a .png file will be saved.

Command options:
	-clear: Reset the 9-patch border to #00000000.  Presumes that a border is present
			Converts to .9.png if not already.
	-strip: If is a .9.png, converts back to a standard .png, removing the border
	-sx {pixels}: Set the given pixels on the x-scale axis (top)
	-sy {pixels}: Set the given pixels on the y-scale axis (left)
	-px {pixels}: Set the given pixels on the x-padding axis (bottom)
	-py {pixels}: Set the given pixels on the y-padding axis (right)
	-template {source.9.png}: Gets border information from another file

All arguments that take {pixels} take a comma delimitted list of zero based
pixel numbers or ranges.  Example: 0,1,10-20

Download

Either check the project out and build by doing "ant dist" (note you need to git submodule init && git submodule update after clone) -or- download prebuilt binaries from the dist folder:

Examples

Convert a standard png to 9-patch:

athena:files stella$ 9pedit -clear raw.png 
--> Processing file raw.png
  - Image is 28x28 pixels
  + Clear 9 patch border area to default
  => Saving to raw.9.png

Convert a 9-patch to a standard png (remove border):

athena:files stella$ 9pedit -strip raw.9.png
--> Processing file raw.9.png
  - Image is 30x30 pixels
  + Strip 9-patch border and convert to standard png
  => Saving to raw.png

Programmatically set scale and padding pixels:

athena:files stella$ 9pedit -sx 14 -sy 15 -px 9-19 -py 4-25 raw.png
--> Processing file raw.png
  - Image is 28x28 pixels
  + Set x scale points 14
  + Set y scale points 15
  + Set x padding points 9-19
  + Set y padding points 4-25
  => Saving to raw.9.png	

Copy scale and padding pixels from another 9-patch:

athena:files stella$ 9pedit -template template.9.png raw.png
--> Processing file raw.png
  - Image is 28x28 pixels
  + Set x scale points 15
  + Set x padding points 9,10,11,12,13,14,15,16,17,18,19
  + Set y scale points 14
  + Set y padding points 4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25
  => Saving to raw.9.png

Update an existing 9-patch:

athena:files stella$ 9pedit -clear -sx 14 -sy 15 raw.9.png
--> Processing file raw.9.png
  - Image is 30x30 pixels
  + Clear 9 patch border area to default
  + Set x scale points 14
  + Set y scale points 15
  => Saving to raw.9.png	

Expand a 9-patches to new sizes and save as standard pngs (I did this as a shortcut to building a bigger combined background image in the image editor):

athena:btn stella$ 9pedit -expand 34x34 -out ../session -strip nav.9.png
Will save images to ../session
--> Processing file nav.9.png
  - Image is 22x21 pixels
  + Expand 9-patch to 34x34
  + Strip 9-patch border and convert to standard png
  => Saving to ../session/nav.png

9-patchedit's People

Contributors

stellaraccident avatar alexfrostdev avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

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.