-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Animated item images: fix problem with transparency on some GIFs, add…
… APNG format
- Loading branch information
Showing
9 changed files
with
936 additions
and
528 deletions.
There are no files selected for viewing
26 changes: 13 additions & 13 deletions
26
tools/item-image-frames-to-animated-gif-converter/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
## PNG to GIF converter | ||
|
||
In this folder are PHP files to generate animated item images from item images exported by `itemImageFramesGenerator.html`. | ||
|
||
Put `items.zip` in this folder and run by command line: | ||
``` | ||
php cli_convert.php | ||
``` | ||
|
||
In `index.php` is version for hosting online PNG to GIF converter. | ||
|
||
Official host is: | ||
https://item-images.ots.me/png-to-gif-converter/ | ||
## PNG to APNG/GIF converter | ||
|
||
In this folder are PHP files to generate animated item images from item images exported by `itemImageFramesGenerator.html`. | ||
|
||
Put `items.zip` in this folder and run by command line: | ||
``` | ||
php cli_convert.php APNG items.zip | ||
``` | ||
|
||
In `index.php` is version for hosting online PNG to GIF converter. | ||
|
||
Official host is: | ||
https://item-images.ots.me/png-to-gif-converter/ |
68 changes: 41 additions & 27 deletions
68
tools/item-image-frames-to-animated-gif-converter/cli_convert.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,41 @@ | ||
<?php | ||
|
||
include_once(__DIR__ . '/lib/converterPngToGifAnimation.php'); | ||
|
||
if (!isset($argv[1])) { | ||
echo 'Missing path to items.zip file.'; | ||
echo 'CLI usage example: php cli_convert.php items.zip'; | ||
exit; | ||
} | ||
$zipFilePath = $argv[1]; | ||
|
||
$startTime = time(); | ||
|
||
echo 'Started converter - it may take few minutes to generate GIFs!' . PHP_EOL; | ||
$converter = new ConverterPngToGifAnimation($zipFilePath, true); | ||
$gifImagesZipArchivePath = './generated-gif-zip-archives/items_' . microtime(true) . '.zip'; | ||
try { | ||
$converter->convert($gifImagesZipArchivePath); | ||
} catch (Exception $exception) { | ||
exit('Exception occured during GIF generation: ' . $exception->getMessage()); | ||
} | ||
|
||
echo 'Peak memory allocated: ' . round(memory_get_peak_usage(false) / 1024 / 1024, 2) . ' MB' . PHP_EOL; | ||
echo 'Peak memory usage (real): ' . round(memory_get_peak_usage(true) / 1024 / 1024, 2) . ' MB' . PHP_EOL; | ||
echo 'Execution time: ' . (time() - $startTime) . ' seconds' . PHP_EOL; | ||
|
||
echo 'GIF IMAGES AND ANIMATIONS SAVED TO: ' . $gifImagesZipArchivePath; | ||
<?php | ||
|
||
include_once(__DIR__ . '/lib/converterPngToApngAnimation.php'); | ||
include_once(__DIR__ . '/lib/converterPngToGifAnimation.php'); | ||
|
||
if (!isset($argv[1]) || !in_array($argv[1], ['GIF', 'APNG'])) { | ||
echo 'Missing animation format: GIF or APNG' . PHP_EOL; | ||
echo 'CLI usage example: php cli_convert.php APNG items.zip' . PHP_EOL; | ||
echo 'CLI usage example: php cli_convert.php GIF items.zip' . PHP_EOL; | ||
exit; | ||
} | ||
if (!isset($argv[2])) { | ||
echo 'Missing path to items.zip file.' . PHP_EOL; | ||
echo 'CLI usage example: php cli_convert.php APNG items.zip' . PHP_EOL; | ||
echo 'CLI usage example: php cli_convert.php GIF items.zip' . PHP_EOL; | ||
exit; | ||
} | ||
|
||
$exportFormat = $argv[1]; | ||
$zipFilePath = $argv[2]; | ||
|
||
$startTime = time(); | ||
|
||
echo 'Started converter - it may take few minutes to generate APNGs/GIFs!' . PHP_EOL; | ||
if ($exportFormat == 'APNG') { | ||
$converter = new ConverterPngToApngAnimation($zipFilePath, true); | ||
} else { | ||
$converter = new ConverterPngToGifAnimation($zipFilePath, true); | ||
} | ||
$animatedImagesZipArchivePath = './generated-zip-archives/items_' . microtime(true) . '.zip'; | ||
try { | ||
$converter->convert($animatedImagesZipArchivePath); | ||
} catch (Exception $exception) { | ||
exit('Exception occurred during APNG/GIF generation: ' . $exception->getMessage()); | ||
} | ||
|
||
echo 'Peak memory allocated: ' . round(memory_get_peak_usage(false) / 1024 / 1024, 2) . ' MB' . PHP_EOL; | ||
echo 'Peak memory usage (real): ' . round(memory_get_peak_usage(true) / 1024 / 1024, 2) . ' MB' . PHP_EOL; | ||
echo 'Execution time: ' . (time() - $startTime) . ' seconds' . PHP_EOL; | ||
|
||
echo 'APNG/GIF IMAGES AND ANIMATIONS SAVED TO: ' . $animatedImagesZipArchivePath; |
4 changes: 2 additions & 2 deletions
4
...ter/generated-gif-zip-archives/.gitignore → ...nverter/generated-zip-archives/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
* | ||
!.gitignore | ||
* | ||
!.gitignore | ||
!index.html |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.