Photo2Parts - Convert a Photo into Parts

Photo2Parts

Roblox Plugin | Source Code (WIP)

Convert a photo into parts.

:thinking: What does it do?

This tool allows you to turn a photo into parts without having to upload it as a decal in Roblox.

:fire: How does it work?

The plugin asks the user to import a PNG file, reads it using MaximumADHD’s PNG Library, then loops through each RGB value creating a new part.

Each pixel has an alpha value allowing the part to be transparent.

:rocket: Instuctions

Install Custom Tools and press Custom Decals in Roblox Studio.

Open the Custom Decals panel in the plugins tab and press “Create”, then select the target image.

🎉 Demonstration


:warning: Important

This is meant to be used with smaller images and pixel art

Make sure that the photo does not exceed 128x128 pixels and make sure you save your work beforehand just incase anything goes wrong or it crashes.

Also, please do not use this for any reason that may break the Roblox TOS. The sole purpose of this tool is to allow you to turn images into parts and use it in your game.

19 Likes

I have one question: Why? I can’t help but think the only good resource this will be use for is for bypassing or getting around roblox’s moderation wall?

4 Likes

I was going to make a section in the post for that very reason:

:sweat_smile: Why?

I got inspired to make this tool from those photo to block programs in Minecraft where you give it a photo, and it generates the photo using blocks that you can use for pixel art, maps, YouTube videos, etc.

I mostly just wanted to see if I could make it since I thought it was simple and I was messing with stuff like this before, so I decided to go ahead and make it for Roblox. I made a simple script that does this for you first, then I turned it into a GUI, then a plugin.

I thought it was useful for me since I could use it in making maps, and I thought that I should share it here since it’s pretty cool and others can use it too.

It was also made to help me add stuff to my game, but could be used for other stuff such as drawing/building games, terrain, etc.

It’s not finished as I’m planning to make it possible to add height maps, and properties such as the material, size for each part, orientation, etc.

I don’t think this is good for bypassing Roblox’s moderation since it’s insanely laggy for big photos and it doesn’t really work like a decal. However if that was your intention; you could do the same with far less effort and time. Also that is probably not specific to this plugin since you could use almost any other plugin to get results that break the Roblox TOS.

(Come to think of it, I think this would be pretty great for height maps and terrain.)

6 Likes

Why not save the data as a file and then use game:GetService("StudioService"):PromptImportFile():GetBinaryContents()
to import the image data.

Because I didn’t know that existed lol. Does :GetBinaryContents() return the RGBA value or something similar? If so I’d love to use that instead, seems like it would make everything a whole lot simpler. Sorry I couldn’t find a good documentation of it.

It just gives whats in a file as a string. Basically what you see when you open a file in a .txt file. I meant that you should save the data as a file rather than copying it to the clipboard (not the actual image data, you need a module to parse that, but the one that you turned into an array) and then have the player use a button which opens the file prompt to import the file.

How would the binary be converted into an RGBA array though? Decoding image file formats without a library is pretty difficult, and would need to be done for each image file type.

Edit:

My reply was to using StudioService:PromptImportFile():GetBinaryContents(), which is in Roblox’s API so the library has to be in Lua or Luau. There isn’t a library I’m aware of for this in Lua, though if you have one I’m all ears.

You would use the python script to generate the file since it already seems to be able to do that.

Ah I understand. I thought you meant they should use :GetBinaryContents() for on an image, then convert the image in studio to cut out the external code.

They could definitely do it where the python script converts the image into a text file, then studio gets that file through :GetBinaryContents(). I personally think it would be easier to just copy paste the code though.

Oh that makes sense. I’ll definitely change it to use that! Thanks for telling me.

:fire: Update v1.0.1

  • Fixed some mistakes
  • Updated the code to save the array as a .txt file instead of saving it to your clipboard so you can easily import the array

There is a library to parse it and do :GetPixel to get color for each pixel.

1 Like
2 Likes

Oh nice, that’s awesome! The OP should totally use that.

2 Likes

I’ve changed the code to use this library and it works flawlessly now. Thank you so much!!

Working to update the post right now.

1 Like

:fire: Update v1.0.2

  • Completely removed Photo2Array and made it work using MaximumADHD’s Roblox PNG Library
1 Like

:sweat_smile: Update v1.0.3

  • Small changes
  • Added the source code to GitHub (not finished)
  • More updates coming soon!

this is actually really useful for my (very specific) use case. i needed a quick way to import a map of the world into roblox as a paintable canvas and this plugin allows me to do that. i just wish there were more quality of life features, such as:
-being able to set the size (was planned but i dont know if this project is abandoned)
-being able to queue multiple images to be imported, allowing you to define a number of tiles for each column and row to create a larger canvas automatically
i wanted to bump this post in hopes that it could bring your attention to this plugin again, and that there is (although probably very little) demand for updates

I kind of forgot about this and lost my motivation to update it anymore, but now that I have time, I’ll try to update it. Thank you for your support!

Is there any way for this to work mid-game, like in a script, instead of being a plugin? Because that’s kind of what I’m looking for.