How do I call a .jpg with a scriptcall?

(I can't search jpg in the forum because three letter words are too small to search, so appologies if this has been answered before!)

When I use scriptcalls to call pictures such as
$gameScreen.showPicture(1, $gameVariables.value(x), 0, 0, 0, 100, 100, 255, 0)
they check for .png files only.
I understand why this is, and I understand the technical spec differences between the image types. Alpha channels, filesize and compression differences, etc. So I know why pngs are defaulted to, but I would still like to know how to call a jpg when I want to.

The engine is capable of showing jpgs because I can show one in the background with PIXI functionality, but its overly complicated, such as:

var sprite;



//Create a Pixi Application

let app = new PIXI.Application({

width: 512, // default: 800

height: 512, // default: 600

antialias: true, // default: false

transparent: false, // default: false

resolution: 1 // default: 1

});

app.renderer.backgroundColor = 0x061639;

//Add the canvas that Pixi automatically created for you to the HTML document

document.body.appendChild(app.view);



const url = "C:/RMMZ/ATWO/img/pictures/101.jpg";



// add image URL to main loader, pass callback to load()

PIXI.loader.add(url).load(function() {

sprite = new PIXI.Sprite(PIXI.loader.resources.texture); console.log(PIXI.loader.resources.texture); sprite.width /= 3; sprite.height /= 3; app.stage.addChild(sprite); });
[/QUOTE]
Aside from all that, couldn't you just convert whatever jpg to png... Sounds a lot easier.
If someone has an actual scripting answer please chime in!
The code you've quoted (I recommend using </> code tags next time instead) creates a whole new PIXI application and adds it to the document, just to display one little image. It actually has nothing to do with the core scripts, i.e. the engine. In that case, why not just add an <image> element? 😅

Could try something like this (untested, modelled on ImageManager.loadBitmap):
JavaScript:
const dir = "img";
const filename = "test";
const url = dir + "/" + Utils.encodeURI(filename) + ".jpg";
const sc = SceneManager._scene;
if (!sc._mySprite)
  sc.addChild(sc._mySprite = new Sprite());
sc._mySprite.bitmap = ImageManager.loadBitmapFromUrl(url);
Note that JPEG files may have extension .jpg or .jpeg.

A plugin-based solution would be preferable. Maybe something that checks for JPEG if PNG is not found. I am not offering to write such a plugin.
(I can't search jpg in the forum because three letter words are too small to search, so appologies if this has been answered before!)
I suggest Googling your questions instead of trying to use the forum search. It has greater power and will also pick up other sources (other RPG Maker forums, Reddit, itch, Steam forums, etc.). These forums always turn up as the first hits for me, and of course you can specify in your Google search to restrict it to a Web site.

I did a search on the topic and found a thread saying RPG Maker gets image format data from the file header, not the extension; so you could use JPEG image formats, tack on an extra .png extension, and use the standard image loading functions.

Now that was admittedly for MV, I don't know if they refined anything in MZ. You'd have to test.
The code you've quoted (I recommend using </> code tags next time instead) creates a whole new PIXI application and adds it to the document, just to display one little image. It actually has nothing to do with the core scripts, i.e. the engine. In that case, why not just add an <image> element? 😅

Could try something like this (untested, modelled on ImageManager.loadBitmap):
JavaScript:
const dir = "img";
const filename = "test";
const url = dir + "/" + Utils.encodeURI(filename) + ".jpg";
const sc = SceneManager._scene;
if (!sc._mySprite)
  sc.addChild(sc._mySprite = new Sprite());
sc._mySprite.bitmap = ImageManager.loadBitmapFromUrl(url);
Note that JPEG files may have extension .jpg or .jpeg.

A plugin-based solution would be preferable. Maybe something that checks for JPEG if PNG is not found. I am not offering to write such a plugin.
Thank you very much, your code works and is much simpler to show the jpg.
Do you happen to know how I would set the jpg's position? That is the final piece I am missing to have working control over it.

I suggest Googling your questions instead of trying to use the forum search. It has greater power and will also pick up other sources (other RPG Maker forums, Reddit, itch, Steam forums, etc.). These forums always turn up as the first hits for me, and of course you can specify in your Google search to restrict it to a Web site.

I did a search on the topic and found a thread saying RPG Maker gets image format data from the file header, not the extension; so you could use JPEG image formats, tack on an extra .png extension, and use the standard image loading functions.

Now that was admittedly for MV, I don't know if they refined anything in MZ. You'd have to test.
Thanks for the advice! After experimenting with your suggestion, my results were that MZ works like this using the default show_picture in the event editor MZ:
It will show a png named Test.png (default behavior)
It will not show jpg named Test.jpg
It will not show jpg named Test.png.jpg
but it will show jpg named Test.jpg.png
It will also show a jpg misnamed to only .png extention ie Test.png

This was helpful! Caethyril has shown me how to call a jpg, but in the event that I cannot also figure out how to move the jpg via script I will at least be able to utilize this new knowledge to my advantage as well. Much appreciated ATT_Turan!
Having files with the wrong extension is definitely not my preference but knowing I can do this is both extremely useful and informative.
Do you happen to know how I would set the jpg's position? That is the final piece I am missing to have working control over it.
_mySprite is a Sprite instance, so it has all the associated methods (cf rmmz_core.js). E.g.
  • Move to X = 100, Y = 200:
    JavaScript:
    sc._mySprite.move(100, 200);
  • Set anchor to centre (default is top-left):
    JavaScript:
    sc._mySprite.anchor.set(0.5, 0.5);
👋
_mySprite is a Sprite instance, so it has all the associated methods (cf rmmz_core.js). E.g.
  • Move to X = 100, Y = 200:
    JavaScript:
    sc._mySprite.move(100, 200);
  • Set anchor to centre (default is top-left):
    JavaScript:
    sc._mySprite.anchor.set(0.5, 0.5);
👋
Is there a place I can find documentation on the rmmz_core.js methods available? I'd like to familiarize myself with them and learn more.
Particularly I would like to know if sprites are capable of having id numbers, as calling the script again overrides the first picture instead of drawing a second one, and I haven't yet learned how to erase the picture at all which is crucial information I am missing.
I think thats all...
I can call an image and set its position now, so once I understand how to erase it when done that should be everything I need to use one correctly, at least in a singular instance when only working with only one picture.

Also, something I've learned from this thread educating me about MZ engine's use of headers when working with file extensions, is that the engine can see and play mp3s if the naming convention is structured as Filename.mp3.ogg
I deduced this from it showing jpgs named jpg.png, and it works fine.
Just mentioning this because it may be useful to someone else.

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-call-a-jpg-with-a-scriptcall.160750/