This package has been used in the development of the video game Nevomon. Check out the game here
The names of the Pokémon used in this package are in English.
Here is an example of the results for the front-normal, front-shiny, back-normal, and back-shiny versions of Aerodactyl:
npm install pokemon3d-image-resolver
- Import necessary functions and types :
import { getPokemon, PokemonData } from "pokemon3d-image-resolver";
- Set the parameters :
const myPokemon: PokemonData = {
name: "pikachu",
version: "front-shiny",
};
- Retrieve the image :
const imageData = await getPokemon(myPokemon);
if (imageData) {
console.log("Votre image Pokemon en base64 :", imageData);
} else {
console.log("Image Pokemon introuvable.");
}
import { getAllPokemonVersions } from "pokemon3d-image-resolver";
const pikachuImages = await getAllPokemonVersions("pikachu");
console.log(pikachuImages["front-shiny"]); // Ceci affichera l'image "front-shiny" de Pikachu en base64, ou `null` si elle n'est pas trouvée.
Once you have retrieved the base64 string of your Pokémon image, you can use it directly in an HTML img tag:
<img src="data:image/gif;base64,CHAINE_BASE64_ICI" alt="Pokemon Image" />
Using JavaScript or others, this would be:
const base64Image = await getPokemon({
name: "pikachu",
version: "front-shiny",
});
const imgElement = `<img src="${base64Image}" alt="Image de Pikachu" />`;
- front-normal : Image standard de face
- back-normal : Image standard de dos
- front-shiny : Image shiny de face
- back-shiny : Image shiny de dos
If you encounter any issues or have suggestions, feel free to open a ticket.
nom init -y
npm install express
npm install pokemon3d-image-resolver
const {
getPokemon,
getAllPokemonVersions,
} = require("pokemon3d-image-resolver");
const express = require("express");
const app = express();
const PORT = 3000;
// ==== Appelez getAllPokemonVersions avec le name du pokemon provenant de l'URL ==== \\
app.get("/getAll/:name", async (req, res) => {
const { name } = req.params;
try {
const versions = await getAllPokemonVersions(name);
res.write("<h1>Versions de Pokemon</h1>");
for (const version in versions) {
if (versions[version]) {
res.write(`<h2>${version}</h2>`);
res.write(`<img src="${versions[version]}" alt="${version}" />`);
}
}
res.end();
} catch (error) {
console.error(`Failed to get versions for ${name}:`, error);
res.status(500).send("Internal server error");
}
});
// ==== Appelez getPokemon avec le name du pokemon provenant de l'URL ==== \\
app.get("/:name", async (req, res) => {
const { name } = req.params;
try {
const pokemon = await getPokemon({ name: name, version: "front-normal" }); // Utilisation du paramètre "name" plutôt que "Pikachu" en dur.
res.write("<h1>Pokemon</h1>");
res.write(`<h2>${name}</h2>`);
if (pokemon) {
res.write(`<img src="${pokemon}" alt="${name}" />`);
} else {
res.write(`<p>Image non trouvée pour ${name}.</p>`);
}
res.end();
} catch (error) {
console.error(`Failed to get image for ${name}:`, error);
res.status(500).send("Internal server error");
}
});
ISC