OguRetsu
littleheroine
littleheroine

patreon


rpgmakermv does not require a key to export images plugin source code

/**

javascript

this is source code to export all pics in cache ,if you want to export all you can add extern code below

you can use it as plugins

result is base64 data ,you must use python code to convert final result

*/

//js code start---------------------------------------------------------------------------------------------------------------------------

var gl_bigmaps={};

var prefix = "d:/data/rs"

Decrypter.decryptImg = function(url, bitmap) {

    url = this.extToEncryptExt(url);

    var requestFile = new XMLHttpRequest();

    requestFile.open("GET", url);

    requestFile.responseType = "arraybuffer";

    requestFile.send();

    requestFile.onload = function () {

        if(this.status < Decrypter._xhrOk) {

   

   let fs = require('fs');

   let argg = url.split("/");

   let path = prefix+"/"

   for(let i=0;argg.length > 1 && i<argg.length-1;++i){

    path +=argg[i]+"/";

   }

   if(!fs.existsSync(path)){

    fs.mkdirSync(path,{ recursive: true });

   }

            var arrayBuffer = Decrypter.decryptArrayBuffer(requestFile.response);

            bitmap._image.src = Decrypter.createBlobUrl(arrayBuffer);

            bitmapimage.addEventListener('load', bitmap.loadListener = Bitmap.prototype._onLoad.bind(bitmap));

   gl_bigmaps[url]=bitmap;

            bitmapimage.addEventListener('error', bitmap.errorListener = bitmaploader || Bitmap.prototype.onError.bind(bitmap));

        }

    };

    requestFile.onerror = function () {

        if (bitmap._loader) {

            bitmap._loader();

        } else {

            bitmap._onError();

        }

    };

};

function saveAllPics(){

 let fs = require('fs');

 for(k in gl_bigmaps){

  let bitmap = gl_bigmaps[k];

  const dataUrl = bitmap._canvas.toDataURL('image/png');

        const base64Data = dataUrl.replace(/^data:image\/png;base64,/, "");

  fs.writeFileSync(prefix+"/"+k+".base",base64Data);

 }

}

//js end -----------------------------------------------------------------------

'''

the code below is to convert base 64 result to normal png pics

'''

#python start----------------------------------------------------

import os

import base64

import urllib.parse

def decode_base64_file(input_path, output_path):

    with open(input_path, 'r') as base64_file:

        base64_data = base64_file.read()

    png_data = base64.b64decode(base64_data)

    with open(output_path, 'wb') as png_file:

        png_file.write(png_data)

def process_directory(directory):

    for root, _, files in os.walk(directory):

        for file in files:

            if file.endswith('.base'):

                base64_path = os.path.join(root, file)

                decoded_filename = urllib.parse.unquote(os.path.splitext(file)[0])

                png_path = os.path.join(root, decoded_filename + '.png')

                try:

                    decode_base64_file(base64_path, png_path)

                    os.remove(base64_path)

                    print(f"Decoded and removed: {base64_path} -> {png_path}")

                except Exception as e:

                    print(f"Error processing {base64_path}: {e}")

if __name__ == "__main__":

    current_directory = os.getcwd()

    process_directory(current_directory)


More Creators