[Mod] Image Loader [0.1.0] [imageloader]

bobomb
Member
 
Posts: 101
Joined: Sat May 23, 2015 20:28
GitHub: bobombolo
IRC: bobomb

Re: [Mod] Image Loader [0.1.0] [imageloader]

by bobomb » Sun Jul 26, 2015 16:48

we need a pure lua image handling library to make the opening of different image formats flawless for this and other mods. I need it for realterrain mod: https://forum.minetest.net/viewtopic.php?f=9&t=12666
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: [Mod] Image Loader [0.1.0] [imageloader]

by kaeza » Sat Aug 01, 2015 22:57

Update!

By popular demand (??), added PNG file support. One note though: please ensure PNG images are well-formed (i.e. not corrupted). Otherwise the PNG loader may get stuck in an endless loop or simply barf.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

Diamond knight
Member
 
Posts: 262
Joined: Sun Apr 19, 2015 19:50
In-game: Diamondknight or diamond_knight

Re: [Mod] Image Loader [0.1.0] [imageloader]

by Diamond knight » Sun Aug 02, 2015 01:33

cluck yea!!!!

i am soooo downloading this mod!!
I can never get enough MESE!!!!!!!!!

my subgame: https://forum.minetest.net/viewtopic.php?f=50&t=11901
 

User avatar
zak1975
Member
 
Posts: 18
Joined: Sat Apr 25, 2015 17:59
GitHub: zak1975
IRC: zak1975
In-game: zak1975

Re: [Mod] Image Loader [0.1.0] [imageloader]

by zak1975 » Sun Aug 30, 2015 19:50

Just tested this mod in 0.4.13 and in 0.4.12. with loading a large png file. I can load the demo-png-file properly but my own png files do not work.
Ingame I get this message: Failed to load image: imageloader: unknown file type

In debug.txt:
21:44:44: WARNING: Assignment to undeclared global "ch" inside a function at ...netest-0.4.12/bin/../mods/imageloader/lib/pngLua/png.lua:251.
21:44:50: WARNING: Assignment to undeclared global "imStr" inside a function at ...netest-0.4.12/bin/../mods/imageloader/lib/pngLua/png.lua:266.
21:44:50: WARNING: Assignment to undeclared global "bpp" inside a function at ...netest-0.4.12/bin/../mods/imageloader/lib/pngLua/png.lua:136.
21:44:50: WARNING: Assignment to undeclared global "bpl" inside a function at ...netest-0.4.12/bin/../mods/imageloader/lib/pngLua/png.lua:137.

Edit:
Maybe the map isn't explored wide enough to insert a large image? What is the maximum resolution this mod can import?
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: [Mod] Image Loader [0.1.0] [imageloader]

by kaeza » Tue Sep 01, 2015 07:25

Thank you for the report about the undeclared globals. They can be safely ignored, but I will fix them so it does not generate those spurious warnings.

About max resolution, the short answer is "about 2000x2000".

The long answer: the max resolution is limited to either 2^32-1 columns by 2^32-1 lines (per the PNG spec), or the memory available to the Minetest executable, whichever is smaller. You are also limited by map size (to place the image in the world). In theory, you should be able to load 64000x64000 image and place it in the world. In practice, you should use a conservative limit (e.g. 2000x2000).

Finally, can you post an archive of some PNGs you find are failing? (if possible, keep them small) That error message is unrelated to map being loaded or not; it could be an unsupported compression method or indeed too big an image.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

Re: [Mod] Image Loader [0.1.0] [imageloader]

by Hybrid Dog » Tue Sep 01, 2015 08:45

What happens if l try to import an animated png file?
 

User avatar
benrob0329
Member
 
Posts: 1192
Joined: Thu Aug 06, 2015 22:39
GitHub: Benrob0329
In-game: benrob03

Re: [Mod] Image Loader [0.1.0] [imageloader]

by benrob0329 » Tue Sep 01, 2015 13:44

PNGs can't be animated, at least not in the official specks.
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

Re: [Mod] Image Loader [0.1.0] [imageloader]

by Hybrid Dog » Tue Sep 01, 2015 16:32

benrob0329 wrote:PNGs can't be animated, at least not in the official specks.

https://en.wikipedia.org/wiki/APNG
lt has a wikipedia article, so l guess it's official.
 

User avatar
benrob0329
Member
 
Posts: 1192
Joined: Thu Aug 06, 2015 22:39
GitHub: Benrob0329
In-game: benrob03

Re: [Mod] Image Loader [0.1.0] [imageloader]

by benrob0329 » Tue Sep 01, 2015 16:59

That's a PNG add on, the official (as in the PNG website) specks say that PNG does not support it.
 

User avatar
zak1975
Member
 
Posts: 18
Joined: Sat Apr 25, 2015 17:59
GitHub: zak1975
IRC: zak1975
In-game: zak1975

Re: [Mod] Image Loader [0.1.0] [imageloader]

by zak1975 » Wed Sep 02, 2015 18:19

@kaeza:
Now I found out that the images I tried to load were too big.
Trying a png with 100x100 px was able to load. Next try with a 250x250 px image ran about 1 hour and then failed.

Another thing is, the top of the image seems always to face south. I'm trying to import streetmaps into minetest and they have north at top of the image. After import north is south and the sun rises in the west ;)
This is not a big problem because I could rotate the images before loading.

My main Problem is that this mod can not import images above a certain resolution. Any idea?
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

Re: [Mod] Image Loader [0.1.0] [imageloader]

by Hybrid Dog » Wed Sep 02, 2015 20:55

zak1975 wrote:My main Problem is that this mod can not import images above a certain resolution. Any idea?

You could use mogrify to cut them.
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: [Mod] Image Loader [0.1.0] [imageloader]

by kaeza » Thu Sep 03, 2015 23:47

zak1975 wrote:@kaeza:
Now I found out that the images I tried to load were too big.
Trying a png with 100x100 px was able to load. Next try with a 250x250 px image ran about 1 hour and then failed.

[...]

My main Problem is that this mod can not import images above a certain resolution. Any idea?


That is weird. I tested this locally, and a test image (640x640, shown in a spoiler below) loaded fine taking about a minute. Granted, the image was scaled down; the original (1500x1000) crashed minetest itself, probably due to out of memory conditions (I'll concede the loading algorithm is not very efficient, either CPU- or memory-wise).

Again, can you upload an image known to fail? Also, what are your system specs (mainly available memory)? For reference, I have a 3GHz dual core Intel E5700, with 4G of RAM.

Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

User avatar
zak1975
Member
 
Posts: 18
Joined: Sat Apr 25, 2015 17:59
GitHub: zak1975
IRC: zak1975
In-game: zak1975

Re: [Mod] Image Loader [0.1.0] [imageloader]

by zak1975 » Fri Sep 04, 2015 14:12

kaeza wrote:That is weird. I tested this locally, and a test image (640x640, shown in a spoiler below) loaded fine taking about a minute. Granted, the image was scaled down; the original (1500x1000) crashed minetest itself, probably due to out of memory conditions (I'll concede the loading algorithm is not very efficient, either CPU- or memory-wise).

Again, can you upload an image known to fail? Also, what are your system specs (mainly available memory)? For reference, I have a 3GHz dual core Intel E5700, with 4G of RAM.


This png file doesn't load: http://we.tl/2yZkTHJwKg
While testing, I converted my png files to bitmap and with bmp I could load files up to 2000x2000.

250.png is a 250x250 px image that I have cut out of my large map. It was created with Maperitive (a tool for generating images from openstreetmap data). With gimp I extracted this piece and saved it over export menu to a new png. While doing this I recognized that there are several options in gimp for exporting to png, but I used the default settings.

When I loaded the bmp files, your mod worked very fast and I just had to wait a few seconds, even with high resolutions. My system is a notebook with 8GB Ram and i5-3230m cpu. OS ist Kubuntu 14.04. Minetest and ImageLoader are latest git versions.
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: [Mod] Image Loader [0.1.0] [imageloader]

by kaeza » Mon Sep 07, 2015 05:56

I first tested your image, and it locked up. I killed the process after about a minute or so, but an image this size should not take that long given that a much larger image takes about 5 seconds.

Something I noticed is that your image (which is 32bpp (*)), when converted to 8bpp, loads in about a second here. So I'm guessing there's something wrong in pngLua, but haven't had time to track the bug down.

So I suggest converting your images to 8bpp that as a workaround in the meantime.

(*) The image I posted is also 32bpp and it loads fine, so this puzzles me.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

Re: [Mod] Image Loader [0.1.0] [imageloader]

by Hybrid Dog » Mon Sep 07, 2015 09:05

Is it possible to use the loadlib function to use some given library for importing images?
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: [Mod] Image Loader [0.1.0] [imageloader]

by kaeza » Tue Sep 08, 2015 00:25

Hybrid Dog wrote:Is it possible to use the loadlib function to use some given library for importing images?

It is, but see the IRC mod for problems with this.

Long story short, I want the mod to be usable without having to hack around with native libs.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

Re: [Mod] Image Loader [0.1.0] [imageloader]

by Hybrid Dog » Tue Sep 08, 2015 10:05

kaeza wrote:
Hybrid Dog wrote:Is it possible to use the loadlib function to use some given library for importing images?

It is, but see the IRC mod for problems with this.

Long story short, I want the mod to be usable without having to hack around with native libs.

thanks, and does the mod also work for windows? Somewhere l read that on windows \ is used for paths instead of /
https://github.com/kaeza/minetest-image ... lua#L4-L10
https://github.com/kaeza/minetest-image ... png.lua#L4
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: [Mod] Image Loader [0.1.0] [imageloader]

by kaeza » Tue Sep 08, 2015 14:03

Yes, it works on Windows.

And I don't know why are you asking about the slashes, given that 100% of the mods out there use forward slashes and none of them fail on Windows.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

Sokomine
Member
 
Posts: 2980
Joined: Sun Sep 09, 2012 17:31

Re: [Mod] Image Loader [0.1.0] [imageloader]

by Sokomine » Tue Sep 08, 2015 14:29

kaeza wrote:And I don't know why are you asking about the slashes, given that 100% of the mods out there use forward slashes and none of them fail on Windows.

I thought so as well. Until I encountered the problem that minetest.get_worldpath returns a path using backslashes instead of slashes.
A list of my mods can be found here.
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: [Mod] Image Loader [0.1.0] [imageloader]

by kaeza » Tue Sep 08, 2015 15:17

Yes, but mod do things like
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
dofile(minetest.get_modpath("foo").."/bar.lua")

which translates to C:\whatever\minetest\mods\foo/bar.lua

It still doesn't fail.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

Sokomine
Member
 
Posts: 2980
Joined: Sun Sep 09, 2012 17:31

Re: [Mod] Image Loader [0.1.0] [imageloader]

by Sokomine » Tue Sep 08, 2015 15:26

kaeza wrote:which translates to C:\whatever\minetest\mods\foo/bar.lua

...unless the mod deliberately searches for the slashes in order to act as a file browser. Lua just doesn't seem to be very consistent here. If all you're doing is loading some files with dofile, it's not relevant. But the pahts are just not the way they might be expected.
A list of my mods can be found here.
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: [Mod] Image Loader [0.1.0] [imageloader]

by kaeza » Tue Sep 08, 2015 17:38

If you need to manipulate paths, feel free to implement all the functionality required. In this particular case, the question was whether or not this mod would work under Windows, citing an unfounded fear that it might cause problems due to different directory separators. The C lib under windows (MSVCRT) supports using forward slashes as separators, so why should I concern myself with these details? It makes the code portable to all platforms currently supported by minetest. If it ever causes problems, it will be fixed. Until then, no more discussion on this subject from my part.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

bobomb
Member
 
Posts: 101
Joined: Sat May 23, 2015 20:28
GitHub: bobombolo
IRC: bobomb

Re: [Mod] Image Loader [0.1.0] [imageloader]

by bobomb » Mon Nov 30, 2015 04:38

inspired by this mod I wanted to show some work I did today on the realterrain mod, now allowing you to map a greyscale image as a heightmap and the same image in color as a color overlay. this map is 640x480
Image
while the intent is to overlay satellite imagery onto elevation maps, it is fun for this kind of thing.
of course realterrain requires a lot of external libraries... and introduces 216 new textures to accomplish this.

viewtopic.php?f=9&t=12666
 

User avatar
lordfingle
Member
 
Posts: 65
Joined: Sat Apr 04, 2015 09:21
GitHub: eidy
IRC: lordfingle
In-game: lordfingle

Re: [Mod] Image Loader [0.1.0] [imageloader]

by lordfingle » Mon Mar 20, 2017 02:13

Image
Image
Image

If you'd like to create load images vertically instead of flat on the ground, change this routine in imageloader.lua:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
function imageloader.to_schematic(bmp, pal)
   local data = { }
   local datai = 1
   for y = bmp.h, 1, -1 do
      for x = 1, bmp.w do
         local c = bmp.pixels[y][bmp.w + 1 - x]
         local i = palette.bestfit_color(pal, c)
         if (i == 1) and ((c.r ~= 255) or (c.g ~= 0) or (c.r ~= 255)) then
            print("WARNING: wrong color taken as transparency:"
               ..(("at (%d,%d): [R=%d,G=%d,B=%d]"):format(x, y, c.r, c.g, c.b))
            )
         end
         local node = pal[i].node
         data[datai] = { name=node }
         datai = datai + 1
      end
   end
   return {
      size = { x=bmp.w, y=bmp.h, z=1 },
      data = data,
   }
end
Attachments
trump.png
trump.png (147.39 KiB) Viewed 3256 times
bottle.png
bottle.png (31.75 KiB) Viewed 3255 times
theeye.png
theeye.png (116.01 KiB) Viewed 3255 times
----------------------------------------------------------------------------------------------
Team Lead on "eidy- Love learning"
I like reading, walks on the beach and building edutech experiences in lua (Find out more in this post)
"Coming together is a beginning; keeping together is progress; working together is success." - Henry Ford
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: [Mod] Image Loader [0.1.0] [imageloader]

by azekill_DIABLO » Mon Mar 20, 2017 16:39

great! but we need a better color render :/
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

Previous

Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 5 guests

cron