Code Monkey home page Code Monkey logo

Comments (4)

britzl avatar britzl commented on July 18, 2024

Hmm, the idea was to show async loading of images from an external source, but it seems like something with the dummyimage.com service has changed.

from gooey.

pabaucom avatar pabaucom commented on July 18, 2024

I see. That's a very useful thing to have now that I think about it. I've been digging into this since the magenta and pink shaded images (salmon, pink, and coral) do work consistently while the others consistently do not work. The urls work fine when opened in a browser, even clicking them directly from the debugger watch.

I see that it is trying to read and write to a file it is opening in appdata on Windows that is not a valid path:

"C:\Users\Paul\AppData\Roaming\Gooey\https://dummyimage.com/40x40/f00/f00.png"

This may have something to do with it or nothing to do with it. I will see if I can get this working as expected since it is very useful and the examples are useful to new devs for baseline best practices.

from gooey.

pabaucom avatar pabaucom commented on July 18, 2024

tl;dr: dummyimage.com is serving webp files for some images and png for others, and Defold can't open the webp files.

I have fixed the issue with the local image cache on Windows, and it now writes the files to disk as expected. I have not tested on linux or mac, but it should work on those too given the nature of how the filename is transformed now.

I can put in a PR for this simple change. The current image_cache.lua module will never be able to write/read these files to disk on Windows. The fix would be relevant if someone tried to used the library as-is with valid external image sources. Let me know if you want to review a PR on it since you may want to go a different direction on the example code given the following:

After getting it to read/write the files to disk as expected, it still considered some images invalid. After doing some digging into the Defold source, it appears that the stb_image library that is used for loading images can't load the webp files.

It wasn't obvious they were webp files until I saved them directly from the browser. They also cannot be imported into the Defold editor when downloaded (giving the same error of unknown format).

The dummyimage.com site is serving compatible pngs for some images.

Not valid, chrome saves this as a webp file: https://dummyimage.com/40x40/ff0/ff0.png
Valid, chrome saves as regular png: https://dummyimage.com/40x40/f0f/f0f.png

I don't know if Defold should support webp files or if stb will ever support it (this may answer both questions).

This issue should probably be closed since it is just an example that is not working. Someone that really needs this to work should hopefully find this issue and proceed with using working external image sources in their project. Let me know if you want a PR on the Windows file path fix in image_cache.lua.

from gooey.

britzl avatar britzl commented on July 18, 2024

I can put in a PR for this simple change

Please do!

dummyimage.com is serving webp files for some images and png for others

That is annoying...

I don't know if Defold should support webp files

Not at runtime using image.load(). But loading WebP images using an extension is ofc possible.

from gooey.

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.