Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

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

Discussion in 'Assets and Asset Store' started by yasirkula, Jul 4, 2018.

  1. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,892
    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: https://github.com/yasirkula/UnityTextureOps
    Discord: https://discord.gg/UJJt549AaV
    GitHub Sponsors ☕

    1.jpg

    Enjoy!
     
    Last edited: May 31, 2023
  2. jiraphatK

    jiraphatK

    Joined:
    Sep 29, 2018
    Posts:
    306
    What's the different between this asset and UnityWebRequestTexture and File.WriteAllByte ?
     
  3. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,892
    - 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
     
    Gerard_Slee and jiraphatK like this.
  4. jiraphatK

    jiraphatK

    Joined:
    Sep 29, 2018
    Posts:
    306
    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.
     
  5. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,892
    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.
     
  6. God-at-play

    God-at-play

    Joined:
    Nov 3, 2006
    Posts:
    330
    Does saving from Texture2D to file and loading from file to Texture2D block the main thread at some point?
     
  7. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,892
    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.