Insert image locally from your PC straight to Workspace

A simple plugin that inserts image from your pc to Roblox Studio and instantly
creates a decal & part with the image on workspace.

When importing a png file, it gets the size of the image and fixes the inserted part to make it look right.

Animation

It also stores the image in the ServerStorage

https://www.roblox.com/library/9375345514/Import-file-as-decal

16 Likes

your plugin seems to be off-sale

Thanks for letting me know, I just configured the plugin to be on sale

Could this ever be open-sourced? that would be nice

I get the error ‘Unable to assign property Position. Vector3 expected, got CFrame’.

Could you upload the source on Github or something?

Just fixed it, try updating the plugin

1 Like

Here’s the code

local toolbar = plugin:CreateToolbar("Insert Decal")-- Make The Plugin ToolBar And Name
 
local Button = toolbar:CreateButton( --Create A Button
    "Insert Decal", --Name of Plugin
    "Insert a file decal to workspace.", --What Is Says When You Hover Over The Plugin
    "http://www.roblox.com/asset/?id=9375337100" --Image of The Plugin rbxassetid://12345678
    )
local studioservice = game.StudioService
local history = game:GetService("ChangeHistoryService")
 
Button.Click:Connect(function() --- Add Whatever You Want Here
    local filee = studioservice:PromptImportFile({"png","jpg"})
    if filee ~= nil then
        history:SetWaypoint("start insert decal")
        local part = Instance.new("Part")
        local decal = Instance.new("Decal")
        print(filee:GetTemporaryId())
        
    
        decal.Texture = filee:GetTemporaryId()
        decal.Parent = part
        part.Name = filee.Name
        part.Size = Vector3.new(5, 5, 2.5)
        part.Position = workspace.CurrentCamera.CFrame.Position
        part.Parent = workspace
        
        local importedecals = game.ServerStorage:FindFirstChild("ImportedDecals")
        if importedecals then
            local clonedpart = part:Clone()
            clonedpart.Parent = importedecals
        else
            local folder = Instance.new("Folder")
            folder.Name = "ImportedDecals"
            folder.Parent = game.ServerStorage
            local clonedpart = part:Clone()
            clonedpart.Parent = game.ServerStorage:FindFirstChild("ImportedDecals")
        end
        history:SetWaypoint("end insert decal")
    end
end)

This plugin already exists: Local Flie Importer Plugin. It also allows you to prewiew the file in a widget and much more functionality.
изображение

6 Likes
local toolbar = plugin:CreateToolbar("Insert Decal")-- Make The Plugin ToolBar And Name

local Button = toolbar:CreateButton( --Create A Button
	"Insert Decal", --Name of Plugin
	"Insert a file decal to workspace.", --What Is Says When You Hover Over The Plugin
	"http://www.roblox.com/asset/?id=9375337100" --Image of The Plugin rbxassetid://12345678
	)
local studioservice = game.StudioService
local history = game:GetService("ChangeHistoryService")



Button.Click:Connect(function() --- Add Whatever You Want Here
	local filee = studioservice:PromptImportFiles({"png","jpg"})
	if  #filee ~= 0 then
		history:SetWaypoint("start insert decal")
		for i,dafile in pairs(filee) do
			local part = Instance.new("Part")
			local decal = Instance.new("Decal")
			print(dafile:GetTemporaryId())
			part.TopSurface = Enum.SurfaceType.SmoothNoOutlines
			decal.Texture = dafile:GetTemporaryId()
			decal.Parent = part
			part.Size = Vector3.new(5, 5, 2.5)
			part.Name = dafile.Name
			
			part.Position = workspace.CurrentCamera.CFrame.Position
			part.Parent = workspace
			part.BottomSurface = Enum.SurfaceType.SmoothNoOutlines
			local importedecals = game.ServerStorage:FindFirstChild("ImportedDecals")
			
			
			
			if string.sub(dafile.Name,string.len(dafile.Name)-2,string.len(dafile.Name)) == "png" then
				local data = dafile:GetBinaryContents()

				local IHDR_start, IHDR_end = data:find("IHDR")
				local DIM_BYTES = 4
				local width_start = IHDR_end
				local height_start = width_start + DIM_BYTES
				local width, height = 0, 0

				for i = 1, DIM_BYTES do
					local byte = string.byte(data:sub(width_start+i, width_start+i)) --turn each character into a number matching the byte that codes for said character
					width += bit32.lshift(byte, 8 * (DIM_BYTES-i)) --lshifting because first bytes are most significant
				end

				for i = 1, DIM_BYTES do
					local byte = string.byte(data:sub(height_start+i, height_start+i))
					height += bit32.lshift(byte, 8 * (DIM_BYTES-i))
				end


				part.Size = Vector3.new(width/100,height/100,1)

			end
			if importedecals then
				local clonedpart = part:Clone()
				clonedpart.Parent = importedecals
			else
				local folder = Instance.new("Folder")
				folder.Name = "ImportedDecals"
				folder.Parent = game.ServerStorage
				local clonedpart = part:Clone()
				clonedpart.Parent = game.ServerStorage:FindFirstChild("ImportedDecals")
			end
		end
		history:SetWaypoint("end insert decal")
	end
end)

updated the plugin

2 Likes

I don’t like widgets so I made this plugin

1 Like

their more flexible and are way more superior then creating your own ui that doesnt even fit in with studio lol

My plugin doesn’t even have UI? also I made this plugin so I can easily insert references like in blender.


Useful plugin mate thanks for sharing it plus the code

Wait hold up-
You can access files from the desktop from studio? Doesn’t this prompt huge security issues? What if somebody uploads something not so good here? Although this is very very cool