Git Product home page Git Product logo

Comments (7)

thedoritos avatar thedoritos commented on August 17, 2024

Hi, @mole84

I expect to get path like the demo code on the README.

https://github.com/thedoritos/unimgpicker/blob/master/README.md

Could you provide more information? Such as...

  • The code you wrote to get the path.
  • The error log you got.

Thank you.

from unimgpicker.

mole84 avatar mole84 commented on August 17, 2024

There is no error any more, but if I use your example (without changing something), and I ulpoad something from my C:/ it returns me the following path in Debug.Log:
C:/Users/mole/AppData/LocalLow/kakeragames/unimgpicker/unimgpicker

But i uploaded the file from "C:/" , so the path is wrong.
It´s always the same path, no matter where I upload the file from

How do i get the path with filename?

by the way, the image is shown correctly on the cube.

from unimgpicker.

thedoritos avatar thedoritos commented on August 17, 2024

Thanks for the info.
Now I see what was your question.

Currently, Unimgpicker doesn't have a feature to get the original image path.

This is a security problem on iOS/Android. The path is abstracted on these platform and you can't read the file directly from the path. As a workaround, Unimgpicker copies the image to the app data directory where your app can read/write.

I assume you want the original filename. If you really need it, I would try! But it seems that we have to switch the image picking framework (for iOS), and it'll take a little more than a few days.

Thank you.

from unimgpicker.

mole84 avatar mole84 commented on August 17, 2024

Hi thedoritos,

thank you for reply.
I like to upload the selected file and maybe it is possible to convert and save the meshrenderer into jpg or png? If this is possible theres no need for getting the original filename.

Do you have an idea?

from unimgpicker.

thedoritos avatar thedoritos commented on August 17, 2024

Hi, @mole84

There is a workaround.

  1. Pick an image.
  2. Copy the image file at the path to anywhere you want.
  3. Do anything you like with the new file.

Note that the image Unimgpicker returns is not the original one. It is a copy as I mentioned above. And it may be downscaled according to the size argument you'll pass.

If you pass a large number, you may get a high quality copy but it probably causes an OutOfMemory error.

Thank you.

from unimgpicker.

mole84 avatar mole84 commented on August 17, 2024

Hi thedoritos,

how to copy the image?

  1. Copy the image file at the path to anywhere you want.

from unimgpicker.

mole84 avatar mole84 commented on August 17, 2024

I did it that way and it is working:

`using UnityEngine;
using System.Collections;
using System.IO;
using UnityEngine.UI;

namespace Kakera
{
public class PickerController : MonoBehaviour
{
[SerializeField]
private Unimgpicker imagePicker;

   // [SerializeField]
   // private MeshRenderer imageRenderer;

    void Awake()
    {
        imagePicker.Completed += (string path) =>
        {
            StartCoroutine(LoadImage(path));
        };
    }

    public void OnPressShowPicker()
    {
        imagePicker.Show("Select Image", "unimgpicker", 1024);
    }

    private IEnumerator LoadImage(string path)
    {
        var url = "file://" + path;
        var www = new WWW(url);
        yield return www;

        var texture = www.texture;
        if (texture == null)
        {
            Debug.LogError("Failed to load texture url:" + url);
        }

        //output.material.mainTexture = texture;

			var pngData = texture.EncodeToPNG();
		if (pngData != null ){
			Debug.Log (Application.persistentDataPath);
			File.WriteAllBytes(Application.persistentDataPath + "/" +"testpic" + ".png", pngData);
				}
			else
				Debug.Log("Could not convert " + texture.name + " to png. Skipping saving texture");
		
			
    }
}

}`

from unimgpicker.

Related Issues (20)

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.