Texture Ops - A basic image processing plugin for Unity [Open Source]

Hi there,

Texture Ops helps you save/load textures and perform simple operations on them, like scale and slice. It also contains an example sliding puzzle project to demonstrate the slice operation.

Features

  • Save textures to files or create textures from image files
  • Resize or slice your textures (uses RenderTexture’s for performance)
  • Supports loading image files in correct orientation on Android & iOS (e.g. images that are taken in portrait mode with the camera)
  • Additional utility functions for Android & iOS
  • Includes sliding puzzle demo scene

Available at: GitHub - yasirkula/UnityTextureOps: A basic image processing plugin for Unity
Discord: yasirkula Unity Assets
GitHub Sponsors :coffee:

Enjoy!

3 Likes

What’s the different between this asset and UnityWebRequestTexture and File.WriteAllByte ?

  • Saving: it is possible to save Textures that are not marked as readable (i.e. not Read/Write Enabled)
  • Loading: it is possible to pass a maxSize parameter. Resulting image will be downscaled if it is larger than this size. On Android & iOS, this downscaling operation uses native functions so it is very fast on these platforms. Also, on Android & iOS, you can load all image formats that are supported by the OS, so you aren’t limited with PNG and JPEG files
2 Likes

Nice. I’m really interested in the saving nonReadae Texture to jpg. Does it block main thread ? Unity’s EncodeToJPG is super slow so I’m using a hacky method to avoid using it right now.

Saving non-readable textures is actually slower than saving readable textures because the non-readable Texture will have to be copied to a temporary readable Texture using an intermediate RenderTexture.

Does saving from Texture2D to file and loading from file to Texture2D block the main thread at some point?

Yes, the whole operation runs on the main thread. But the good thing is, on Android & iOS native functions are used so all image formats supported by the OS can be loaded. And the maxSize parameter can be very useful to limit the image dimensions, in case the original image was unnecessarily large.