npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

com.xmobitea.changx.mini-texturecrop

v1.5.2

Published

XmobiTea Unity Toolkit packages

Readme

XmobiTea TextureCrop

Editor-only texture cropping window for opening an image file, adjusting board/offset/scale, and saving the baked result.

AI Quick Contract

  • This package is Editor-only
  • Main window: TextureCropWindowsEditor
  • Main menus:
    • XmobiTea Tools/Texture Crop/Show Windows
    • Assets/Texture Crop/Show Windows
  • Works with selected Texture2D or Sprite
  • Apply overwrites the currently opened file on disk
  • Save As writes a new file and reopens it
  • The tool edits raw image bytes, not Unity importer metadata
  • Current 9-Slice mode is pixel-cropping logic, not Unity sprite border authoring
  • Save implementation only handles .png and .jpg, even though the dialog also offers .jpeg and .jpe

What This Package Provides

  • fixed-size editor utility window for image cropping
  • manual board size and scaling controls
  • trim and power-of-two helpers
  • undo/redo state stacks
  • corner-only 9-Slice crop mode

Exact Editor Behavior

Opening The Tool

Menus:

XmobiTea Tools/Texture Crop/Show Windows
Assets/Texture Crop/Show Windows

Assets/Texture Crop/Show Windows is only valid when the current selection is:

  • Texture2D
  • Sprite

The asset-path flow opens the selected file from disk and loads it into a temporary Texture2D.

Board Size And Canvas Behavior

Initial/default board size is:

512 x 512

Allowed board-size range is clamped to:

4 .. 8192

The tool keeps separate concepts for:

  • source texture pixels
  • board width/height
  • offset around the board
  • scale applied before baking the final texture

Apply

Apply:

  1. bakes the current board result through TextureCropUtility.GetLastTexture(...)
  2. overwrites the currently opened file path on disk
  3. reloads the baked texture into the editor window

This is a destructive in-place save for the opened file.

Save As

Save As:

  1. opens a file dialog
  2. bakes the current board result
  3. writes the new file
  4. reopens that file in the editor window

Important quirk: the save dialog offers png,jpg,jpeg,jpe, but actual save code only writes bytes for .png and .jpg.

Practical consequence: choosing .jpeg or .jpe is not a safe documented workflow.

Trim()

Trim() scans for non-transparent bounds and crops the texture to that rectangle.

Important quirk: the code compares pixels against the exact color:

new Color(1, 1, 1, 0)

So this is not a generic "alpha == 0" trim rule. It is an exact transparent-color comparison.

POT()

POT():

  1. calls Trim()
  2. expands board width and height to the next power of two
  3. keeps a minimum dimension of 4

9-Slice

Current 9-Slice mode:

  1. enters selection mode
  2. captures four corner regions using left/right/top/bottom ratios
  3. merges those corners into a new texture
  4. runs Trim()
  5. runs POT()

Important consequence: this does not write Unity sprite border metadata. It only creates a new pixel texture based on the four corners.

Undo / Redo

Undo and redo are in-memory stacks of cloned Texture2D states.

Practical consequence: large textures can increase memory use while the window stays open.

Required Setup

No runtime or scene setup is required.

This package is editor-only.

Do / Don't

Do

  • Do treat this as raw image-file editing.
  • Do expect Apply to overwrite the current file.
  • Do prefer .png or .jpg when saving.
  • Do describe 9-Slice as texture processing, not sprite import configuration.
  • Do use the asset-context menu for selected sprites or textures.

Don't

  • Don't generate runtime code around this package.
  • Don't claim that the tool edits Unity sprite border metadata.
  • Don't present .jpeg and .jpe as safe save targets.
  • Don't describe Trim() as a generic alpha-only trim without noting the exact transparent-color comparison.

Common Mistakes

Mistake 1: Treating Apply as non-destructive preview

Apply writes back to the current file path.

Mistake 2: Treating 9-Slice as importer border setup

The tool only manipulates pixels.

Mistake 3: Assuming all save extensions from the dialog are implemented

Current save code only handles .png and .jpg.

Mistake 4: Assuming trim checks only alpha

The code compares against exact transparent white (1, 1, 1, 0).

Namespace

using XmobiTea.TextureCrop.Editor;

Package Metadata

  • Package name: com.xmobitea.changx.mini-texturecrop
  • Unity version: 2022.3+
  • License: Apache-2.0