ZX-Image

This is the place for general discussion and updates about the ZXDB Database. This forum is not specific to Spectrum Computing.

Moderator: druellan

Post Reply
User avatar
moroz1999
Manic Miner
Posts: 329
Joined: Fri Mar 30, 2018 9:22 pm

ZX-Image

Post by moroz1999 »

I will post updates in this topic regarding ZX-Image php library.

https://github.com/moroz1999/zx-image - project page.
User avatar
moroz1999
Manic Miner
Posts: 329
Joined: Fri Mar 30, 2018 9:22 pm

Re: ZX-Image

Post by moroz1999 »

Today update:
1. Fixed a lot of issues which appeared during my switch to psalm static analysis. Some of formats were not working at all
2. I've added example for each format supported by library, so currently they are all working (at least with my test data)
3. Added support for SSX-Raw
4. Fixed issue with mime-type passing for SSX.

Now will look onto any way to run it on an older PHP versions, because I'm ultimately aiming to switch to PHP8 with its features.
User avatar
moroz1999
Manic Miner
Posts: 329
Joined: Fri Mar 30, 2018 9:22 pm

Re: ZX-Image

Post by moroz1999 »

I've managed to transpile the latest version of library into PHP7.0-compatible code using Rector.
This is feature/PHP7.0 branch in Github, I've also made a separate tag 5.2.0.1 for this release.

So if you need version for 7.0, then please run the following composer command in root of your project.
composer require "moroz1999/zx-image:5.2.0.1"
User avatar
moroz1999
Manic Miner
Posts: 329
Joined: Fri Mar 30, 2018 9:22 pm

Re: ZX-Image

Post by moroz1999 »

Next formats to support: GRF from ZX Evo, textmode from ZX81
User avatar
pavero
Dynamite Dan
Posts: 1599
Joined: Sat Dec 09, 2017 11:49 pm
Location: The Czech Republic
Contact:

Re: ZX-Image

Post by pavero »

Thanks [mention]moroz1999[/mention] !

The version for PHP 7.4 works perfectly for me, but version for PHP 7.0 not.

I always get a message "Class not found" ...

http://127.0.0.1/zx/vendor/moroz1999/zx ... script.php

Code: Select all

<?php

include_once('Converter.php');

$converter = new \ZxImage\Converter();
$converter->setType('standard');
$converter->setPath('example.scr'); //
$converter->setBorder(5); //cyan
$converter->setZoom(1); //1 for 320*240 (256*192 with border)

//convert and return image data
if ($binary = $converter->getBinary()) {
    //after conversion we can ask for a mime type of last operation and send it to browser
    if ($imageType = $converter->getResultMime()) {
        header('Content-Type: ' . $imageType);
    }

    //send image contents to browser
    echo $binary;
} else {
 echo "err Class not found";
}      

?>
$className = 'ZxImage\Plugin\Standard'
User avatar
pavero
Dynamite Dan
Posts: 1599
Joined: Sat Dec 09, 2017 11:49 pm
Location: The Czech Republic
Contact:

Re: ZX-Image

Post by pavero »

Well, I had to add ...

Code: Select all

include_once('../../../../vendor/autoload.php');
And it works now ...
User avatar
pavero
Dynamite Dan
Posts: 1599
Joined: Sat Dec 09, 2017 11:49 pm
Location: The Czech Republic
Contact:

Re: ZX-Image

Post by pavero »

[mention]PeterJ[/mention] I have implemented the newest version of ZX-Image on the server.

https://spectrumcomputing.co.uk/ssx-example.php

How I noticed, SCR cache never worked. And I don't know if there was your intention.

I have created 'SCRcache' folder. But I guess it will be generated huge number of files on the server now.
User avatar
moroz1999
Manic Miner
Posts: 329
Joined: Fri Mar 30, 2018 9:22 pm

Re: ZX-Image

Post by moroz1999 »

pavero wrote: Sun Dec 06, 2020 9:27 am @PeterJ I have implemented the newest version of ZX-Image on the server.

https://spectrumcomputing.co.uk/ssx-example.php

How I noticed, SCR cache never worked. And I don't know if there was your intention.

I have created 'SCRcache' folder. But I guess it will be generated huge number of files on the server now.
Nice!
Using cache is generally a good idea, some formats can be really cpu-consumable and as far as I see the parsing is really far for optimal in my old implementation :)
The library would delete the old files from cache automatically, but just for a case keep an eye on files amount.
User avatar
moroz1999
Manic Miner
Posts: 329
Joined: Fri Mar 30, 2018 9:22 pm

Re: ZX-Image

Post by moroz1999 »

pavero wrote: Sat Dec 05, 2020 10:49 pm Well, I had to add ...

Code: Select all

include_once('../../../../vendor/autoload.php');
And it works now ...
Yep, as a composer library it depends on composer's autoloading of classes. So instead of manually including the file with class it's being taken from an agreed location automatically.
https://www.php.net/manual/en/language. ... toload.php
https://www.php-fig.org/psr/psr-4/

I'll update the example in readme.md, the example is from old pre-composer times.
User avatar
PeterJ
Site Admin
Posts: 6926
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: ZX-Image

Post by PeterJ »

[mention]moroz1999[/mention],

When you have time would you be able to update our server with the latest version? Let me know if you need a reminder of the server details. Thanks in advance.
User avatar
pavero
Dynamite Dan
Posts: 1599
Joined: Sat Dec 09, 2017 11:49 pm
Location: The Czech Republic
Contact:

Re: ZX-Image

Post by pavero »

PeterJ wrote: Sun Dec 06, 2020 10:55 am @moroz1999,

When you have time would you be able to update our server with the latest version? Let me know if you need a reminder of the server details. Thanks in advance.
Have you read my previous post? ;)
User avatar
PeterJ
Site Admin
Posts: 6926
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: ZX-Image

Post by PeterJ »

Sorry, [mention]pavero[/mention],

I missed it. Apologies. Thank you for doing that!
User avatar
moroz1999
Manic Miner
Posts: 329
Joined: Fri Mar 30, 2018 9:22 pm

Re: ZX-Image

Post by moroz1999 »

So, is everything ok now? No more help required currently from my side? :)
User avatar
pavero
Dynamite Dan
Posts: 1599
Joined: Sat Dec 09, 2017 11:49 pm
Location: The Czech Republic
Contact:

Re: ZX-Image

Post by pavero »

moroz1999 wrote: Sun Dec 06, 2020 6:10 pm So, is everything ok now? No more help required currently from my side? :)
Yes, at least for now. We will see in the future, because now we don't have any SSX file in ZXDB. :-)
User avatar
PeterJ
Site Admin
Posts: 6926
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: ZX-Image

Post by PeterJ »

pavero wrote: Sun Dec 06, 2020 6:15 pm
Yes, at least for now. We will see in the future, because now we don't have any SSX file in ZXDB. :-)
I have a batch of Sam Coupe games that need screens. I was going to do PNG, but will produce some in SSX during the week and share with you. Peter
User avatar
kolbeck
Manic Miner
Posts: 310
Joined: Mon Nov 13, 2017 9:04 pm

Re: ZX-Image

Post by kolbeck »

Just wish I found this thread ealier, spend a few days getting latest version of zx_image to work with php 8 invoked from commandline :-)

FYI - there are some constructions around accessing array elements in GifCreator that needs to change from {} to [] when moving to PHP 8

But now it works for me..

/Thomas
https://api.zxinfo.dk/v3/ - ZXDB API for developers
zxinfo-file-browser - Cross platform app to manage your files
https://zxinfo.dk - another ZXDB frontend
Post Reply