MV How do I set image width and height size?

(Sorry I'm very new at javascript and yes I haven't read all the RPG Maker MV core plugins. Also my English are not very good. Sorry if maybe I have violate any forum rules, This is my first time going in this forum.)
I want to show an image but the problem is I don't know how to set their size to fit the screen. I tried writing these:
createLayout = function() {
var ayy = ImageManager.ambil_gambar("Layout");
this._layout = new Sprite(ayy);
this._layout.width = Graphics.boxWidth;
this._layout.height = Graphics.boxHeight;
this._field.addChild(this._layout);
};
But after I tested it, the image size still doesn't change. Can anyone help me what should I write to make it work?
So I had thought I'd seen a scaleSprite function somewhere, but it turns out it's in MZ rather than MV. Basically you need to adjust the scale properties of the sprite. The same code works in MV - I tried this out in Window_Help and it worked, so you can adapt it in your own function:

Code:
Window_Help.prototype.createLayout = function() {
    var picture = ImageManager.loadSystem("balloon");
    this._layout = new Sprite(picture);
    var ratioX = Graphics.width / this._layout.bitmap.width;
    var ratioY = Graphics.height / this._layout.bitmap.height;
    var scale = Math.max(ratioX, ratioY, 1.0);
    this._layout.scale.x = scale;
    this._layout.scale.y = scale;
    this.addChild(this._layout);
};
you didn't say what kind of picture you need to scale, but you should consider doing the scaling with a professional image program outside the game.

The problem here is that almost all zooming will result in quality loss - in a lot of cases a very high quality loss when using the build-in scale functions of the browsers, because those are optimised for data and processing speed, not for quality.
Image programs have much better formulae for resizing - the professional ones even allow you to select which formula is used because different pictures have different quality loss depending on function.

So if you know in advance that a picture has to be resized in a certain way, it is usually better to do the resizing in an imge program.
Sorry for the late reply. Been busy with another coding problem that I might post in this forum.
So I had thought I'd seen a scaleSprite function somewhere, but it turns out it's in MZ rather than MV. Basically you need to adjust the scale properties of the sprite. The same code works in MV - I tried this out in Window_Help and it worked, so you can adapt it in your own function:

Code:
Window_Help.prototype.createLayout = function() {
    var picture = ImageManager.loadSystem("balloon");
    this._layout = new Sprite(picture);
    var ratioX = Graphics.width / this._layout.bitmap.width;
    var ratioY = Graphics.height / this._layout.bitmap.height;
    var scale = Math.max(ratioX, ratioY, 1.0);
    this._layout.scale.x = scale;
    this._layout.scale.y = scale;
    this.addChild(this._layout);
};
Thanks for the help, but unfortunately mine doesn't work after I tested the code you suggest. The whole screen just turns purple. It's okay tho, I ditch the plan to resize the image and just doing it on image editing software.

you didn't say what kind of picture you need to scale, but you should consider doing the scaling with a professional image program outside the game.

The problem here is that almost all zooming will result in quality loss - in a lot of cases a very high quality loss when using the build-in scale functions of the browsers, because those are optimised for data and processing speed, not for quality.
Image programs have much better formulae for resizing - the professional ones even allow you to select which formula is used because different pictures have different quality loss depending on function.

So if you know in advance that a picture has to be resized in a certain way, it is usually better to do the resizing in an imge program.
I just thought maybe it would save a lot of time and data size if I just resize picture through code rather than creating multiple image of the same picture but with different size. But since there's no solution yet, I opt to do like what you have suggested.
I just thought maybe it would save a lot of time and data size if I just resize picture through code rather than creating multiple image of the same picture but with different size.
yes and no

it does save data size, and because of that techniques like it (or color change mathematics) were used often in games two decades ago, when the cost of memory (both RAM and HDD space) was much higher. But at that time the picture quality was also a lot less in general.

Today there is so much HDD-space available that it doesn't really matter anymore, and people are much more concerned with picture quality.

It might still save you some developer time, but only a bit compared to how much work game development is (remember to use an image program's batch or macro functions where possible).


Resizing only works good in 3D due to the completely different way pictures are created there - with a 2D basic that is often a bad idea.

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-set-image-width-and-height-size.145236/