Export png images in the game folder by "Script call" of an event.

Hi there!

I would like to know if it is possible to export an image from the "graphics / pictures" folder in png format from the game through an event.

Let me explain ... For example:


The game ends and automatically by means of a "Script call" a png image appears and put in "graphics / pictures" which is copied into the game folder.

(Sorry I'm bad at explaining these things, it's the first time I've done this.)

Is it possible to do that?
yes and no.

It can be done, but it isn't as simple as you assume.
you have to create the picture file and fill it with the picture data, that can't be done with a simple script call but needs a full script.
and only after you installed that full script you can give it the command to create the picture you want.

If I remember correctly, Tsukihime wrote a mapshot script for Ace - that is a script that creates a picture based on the current map data of the game.
You could search for this and learn from it how to write such a script.
yes and no.

It can be done, but it isn't as simple as you assume.
you have to create the picture file and fill it with the picture data, that can't be done with a simple script call but needs a full script.
and only after you installed that full script you can give it the command to create the picture you want.

If I remember correctly, Tsukihime wrote a mapshot script for Ace - that is a script that creates a picture based on the current map data of the game.
You could search for this and learn from it how to write such a script.
Oh! I see!

Thank u!
If you just want to copy a file:
Ruby:
module Export
  def self.picture(filename, destination_directory = '.')
    File.open(File.join('Graphics/Pictures/', filename), 'rb') do |s|
      File.open(File.join(destination_directory, filename), 'wb') do |d|
        IO.copy_stream(s, d)
      end
    end
  end
end
Usage:
Ruby:
Export.picture('b585dbeb.jpg')

If you want to copy a file from within an encrypted archive (*.rgss3a), well, that's a bit more difficult but there are ways without having to 'screenshot' it. Extracting the actual file from the archive means any metadata, etc. won't be lost. The following script should work in both cases but if you don't plan on using an encrypted archive use the one above:
Spoiler: script
Ruby:
module Export

  Marshal = ::Marshal

  module MarshalRGSSAD
    def self.load(src, proc = nil)
      case src
      when String
        proc ? proc.call(src) : src
      when IO
        src.dup
      end
    end
  end

  def self.picture(filename, destination_directory = '.')
    Object.send(:remove_const, :Marshal)
    Object.const_set(:Marshal, MarshalRGSSAD)
    src = load_data(File.join('Graphics/Pictures/', filename))
    File.open(File.join(destination_directory, filename), 'wb') do |dst|
      case src
      when String
        dst.write(src)
      when IO
        IO.copy_stream(src, dst)
      end
    end
  ensure
    Object.send(:remove_const, :Marshal)
    Object.const_set(:Marshal, Marshal)
    src.close if src.is_a?(IO)
  end
end
If you just want to copy a file:
Ruby:
module Export
  def self.picture(filename, destination_directory = '.')
    File.open(File.join('Graphics/Pictures/', filename), 'rb') do |s|
      File.open(File.join(destination_directory, filename), 'wb') do |d|
        IO.copy_stream(s, d)
      end
    end
  end
end
Usage:
Ruby:
Export.picture('b585dbeb.jpg')

If you want to copy a file from within an encrypted archive (*.rgss3a), well, that's a bit more difficult but there are ways without having to 'screenshot' it. Extracting the actual file from the archive means any metadata, etc. won't be lost. The following script should work in both cases but if you don't plan on using an encrypted archive use the one above:
Spoiler: script
Ruby:
module Export

  Marshal = ::Marshal

  module MarshalRGSSAD
    def self.load(src, proc = nil)
      case src
      when String
        proc ? proc.call(src) : source
      when IO
        src.dup
      end
    end
  end

  def self.picture(filename, destination_directory = '.')
    Object.send(:remove_const, :Marshal)
    Object.const_set(:Marshal, MarshalRGSSAD)
    src = load_data(File.join('Graphics/Pictures/', filename))
    File.open(File.join(destination_directory, filename), 'wb') do |dst|
      case src
      when String
        dst.write(src)
      when IO
        IO.copy_stream(src, dst)
      end
    end
  ensure
    Object.send(:remove_const, :Marshal)
    Object.const_set(:Marshal, Marshal)
    src.close if src.is_a?(IO)
  end
end

It works perfectly! Thank u so much, Cremnophobia!! 😀

I really aprecciate it!

Original thread: https://forums.rpgmakerweb.com/threads/export-png-images-in-the-game-folder-by-script-call-of-an-event.133261/