From dc9a6dc725bff8e7b073b9cc5bdcb16b7f37705c Mon Sep 17 00:00:00 2001 From: CreatorADOfficial Date: Tue, 21 Oct 2025 18:52:00 +0000 Subject: [PATCH] Automated Extension submission for issue #1884 --- extensions/community/UploadImages.json | 162 +++++++++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 extensions/community/UploadImages.json diff --git a/extensions/community/UploadImages.json b/extensions/community/UploadImages.json new file mode 100644 index 000000000..86fad3f57 --- /dev/null +++ b/extensions/community/UploadImages.json @@ -0,0 +1,162 @@ +{ + "author": "", + "category": "Advanced", + "extensionNamespace": "", + "fullName": "Upload Images", + "gdevelopVersion": "", + "helpPath": "", + "iconUrl": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0ibWRpLWZpbGUtaW1hZ2UiIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTMsOUgxOC41TDEzLDMuNVY5TTYsMkgxNEwyMCw4VjIwQTIsMiAwIDAsMSAxOCwyMkg2QzQuODksMjIgNCwyMS4xIDQsMjBWNEM0LDIuODkgNC44OSwyIDYsMk02LDIwSDE1TDE4LDIwVjEyTDE0LDE2TDEyLDE0TDYsMjBNOCw5QTIsMiAwIDAsMCA2LDExQTIsMiAwIDAsMCA4LDEzQTIsMiAwIDAsMCAxMCwxMUEyLDIgMCAwLDAgOCw5WiIgLz48L3N2Zz4=", + "name": "UploadImages", + "previewIconUrl": "https://asset-resources.gdevelop.io/public-resources/Icons/c6efdd283b225c8becfdf656fbeb51d03463b368c60c0db6933fee69b953dfb8_file-image.svg", + "shortDescription": "- Uploads Image into object.\n- Downloads the frames of the object.", + "version": "1.0.0", + "description": "Handle's Image Files.", + "tags": [ + "Files" + ], + "authorIds": [ + "mu1pKMrGmTTX98LMxHYJ62GzFyJ2" + ], + "dependencies": [], + "globalVariables": [], + "sceneVariables": [], + "eventsFunctions": [ + { + "description": "Imports an image in a Object.", + "fullName": "Import Image", + "functionType": "Action", + "name": "SpriteAndTiledSprite", + "sentence": "Import an image in: _PARAM1_ -- Sprite/TiledSprite", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "(function(runtimeScene, eventsFunctionContext) {", + " const input = document.createElement(\"input\");", + " input.type = \"file\";", + " input.accept = \"image/*\";", + "", + " input.onchange = e => {", + " const file = e.target.files[0];", + " if (!file) return;", + "", + " const reader = new FileReader();", + " reader.onload = function(event) {", + " const dataUrl = event.target.result;", + " const objects = eventsFunctionContext.getObjects(\"object\");", + "", + " for (const obj of objects) {", + " const originalWidth = obj.getWidth();", + " const originalHeight = obj.getHeight();", + "", + " const img = new Image();", + " img.onload = () => {", + " const baseTexture = PIXI.BaseTexture.from(img);", + " const texture = new PIXI.Texture(baseTexture);", + "", + " // Use GDevelop's setTexture for safety", + " try {", + " obj.setTexture(dataUrl);", + " } catch (err) {", + " // fallback if setTexture fails", + " const rendererObj = obj.getRendererObject();", + " if (rendererObj && rendererObj.texture) {", + " rendererObj.texture = texture;", + " }", + " }", + "", + " // Maintain original size", + " obj.setWidth(originalWidth);", + " obj.setHeight(originalHeight);", + "", + " // Extra for TiledSprite: reset tiling position", + " const rendererObj = obj.getRendererObject();", + " if (rendererObj && rendererObj.tilePosition) {", + " rendererObj.tilePosition.x = 0;", + " rendererObj.tilePosition.y = 0;", + " }", + " };", + " img.src = dataUrl;", + " }", + " };", + "", + " reader.readAsDataURL(file);", + " };", + "", + " input.click();", + " })(runtimeScene, eventsFunctionContext);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Object To Change", + "name": "object", + "type": "objectList" + } + ], + "objectGroups": [] + }, + { + "description": "Downloads The Current Frame.", + "fullName": "Download Current Frame", + "functionType": "Action", + "name": "DownloadObjectFrame", + "sentence": "Download The Current Frame Of: _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const objects = eventsFunctionContext.getObjects(\"object\"); ", + "if (!objects || objects.length === 0) return;", + "", + "const obj = objects[0]; ", + "const rendererObj = obj.getRendererObject();", + "if (!rendererObj) return;", + "", + "const totalFrames = obj.getAnimationFrameCount();", + "const originalFrame = obj.getAnimationFrame();", + "", + "const tempCanvas = document.createElement(\"canvas\");", + "const ctx = tempCanvas.getContext(\"2d\");", + "tempCanvas.width = obj.getWidth();", + "tempCanvas.height = obj.getHeight();", + "", + "for (let i = 0; i < totalFrames; i++) {", + " obj.setAnimationFrame(i);", + "", + " ctx.clearRect(0, 0, tempCanvas.width, tempCanvas.height);", + " ctx.drawImage(rendererObj.texture.baseTexture.resource.source, 0, 0, tempCanvas.width, tempCanvas.height);", + "", + " const link = document.createElement(\"a\");", + " link.href = tempCanvas.toDataURL(\"image/png\");", + " link.download = `frame_${i}.png`;", + " document.body.appendChild(link);", + " link.click();", + " link.remove();", + " }", + "", + " ", + " obj.setAnimationFrame(originalFrame);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Objects", + "name": "object", + "type": "objectList" + } + ], + "objectGroups": [] + } + ], + "eventsBasedBehaviors": [], + "eventsBasedObjects": [] +} \ No newline at end of file