Search code examples
phpshell-execwebp

is it possible to convert webp image without shell_exec() or exec() in rosell-dk packages?


is it possible to convert .webp image without shell_exec() or exec() in rosell-dk packages ? i am use rosell-dk package and install through composer. and rosell-dk package use shell_Exec() or exec() function .


Solution

  • Assuming you're talking about the rosell-dk/webp-convert package, it looks like the 'gd' converter uses the php-gd extension to convert from jpeg to webp without using any shell commands.

    Based on the documentation you'd force the package to use the 'gd' converter like this:

     <?php
    // Initialise your autoloader (this example is using Composer)
    require 'vendor/autoload.php';
    use WebPConvert\WebPConvert;
    $source = __DIR__ . '/logo.jpg';
    $destination = __DIR__ . '/logo.jpg.webp';
    $success = WebPConvert::convert($source, $destination, [
        'converters' => ['gd']
    ]);