Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVG optimization command fails due to missing space between command and file path #300

Closed
bfopma opened this issue Nov 12, 2021 · 1 comment
Labels

Comments

@bfopma
Copy link

bfopma commented Nov 12, 2021

Describe the bug

On line 664 of craft-imageoptimize/src/services/Optimize.php, command options are concatenated and padded with spaces only if $thisProcessor['commandOptions'] isn't empty. All of the image optimizers except svgo have default command options in the config. If using svgo, it fails because a space is missing between the command and path in the absence of a command option.

For example:

2021-11-12 10:49:52 [-][-][-][profile begin][nystudio107\imageoptimize\services\Optimize::optimizeImage] optimizeImage
2021-11-12 10:49:52 [-][-][-][info][nystudio107\imageoptimize\services\Optimize::executeImageProcessor] /usr/bin/svgo'/app/storage/runtime/temp/7_Text_v1618e9b30d101f3.73745519.svg'
sh: 1: /usr/bin/svgo/app/storage/runtime/temp/7_Text_v1618e9b30d101f3.73745519.svg: not found

To reproduce

Steps to reproduce the behaviour:

Config:

'svgo' => [
       'commandPath' => '/usr/bin/svgo',
       'commandOptions' => '',
       'commandOutputFileFlag' => '',
],

Create an image transform to trigger optimization on an SVG:

{% set transform = {
   quality: 100
} %}

{{ svg.getUrl(transform) }}

Versions

  • Plugin version: 1.6.37
  • Craft version: 3.7.20
@bfopma bfopma added the bug label Nov 12, 2021
khalwat added a commit that referenced this issue Nov 13, 2021
… `commandOptions` have the resulting command properly padded with a space ([#300](#300))

Signed-off-by: Andrew Welch <andrew@nystudio107.com>
@khalwat
Copy link
Contributor

khalwat commented Nov 13, 2021

Addressed in: 33c612f

You can try it now by setting your semver in your composer.json to look like this:

    "nystudio107/craft-imageoptimize": "dev-develop as 1.6.38”,

Then do a composer clear-cache && composer update

@khalwat khalwat closed this as completed Nov 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants