Standalone price-image test
==========================

This is a separate test package. Nothing in the uploaded bot has been changed.
It does not include bot.php, fetch live market prices, send Telegram messages,
change the schedule, or read/write the bot's state or log.

Requirements
------------
PHP 7.4 or newer, with GD, PNG and FreeType support enabled.
The supplied bot already uses PHP 8 syntax; use your existing PHP 8 runtime.
No Composer packages, API keys, network access or Persian shaping library needed.
The Persian labels are in the background image; only Latin digits are drawn.

Browser test (cPanel / hosting)
------------------------------
1. Extract this entire price-image-test folder.
2. Upload it as its own folder under public_html.
3. Open: https://YOUR-DOMAIN/price-image-test/generate_image.php
   The response is the filled 1000 x 1000 PNG, with the current Tehran timestamp.
4. To download instead, open: generate_image.php?download=1

Keep the assets directory and sample-data.json beside generate_image.php.
If the script says to enable GD/FreeType, enable GD in your hosting's PHP
extensions selector or ask your hosting provider to enable it.

Command-line test
-----------------
From inside the extracted folder:

php generate_image.php

This creates market-test.png beside the script, using the current Tehran time.
Choose an output filename and the timestamp from the example message:

php generate_image.php --output=market-test.png --timestamp=2026-10-01T15:00:00+03:30

Choose another bot-shaped JSON data file:

php generate_image.php --data=my-prices.json --output=my-market.png

Use absolute paths if running from a different working directory. Quote paths
containing spaces. The browser test always uses the bundled sample-data.json.

Edit the sample prices
----------------------
Edit sample-data.json; these are SAMPLE values from the conversation, not live
or verified prices. The default values display:

Tether:       256,960 toman
18K gold:    25,617,300 toman
Brent:       100.18 USD
Bitcoin:     83,687.08 USD
Emami coin:  259,975,000 toman

IMPORTANT: Input Iranian values in RIALS, matching fetchMarketData() in bot.php.
The renderer divides them by 10 to display TOMANS. For example, to display
256,960 toman, set tether_rial to 2569600. Do not pass pre-converted toman values.
The background is labeled in tomans; this package does not support rial display.
Brent and Bitcoin inputs are USD and are rendered with two decimal places.
Units are already printed in Persian, so currency words/symbols are not repeated.

Data keys:
  tether_rial
  gold18.current
  brent.current
  bitcoin.current
  coin.current

Set bitcoin to null to display N/A in its field if it is unavailable. Other
missing, zero, negative or non-numeric prices raise an error instead of showing
an incorrect value. Long values automatically use a smaller font to fit.

Later integration
-----------------
generate_image.php also exposes the reusable function:

\PriceImageTest\renderMarketImage(array $data, DateTimeImmutable $timestamp)

It returns PNG bytes. Requiring the script from another PHP file does not run
the standalone test. Integration with the bot is intentionally left for later.

Files
-----
generate_image.php           Standalone test + reusable PNG renderer
sample-data.json             Editable sample prices, in the bot's raw format
assets/market-template.png  Approved template without the three-hour subtitle
assets/DejaVuSans-Bold.ttf   Bundled font for numbers and timestamp
assets/FONT-LICENSE.txt     Font license

Validation performed
--------------------
The sample rial-to-toman conversions and price formatting were checked.
The 1000 x 1000 template and text positions were visually checked using Pillow
with the same font. This is a layout check, not an execution of PHP/GD.
The original uploaded bot.php remains byte-for-byte unchanged.
PHP is not installed in the preparation environment, so the PHP script could
not be executed or linted here. Run the browser or CLI test on your hosting.

Implementation references
-------------------------
https://www.php.net/manual/en/function.imagettfbbox.php
https://www.php.net/manual/en/function.imagettftext.php
https://www.php.net/manual/en/function.imagepng.php
