This means that you're trying to upload something that isn't a valid PNG image. The reason this got through to cause a Minetest error is because I only do a simple check for 'iVBOR' at the start of the data, which as you can see your invalid data still passes. The un-base64 version of the data you mention includes 'PNEc', not 'PNG' like it ought, so it's possible that the file is somehow corrupted or in a different format (since your OS doesn't understand it either). An interesting thing to note is that your data visually looks similar to what it should be: 'iVBORWOK' vs. 'iVBORw0K'. Probably the only thing for it is to use another image file that you know is valid (i.e. that opens in your image editor), which should be as simple as redownloading/re-exporting the skin in question.
well the actual image i am using works ( i can open that in my image viewer) the issue is with the png created by minetest when the bace64 is decoded into the image. for some reson the outputed file is curopted and i cant open it in my image viewer. i am using luanti 5.11 on a windows 11 if that helps at all.
In that case, are you sure you're converting the image to base64 correctly? If the image itself is valid, then the issue is most likely with how it's converted to base64. You can try using (a different) one of the numerous online converters, which ought to work.
(I'm not really sure what you mean by 'output file', since you should just be getting plain text that you can copy/paste. If you're putting it in a file, that makes sense, since as a rule image editors don't open base64-encoded PNGs.)
For what it's worth, this issue isn't really the fault of libskinupload, since the base64 you paste in isn't touched except for stripping data URL prefixes and a length check. The issue, thus, almost certainly lies somewhere in how you get your data.
ok, can you sugjest a good bace 64 encoder. the file i was refering to is the png file saved in the world folder arfter minetest becodes the bace 64 . that image seems to be corupted. but your probubly right about me just puting in some bad data. i have tried many of the online tools and none of them work. they all give me the same error.
also i dont know wether this maters but when i input the encoded image to the uploder and view the skin in the skin previewer it works fine. same with the reviewing prosses. its only when i try to change to the skin that the game gives me thoses erors.
Converting the skin to base64 works fine, because the texture renders properly in the upload and review formspecs.
The base64 is stored correctly, because the review formspec works just fine.
However, the file that gets saved to disk is not a valid PNG.
So, the issue would appear to lie in either how the base64 in the request is decoded, or how the file is written.
Since I can't seem to reproduce the issue, the problem is probably not with the base64 decoding. One thing that comes to mind is minetest.safe_file_write(path, content), which "Replaces contents of file at path with new contents in a safe (atomic) way." I don't know how relevant it is, but it's recommended for writing binary files. You can see if it makes a difference by replacing the following code around line 316:
local f = io.open(fp, "w+")
if not f:write(minetest.decode_base64(req.data)) then minetest.log("error", "Failed to write skin file.") end
f:flush()
f:close()
with:
if not minetest.safe_file_write(fp, minetest.decode_base64(req.data)) then minetest.log("error", "Failed to write skin file.") end
it fixed the issue with the actual image(the png file is apearing in the libskinupload_skins derectory) , but it still giving me te error and is giving the player a blank texture. also the meta data is not being saved in the meta derector, the derectory isnt even being created at all
So the saved file is now a valid PNG? If so, what's the specific error message you're getting now?
You can also try disabling the libskinupload.optimize_media setting to use the simpler scheme of always referencing the textures by name, and report how that affects things.
The meta directory shouldn't be created: version 6 added basic search functionaliy, which requires metadata for all skins to be stored in a single file (libskinupload_meta.json next to the libskinupload_skins folder).
now to error is "2025-04-02 16:40:49: ERROR[Main]: generateImagePart): Could not load image
"libskinupload_uploaded_skin_0.png" while building texture; Creating a dummy image"
It seems I can reproduce this issue, but not reliably. My guess is that something is going wrong with dynamic media, but I still don't know what. (Even more strange is that I wait 5s after requesting that the skin be dynamically allocated specifically to work around a similar issue.) If you keep trying to upload, accept, and apply the skin, does it eventually work? Also, what game are you using libskinupload with? I'll keep testing and try to fix this in the next update.
I haven't been able to look into this very much yet, but I did notice a possible problem in the code: I do wait 5s, but only to set the player texture. The compatibility code for mcl etc. always runs immediately, which could still trigger the bug I tried to work around by setting the player texture before the client has the skin media.
To fix that oversight, you can try replacing the libskinupload.set_skin function (starting c. line 836) with this:
local function apply_skin(p, tx, id)
p:set_properties({
textures = tx,
})
if mcl then
mcl_player.player_set_skin(p, "libskinupload_uploaded_skin_"..id..".png")
mcl_skins.save(p)
end
if minetest.get_modpath("3d_armor") then
armor.textures[p:get_player_name()].skin = "libskinupload_uploaded_skin_"..id..".png"
end
end
function libskinupload.set_skin(p, id)
local fname = "libskinupload_uploaded_skin_"..id..".png"
local meta = libskinupload.get_skin_meta(fname)
if not meta then
libskinupload.forget_skin(p)
minetest.chat_send_player(p:get_player_name(), "Your skin does not exist anymore.")
return
end
if meta.p and meta.c ~= p:get_player_name() then
--minetest.chat_send_player(p:get_player_name(), "Insufficient permissions.")
return
end
local m = p:get_meta()
local tx = p:get_properties().textures
tx[1] = fname..m:get_string("texmod")
if not libskinupload.enabled[id] then
libskinupload.add_skin_media(id, false, function(name)
-- 5s delay to dodge a potential race condition that happens for unknown reasons.
minetest.after(5, function()
apply_skin(p, tx, id)
end)
end)
else
minetest.after(0, function()
apply_skin(p, tx, id)
end)
end
db:set_string("skin:"..p:get_player_name(), id)
end
What should happen is that nothing should change for 5s, then your skin should update correctly.
this didnt work ether. somthing i did notice somethin that i might not have said is that the error and blank textur apears when i open the skin choose formspec. do you think this could be the problem
What happens if you name a copy of the original PNG 'libskinupload_uploaded_skin_1.png', put it in the skins folder, and then try to choose a skin? (You probably need to add a meta key to libskinuplod_meta.json as well; refer to the bottom of the description for what that should look like.)
it works, i messed up and deleated the prves fix with the invalid png. but after i fixed it it workes, thanks for all your help, the only other problem i found was the mod crashes when i try to reload the world, but all i had to do was change the fragmented_meta seting to true and now it works perfictly. i love this mod and i hope you make more amazing mods like this in the futer.
actualy i cant seem to fix the isue there seems to be somthin wrong with get_skin_meta beeing a nill value, i will keep mesin around with it but i might not beable to fix it.
I don't really reccommend enabling the fragmented_meta setting, mostly because it disables all searching functionality (though that's probably fine for singleplayer).
It seems like you somehow didn't correctly add the entry to the meta file, which could cause a crash if the file is invalid (or maybe if I try to access a key that doesn't exist — I've added fallbacks to the next version). It might crash on set_skin, but my checks there should just make it not work if the meta doesn't exist. What's the error message?
every time i try to use libskin i get a set of ingame errors saying " 2025-04-01 15:07:16: ERROR Main: generatermageParto: Invalid PNG data
2025-04-01 15:07:16: ERROR[Main]: generateImage): Failed to generate "[png: iVBORWOK' 2025-04-01 15:07:16: ERROR[Main]: part of texture "[png:iVBORWOK"
2025-04-01 15:07:16: ERROR[Main]: generateImage): baseimg is NULL (attempted to create texture "[png: iVBORwOK" )
also if i try to open the png in a image vewer i get a simaler eror saying that the image is not a png. can you help me?
This means that you're trying to upload something that isn't a valid PNG image. The reason this got through to cause a Minetest error is because I only do a simple check for 'iVBOR' at the start of the data, which as you can see your invalid data still passes. The un-base64 version of the data you mention includes 'PNEc', not 'PNG' like it ought, so it's possible that the file is somehow corrupted or in a different format (since your OS doesn't understand it either). An interesting thing to note is that your data visually looks similar to what it should be: 'iVBORWOK' vs. 'iVBORw0K'. Probably the only thing for it is to use another image file that you know is valid (i.e. that opens in your image editor), which should be as simple as redownloading/re-exporting the skin in question.
well the actual image i am using works ( i can open that in my image viewer) the issue is with the png created by minetest when the bace64 is decoded into the image. for some reson the outputed file is curopted and i cant open it in my image viewer. i am using luanti 5.11 on a windows 11 if that helps at all.
In that case, are you sure you're converting the image to base64 correctly? If the image itself is valid, then the issue is most likely with how it's converted to base64. You can try using (a different) one of the numerous online converters, which ought to work.
(I'm not really sure what you mean by 'output file', since you should just be getting plain text that you can copy/paste. If you're putting it in a file, that makes sense, since as a rule image editors don't open base64-encoded PNGs.)
For what it's worth, this issue isn't really the fault of libskinupload, since the base64 you paste in isn't touched except for stripping data URL prefixes and a length check. The issue, thus, almost certainly lies somewhere in how you get your data.
ok, can you sugjest a good bace 64 encoder. the file i was refering to is the png file saved in the world folder arfter minetest becodes the bace 64 . that image seems to be corupted. but your probubly right about me just puting in some bad data. i have tried many of the online tools and none of them work. they all give me the same error.
also i dont know wether this maters but when i input the encoded image to the uploder and view the skin in the skin previewer it works fine. same with the reviewing prosses. its only when i try to change to the skin that the game gives me thoses erors.
Ah, I see. So, what we know is that:
Since I can't seem to reproduce the issue, the problem is probably not with the base64 decoding. One thing that comes to mind is
minetest.safe_file_write(path, content)
, which "Replaces contents of file at path with new contents in a safe (atomic) way." I don't know how relevant it is, but it's recommended for writing binary files. You can see if it makes a difference by replacing the following code around line 316:with:
it fixed the issue with the actual image(the png file is apearing in the libskinupload_skins derectory) , but it still giving me te error and is giving the player a blank texture. also the meta data is not being saved in the meta derector, the derectory isnt even being created at all
So the saved file is now a valid PNG? If so, what's the specific error message you're getting now?
You can also try disabling the
libskinupload.optimize_media
setting to use the simpler scheme of always referencing the textures by name, and report how that affects things.The meta directory shouldn't be created: version 6 added basic search functionaliy, which requires metadata for all skins to be stored in a single file (libskinupload_meta.json next to the libskinupload_skins folder).
now to error is "2025-04-02 16:40:49: ERROR[Main]: generateImagePart): Could not load image "libskinupload_uploaded_skin_0.png" while building texture; Creating a dummy image"
It seems I can reproduce this issue, but not reliably. My guess is that something is going wrong with dynamic media, but I still don't know what. (Even more strange is that I wait 5s after requesting that the skin be dynamically allocated specifically to work around a similar issue.) If you keep trying to upload, accept, and apply the skin, does it eventually work? Also, what game are you using libskinupload with? I'll keep testing and try to fix this in the next update.
i am using libskin in mineclonia
l tried an if i repetadly try it still dose not work. l even tried waiting a couple seconds and the trying to aply the skin and it still fails.
I haven't been able to look into this very much yet, but I did notice a possible problem in the code: I do wait 5s, but only to set the player texture. The compatibility code for mcl etc. always runs immediately, which could still trigger the bug I tried to work around by setting the player texture before the client has the skin media.
To fix that oversight, you can try replacing the
libskinupload.set_skin
function (starting c. line 836) with this:What should happen is that nothing should change for 5s, then your skin should update correctly.
this didnt work ether. somthing i did notice somethin that i might not have said is that the error and blank textur apears when i open the skin choose formspec. do you think this could be the problem
i tryed the mod in minetest game and it has the same problem.
What happens if you name a copy of the original PNG 'libskinupload_uploaded_skin_1.png', put it in the skins folder, and then try to choose a skin? (You probably need to add a meta key to libskinuplod_meta.json as well; refer to the bottom of the description for what that should look like.)
it works, i messed up and deleated the prves fix with the invalid png. but after i fixed it it workes, thanks for all your help, the only other problem i found was the mod crashes when i try to reload the world, but all i had to do was change the fragmented_meta seting to true and now it works perfictly. i love this mod and i hope you make more amazing mods like this in the futer.
actualy i cant seem to fix the isue there seems to be somthin wrong with get_skin_meta beeing a nill value, i will keep mesin around with it but i might not beable to fix it.
I don't really reccommend enabling the fragmented_meta setting, mostly because it disables all searching functionality (though that's probably fine for singleplayer).
It seems like you somehow didn't correctly add the entry to the meta file, which could cause a crash if the file is invalid (or maybe if I try to access a key that doesn't exist — I've added fallbacks to the next version). It might crash on set_skin, but my checks there should just make it not work if the meta doesn't exist. What's the error message?