Page 3 of 37

Re: Image Resizing Script required - a better one...

Posted: Tue Mar 07, 2017 8:52 am
by Celauran
You could in theory download the Imagine library manually, set up your own autoloading, and thereby bypass Composer. Seems unnecessarily complicated to me, though. A few simple composer require saves you from writing tons of boilerplate.

Re: Image Resizing Script required - a better one...

Posted: Tue Mar 07, 2017 8:55 am
by simonmlewis
I just tried.

Re: Image Resizing Script required - a better one...

Posted: Tue Mar 07, 2017 9:00 am
by Celauran
Having not used Windows since Win7 was new, I'm afraid I'll be worse than useless at helping you resolve that. You could try the manual installation. Otherwise, you'll need to rely on Google to get that installed.

Re: Image Resizing Script required - a better one...

Posted: Tue Mar 07, 2017 9:13 am
by simonmlewis
Bugger.
What I am going to do in the meantime, is send my older code, with the longer-winded script to the guys we are doing this with to see if they can fathom how to make it work without additional libraries.

If it were to be done by a consumer, 'speed' may be important. But it isn't.
Does make one wonder how it works on Wordpress. Or maybe that uses a different engine for resizing. Though I Think that does it on the fly, as it is requested at user end.

Re: Image Resizing Script required - a better one...

Posted: Tue Mar 07, 2017 9:19 am
by Celauran
simonmlewis wrote:Bugger.
What I am going to do in the meantime, is send my older code, with the longer-winded script to the guys we are doing this with to see if they can fathom how to make it work without additional libraries.
Fair enough for the meantime, but I strongly advise against giving up on Composer. It's not really optional for modern PHP development. Wish I could help more, but haven't touched Windows in ages.
simonmlewis wrote:Does make one wonder how it works on Wordpress.
You could just look at their code.
simonmlewis wrote:Though I Think that does it on the fly, as it is requested at user end.
Only the first time a particular size is requested. Once it's saved to the disk, that's what gets served.

Re: Image Resizing Script required - a better one...

Posted: Tue Mar 07, 2017 9:26 am
by Celauran
Going to require some digging, but you could start here:
https://github.com/WordPress/WordPress/ ... d.php#L142

Re: Image Resizing Script required - a better one...

Posted: Tue Mar 07, 2017 9:29 am
by simonmlewis
Yes so it must check for each image shown, if it exists or not. And if not, it then creates it on the fly.
That might even be a better way of doing it. And when Admin delete the main image, it checks if there are the other three versions on the server, and delete those.

But I am assuming we need Composer to do this 'on the fly' stuff?

Re: Image Resizing Script required - a better one...

Posted: Tue Mar 07, 2017 9:32 am
by Celauran
Take a look at your old code. Take a look at the WordPress code. Heck, take a look at the Imagine code. It can all be done using PHP's built-in functionality. The point of leveraging third-party libraries is that the heavy lifting is already done for you and you can just call it via a simple public API.

Re: Image Resizing Script required - a better one...

Posted: Tue Mar 07, 2017 9:39 am
by simonmlewis
It's installed. There was some issue, but when I Tried it again, it worked.

Re: Image Resizing Script required - a better one...

Posted: Tue Mar 07, 2017 9:43 am
by simonmlewis
I'm still getting that error. It was installed using the default settings, so would in theory run for all sites on my laptop.
But those two line errors show up.

Re: Image Resizing Script required - a better one...

Posted: Tue Mar 07, 2017 9:44 am
by Celauran
Which errors?

Re: Image Resizing Script required - a better one...

Posted: Tue Mar 07, 2017 9:46 am
by simonmlewis
Warning: require_once(C:\xampp\phpMyAdmin\site-wide/vendor/autoload.php): failed to open stream: No such file or directory in C:\xampp\phpMyAdmin\site-wide\includes\a_home.inc on line 616

Fatal error: require_once(): Failed opening required 'C:\xampp\phpMyAdmin\site-wide/vendor/autoload.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\phpMyAdmin\site-wide\includes\a_home.inc on line 616

Line 616 is this:
require_once dirname(__DIR__) . '/vendor/autoload.php';

Re: Image Resizing Script required - a better one...

Posted: Tue Mar 07, 2017 9:48 am
by Celauran
Have you created your composer.json file? Are you pulling in Imagine? Are you looking for the autoload file in the right place?

Re: Image Resizing Script required - a better one...

Posted: Tue Mar 07, 2017 9:50 am
by simonmlewis
That page you sent doesn't state about creating a composer.json file. I'm using that code you sent me.
require_once dirname(__DIR__) . '/vendor/autoload.php';

$imagine = new Imagine\Gd\Imagine();

Re: Image Resizing Script required - a better one...

Posted: Tue Mar 07, 2017 9:55 am
by Celauran
https://getcomposer.org/doc/01-basic-usage.md

You need to tell composer which packages you need. For this case, calling this should suffice:

Code: Select all

composer require imagine/imagine
Alternately, create a composer.json in your project's root directory with the following contents:

Code: Select all

{
    "require": {
        "imagine/imagine": "^0.6.3"
    }
}
and run composer install