<p>Image Optimize hooks into regular old Craft transforms to do its thing. This means that any time an image transform is created, it'll piggyback on that to create any variants such as the <code>.webp</code> versions.</p>

<p>The thing is, Craft looks to see if the image transform is already on disk, and if so, skips the process of re-creating it. So if you enable <code>.webp</code> (or other image variants) after the regular transforms have already been created on disk, Craft will never throw the event to notify Image Optimize that the <code>.webp</code> variants should be made.</p>

<p>So what you can do is delete the image transform directories from the disk (they are all prefaced with an underscore <code>_</code>), clear the Asset Transform cache, and then re-save the volume (or use the built-in Image Optimized CLI command for generating the images).</p>

CC BY-SA 4.0
2019-12-05T14:49:41.847Z
2019-12-05T14:49:41.847Z
andrew.welch
<p>Based on our discussion in the comments I'm very certain that the problem lies within the settings of the fields in your assets.</p>

<p>In your <strong>Optimized Image Variants</strong> have you set the <strong>Image Format</strong> wrongly? 
<a href="https://i.sstatic.net/6zWGR.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/6zWGR.png" alt="enter image description here"></a></p>

<p>If it's not that, then I'm still leaning towards some field/setting rather than the plugin acting wrongly as there were no errors/warnings logged containing <code>webp</code> in your logs.</p>

CC BY-SA 4.0
2019-12-04T15:31:10.720Z
2019-12-04T15:31:10.720Z
Campiotti
<p>I'm struggling to generate webp images on my forge server. Here is my process in Craft 3.</p>

<ol>
<li>ssh in to the server (forge)</li>
<li>Install wepb <code>sudo apt-get install webp</code></li>
<li>Check it is installed and getting piacked up by image Optimize.</li>
</ol>

<p><a href="https://i.sstatic.net/0V3Nh.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/0V3Nh.png" alt="enter image description here"></a></p>

<ol start="4">
<li>In the Craft Admin go to Utilities -> Clear Caches and tick all of the Asset related caches, click on Clear Caches and then to force it to resave all of the images.</li>
<li>Go back to terminal and run <code>./craft image-optimize/optimize/create images</code> - (I have also tried saving the volume in the admin settings(.</li>
<li>Wait for the image processing to finish (takes a good 10 mins as there is only 50 or so images at variouse sizes)</li>
<li>Then I check my image folder to see if the webp variant has been created. There is no webp alternatives.</li>
</ol>

<p><a href="https://i.sstatic.net/ykuNh.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ykuNh.png" alt="enter image description here"></a></p>

<ol start="8">
<li>Log files that get generated are:

<ul>
<li>console.log</li>
<li>queue.log</li>
<li>web.log</li>
</ul></li>
</ol>

<p><a href="https://we.tl/t-8XPKbdZAo4" rel="nofollow noreferrer">Download Log files</a></p>

<p>I'm not seeing any errors in the log files. </p>

<ol start="9">
<li><p>Checking the image-optimize.php config file - everything looks in order.</p>

<pre><code>return [
//  What transform method should be used for image transforms?
'transformMethod' =&gt; 'craft',
// Domain for the Imgix transform service
'imgixDomain' =&gt; '',
// API key for the Imgix transform service
'imgixApiKey' =&gt; '',
// The optional security token used to sign image URLs from Imgix
'imgixSecurityToken' =&gt; '',
// Should the image variants in an Asset Volume be automatically re-saved when saving
// an OptimizedImages field, saving an Asset Volume that has an OptimizedImages field
// in its layout, or saving the ImageOptimized settings. Set this to false only if
// you will be manually using the CLI console command to resave image variants
'automaticallyResaveImageVariants' =&gt; true,
// Should image variant be created on Asset save (aka BeforePageLoad)
'generateTransformsBeforePageLoad' =&gt; true,
// Set to false to disable all placeholder generation
'generatePlaceholders' =&gt; true,
// Controls whether a dominant color palette should be created for image variants
// It takes a bit of time, so if you never plan to use it, you can turn it off
'createColorPalette' =&gt; true,
 // Controls whether SVG placeholder silhouettes should be created for image variants
 // It takes a bit of time, so if you never plan to use them, you can turn it off
'createPlaceholderSilhouettes' =&gt; true,
// Controls whether retina images are automatically created with reduced quality
// as per https://www.netvlies.nl/tips-updates/design-interactie/design-interactie/retina-revolution/
'lowerQualityRetinaImageVariants' =&gt; true,
// Controls whether Optimized Image Variants are created that would be up-scaled
// to be larger than the original source image
'allowUpScaledImageVariants' =&gt; false,
// Controls whether images scaled down &gt;= 50% should be automatically sharpened
'autoSharpenScaledImages' =&gt; true,
// Default aspect ratios
'defaultAspectRatios' =&gt; [
    ['x' =&gt; 16, 'y' =&gt; 9],
    ['x' =&gt; 8, 'y' =&gt; 5],
    ['x' =&gt; 4, 'y' =&gt; 3],
    ['x' =&gt; 5, 'y' =&gt; 4],
    ['x' =&gt; 1, 'y' =&gt; 1],
    ['x' =&gt; 9, 'y' =&gt; 16],
    ['x' =&gt; 5, 'y' =&gt; 8],
    ['x' =&gt; 3, 'y' =&gt; 4],
    ['x' =&gt; 4, 'y' =&gt; 5],
],
// Default image variants
'defaultVariants'            =&gt; [
    [
        'width'          =&gt; 1920,
        'useAspectRatio' =&gt; true,
        'aspectRatioX'   =&gt; 16.0,
        'aspectRatioY'   =&gt; 9.0,
        'retinaSizes'    =&gt; ['1'],
        'quality'        =&gt; 82,
        'format'         =&gt; 'jpg',
    ],
    [
        'width'          =&gt; 1120,
        'useAspectRatio' =&gt; true,
        'aspectRatioX'   =&gt; 16.0,
        'aspectRatioY'   =&gt; 9.0,
        'retinaSizes'    =&gt; ['1', '2'],
        'quality'        =&gt; 82,
        'format'         =&gt; 'jpg',
    ],
    [
        'width'          =&gt; 800,
        'useAspectRatio' =&gt; true,
        'aspectRatioX'   =&gt; 16.0,
        'aspectRatioY'   =&gt; 9.0,
        'retinaSizes'    =&gt; ['1', '2'],
        'quality'        =&gt; 82,
        'format'         =&gt; 'jpg',
    ],
    [
        'width'          =&gt; 480,
        'useAspectRatio' =&gt; true,
        'aspectRatioX'   =&gt; 16.0,
        'aspectRatioY'   =&gt; 9.0,
        'retinaSizes'    =&gt; ['1', '2'],
        'quality'        =&gt; 60,
        'format'         =&gt; 'jpg',
    ],
    [
        'width'          =&gt; 300,
        'useAspectRatio' =&gt; true,
        'aspectRatioX'   =&gt; 1.0,
        'aspectRatioY'   =&gt; 1.0,
        'retinaSizes'    =&gt; ['1', '2'],
        'quality'        =&gt; 60,
        'format'         =&gt; 'jpg',
    ],
    [
        'width'          =&gt; 200,
        'useAspectRatio' =&gt; true,
        'aspectRatioX'   =&gt; 1.0,
        'aspectRatioY'   =&gt; 1.0,
        'retinaSizes'    =&gt; ['1', '2'],
        'quality'        =&gt; 60,
        'format'         =&gt; 'jpg',
    ],
    [
        'width'          =&gt; 100,
        'useAspectRatio' =&gt; true,
        'aspectRatioX'   =&gt; 1.0,
        'aspectRatioY'   =&gt; 1.0,
        'retinaSizes'    =&gt; ['1', '2'],
        'quality'        =&gt; 60,
        'format'         =&gt; 'jpg',
    ],
],
// Active image processors
'activeImageProcessors'      =&gt; [
    'jpg' =&gt; [
        'jpegoptim',
    ],
    'png' =&gt; [
        'optipng',
    ],
    'svg' =&gt; [
        'svgo',
    ],
    'gif' =&gt; [
        'gifsicle',
    ],
],
// Active image variant creators
'activeImageVariantCreators' =&gt; [
    'jpg' =&gt; [
        'cwebp',
    ],
    'png' =&gt; [
        'cwebp',
    ],
    'gif' =&gt; [
        'cwebp',
    ],
],
// Preset image processors
'imageProcessors'            =&gt; [
    // jpeg optimizers
    'jpegoptim' =&gt; [
        'commandPath'           =&gt; '/usr/bin/jpegoptim',
        'commandOptions'        =&gt; '-s',
        'commandOutputFileFlag' =&gt; '',
    ],
    'mozjpeg'   =&gt; [
        'commandPath'           =&gt; '/usr/bin/mozjpeg',
        'commandOptions'        =&gt; '-optimize -copy none',
        'commandOutputFileFlag' =&gt; '-outfile',
    ],
    'jpegtran'  =&gt; [
        'commandPath'           =&gt; '/usr/bin/jpegtran',
        'commandOptions'        =&gt; '-optimize -copy none',
        'commandOutputFileFlag' =&gt; '',
    ],
    // png optimizers
    'optipng'   =&gt; [
        'commandPath'           =&gt; '/usr/bin/optipng',
        'commandOptions'        =&gt; '-o3 -strip all',
        'commandOutputFileFlag' =&gt; '',
    ],
    'pngcrush'  =&gt; [
        'commandPath'           =&gt; '/usr/bin/pngcrush',
        'commandOptions'        =&gt; '-brute -ow',
        'commandOutputFileFlag' =&gt; '',
    ],
    'pngquant'  =&gt; [
        'commandPath'           =&gt; '/usr/bin/pngquant',
        'commandOptions'        =&gt; '--strip--skip -if-larger',
        'commandOutputFileFlag' =&gt; '',
    ],
    // svg optimizers
    'svgo'      =&gt; [
        'commandPath'           =&gt; '/usr/bin/svgo',
        'commandOptions'        =&gt; '',
        'commandOutputFileFlag' =&gt; '',
    ],
    // gif optimizers
    'gifsicle'  =&gt; [
        'commandPath'           =&gt; '/usr/bin/gifsicle',
        'commandOptions'        =&gt; '-O3 -k 256',
        'commandOutputFileFlag' =&gt; '',
    ],
],
'imageVariantCreators' =&gt; [
    // webp variant creator
    'cwebp' =&gt; [
        'commandPath'           =&gt; '/usr/bin/cwebp',
        'commandOptions'        =&gt; '',
        'commandOutputFileFlag' =&gt; '-o',
        'commandQualityFlag'    =&gt; '-q',
        'imageVariantExtension' =&gt; 'webp',
    ],
],
</code></pre>

<p>];</p></li>
</ol>

<p>I'm stumped! What else do I need to check?</p>

CC BY-SA 4.0
2019-12-04T12:27:13.187Z
1. Is your setup craft cms v3+ or v2+? (Please add this to your reply)

2. path will be `craft/app/storage/runtime/logs` in v2 and `app/storage/runtime/logs` in v3.

3. clear the craft cache

4. clear out all files present in the log folder (see step 2)

5. run the image optimiazation/creation command

6. if possible either upload and link your now present log files in your reply or say which files have been generated (name.log)

This should help in identifying wherein the problem lies, thanks!
Campiotti
CC BY-SA 4.0
2019-12-04T14:01:39.133Z
Updated. I'm using Craft 3.3.17
Dan Lee
CC BY-SA 4.0
2019-12-04T14:17:08.973Z
Hmm ok I havent' found anything as of yet, one more thing though, can you copy-paste (or upload) your `craft/config/image-optimize.php` file, if you don't have one then it should be using the default settings.
-----------------------------------------------------------------
One more thing: Could you also verify that you get the "same" output when edit an image asset [as seen here](https://nystudio107.com/docs/image-optimize/assets/img/image-variant-field.d22a9fbe.png) and try to open a webp variant in a new tab (according to github issues, there can also be issues in that area)
Campiotti
CC BY-SA 4.0
2019-12-04T14:29:33.897Z
Two (hopfully) last things:
1. Do you have `devMode` turned on, if not, please do so and re-create webp images so it'll display debug output either in console or/and in logs.
2. https://nystudio107.com/docs/image-optimize/Using.html Have you tried the different methods mentioned herein to generate webp files not directly through the CLI?
Campiotti
CC BY-SA 4.0
2019-12-04T14:46:14.297Z
Updated the question. devMode was on when images were generated. I have used the admin and command line to generate the images according to the documentation.
Dan Lee
CC BY-SA 4.0
2019-12-04T15:22:53.813Z
I grep'd the log files you've uploaded and found that there were only 2 types of lines which contained the text `image-optimize` and were adjusting images:
one was `queue.log:2019-12-04 13:38:26 [-][-][-][info][image-optimize] image/jpeg` the other was `queue.log:2019-12-04 13:38:35 [-][-][-][info][image-optimize] image/png`, there was no mention of image/webp at all
The term `webp` only ever pops up in queue.log in massive logged sql statements wherein links to images like [these](https://bit.ly/2OPqZil) are present - in no other place is the term `webp` present.
=> problem in settings?
Campiotti
<craft3><plugin-imageoptimize>
Generating Webp Images - Webp Installed but not Generating Images
# Generating Webp Images - Webp Installed but not Generating Images

(Asked by: username_0 on 2019-12-04)

I'm struggling to generate webp images on my forge server. Here is my process in Craft 3.

ssh in to the server (forge)
Install wepb sudo apt-get install webp
Check it is installed and getting piacked up by image Optimize.



In the Craft Admin go to Utilities -> Clear Caches and tick all of the Asset related caches, click on Clear Caches and then to force it to resave all of the images.
Go back to terminal and run ./craft image-optimize/optimize/create images - (I have also tried saving the volume in the admin settings(.
Wait for the image processing to finish (takes a good 10 mins as there is only 50 or so images at variouse sizes)
Then I check my image folder to see if the webp variant has been created. There is no webp alternatives.



Log files that get generated are:


console.log
queue.log
web.log


Download Log files
I'm not seeing any errors in the log files. 

Checking the image-optimize.php config file - everything looks in order.
return [
//  What transform method should be used for image transforms?
'transformMethod' => 'craft',
// Domain for the Imgix transform service
'imgixDomain' => '',
// API key for the Imgix transform service
'imgixApiKey' => '',
// The optional security token used to sign image URLs from Imgix
'imgixSecurityToken' => '',
// Should the image variants in an Asset Volume be automatically re-saved when saving
// an OptimizedImages field, saving an Asset Volume that has an OptimizedImages field
// in its layout, or saving the ImageOptimized settings. Set this to false only if
// you will be manually using the CLI console command to resave image variants
'automaticallyResaveImageVariants' => true,
// Should image variant be created on Asset save (aka BeforePageLoad)
'generateTransformsBeforePageLoad' => true,
// Set to false to disable all placeholder generation
'generatePlaceholders' => true,
// Controls whether a dominant color palette should be created for image variants
// It takes a bit of time, so if you never plan to use it, you can turn it off
'createColorPalette' => true,
 // Controls whether SVG placeholder silhouettes should be created for image variants
 // It takes a bit of time, so if you never plan to use them, you can turn it off
'createPlaceholderSilhouettes' => true,
// Controls whether retina images are automatically created with reduced quality
// as per https://www.netvlies.nl/tips-updates/design-interactie/design-interactie/retina-revolution/
'lowerQualityRetinaImageVariants' => true,
// Controls whether Optimized Image Variants are created that would be up-scaled
// to be larger than the original source image
'allowUpScaledImageVariants' => false,
// Controls whether images scaled down >= 50% should be automatically sharpened
'autoSharpenScaledImages' => true,
// Default aspect ratios
'defaultAspectRatios' => [
    ['x' => 16, 'y' => 9],
    ['x' => 8, 'y' => 5],
    ['x' => 4, 'y' => 3],
    ['x' => 5, 'y' => 4],
    ['x' => 1, 'y' => 1],
    ['x' => 9, 'y' => 16],
    ['x' => 5, 'y' => 8],
    ['x' => 3, 'y' => 4],
    ['x' => 4, 'y' => 5],
],
// Default image variants
'defaultVariants'            => [
    [
        'width'          => 1920,
        'useAspectRatio' => true,
        'aspectRatioX'   => 16.0,
        'aspectRatioY'   => 9.0,
        'retinaSizes'    => ['1'],
        'quality'        => 82,
        'format'         => 'jpg',
    ],
    [
        'width'          => 1120,
        'useAspectRatio' => true,
        'aspectRatioX'   => 16.0,
        'aspectRatioY'   => 9.0,
        'retinaSizes'    => ['1', '2'],
        'quality'        => 82,
        'format'         => 'jpg',
    ],
    [
        'width'          => 800,
        'useAspectRatio' => true,
        'aspectRatioX'   => 16.0,
        'aspectRatioY'   => 9.0,
        'retinaSizes'    => ['1', '2'],
        'quality'        => 82,
        'format'         => 'jpg',
    ],
    [
        'width'          => 480,
        'useAspectRatio' => true,
        'aspectRatioX'   => 16.0,
        'aspectRatioY'   => 9.0,
        'retinaSizes'    => ['1', '2'],
        'quality'        => 60,
        'format'         => 'jpg',
    ],
    [
        'width'          => 300,
        'useAspectRatio' => true,
        'aspectRatioX'   => 1.0,
        'aspectRatioY'   => 1.0,
        'retinaSizes'    => ['1', '2'],
        'quality'        => 60,
        'format'         => 'jpg',
    ],
    [
        'width'          => 200,
        'useAspectRatio' => true,
        'aspectRatioX'   => 1.0,
        'aspectRatioY'   => 1.0,
        'retinaSizes'    => ['1', '2'],
        'quality'        => 60,
        'format'         => 'jpg',
    ],
    [
        'width'          => 100,
        'useAspectRatio' => true,
        'aspectRatioX'   => 1.0,
        'aspectRatioY'   => 1.0,
        'retinaSizes'    => ['1', '2'],
        'quality'        => 60,
        'format'         => 'jpg',
    ],
],
// Active image processors
'activeImageProcessors'      => [
    'jpg' => [
        'jpegoptim',
    ],
    'png' => [
        'optipng',
    ],
    'svg' => [
        'svgo',
    ],
    'gif' => [
        'gifsicle',
    ],
],
// Active image variant creators
'activeImageVariantCreators' => [
    'jpg' => [
        'cwebp',
    ],
    'png' => [
        'cwebp',
    ],
    'gif' => [
        'cwebp',
    ],
],
// Preset image processors
'imageProcessors'            => [
    // jpeg optimizers
    'jpegoptim' => [
        'commandPath'           => '/usr/bin/jpegoptim',
        'commandOptions'        => '-s',
        'commandOutputFileFlag' => '',
    ],
    'mozjpeg'   => [
        'commandPath'           => '/usr/bin/mozjpeg',
        'commandOptions'        => '-optimize -copy none',
        'commandOutputFileFlag' => '-outfile',
    ],
    'jpegtran'  => [
        'commandPath'           => '/usr/bin/jpegtran',
        'commandOptions'        => '-optimize -copy none',
        'commandOutputFileFlag' => '',
    ],
    // png optimizers
    'optipng'   => [
        'commandPath'           => '/usr/bin/optipng',
        'commandOptions'        => '-o3 -strip all',
        'commandOutputFileFlag' => '',
    ],
    'pngcrush'  => [
        'commandPath'           => '/usr/bin/pngcrush',
        'commandOptions'        => '-brute -ow',
        'commandOutputFileFlag' => '',
    ],
    'pngquant'  => [
        'commandPath'           => '/usr/bin/pngquant',
        'commandOptions'        => '--strip--skip -if-larger',
        'commandOutputFileFlag' => '',
    ],
    // svg optimizers
    'svgo'      => [
        'commandPath'           => '/usr/bin/svgo',
        'commandOptions'        => '',
        'commandOutputFileFlag' => '',
    ],
    // gif optimizers
    'gifsicle'  => [
        'commandPath'           => '/usr/bin/gifsicle',
        'commandOptions'        => '-O3 -k 256',
        'commandOutputFileFlag' => '',
    ],
],
'imageVariantCreators' => [
    // webp variant creator
    'cwebp' => [
        'commandPath'           => '/usr/bin/cwebp',
        'commandOptions'        => '',
        'commandOutputFileFlag' => '-o',
        'commandQualityFlag'    => '-q',
        'imageVariantExtension' => 'webp',
    ],
],

];

I'm stumped! What else do I need to check?

**Tags:** craft3, plugin-imageoptimize
> **Comments:**
> **username_1**: 1. Is your setup craft cms v3+ or v2+? (Please add this to your reply)  2. path will be `craft/app/storage/runtime/logs` in v2 and `app/storage/runtime/logs` in v3.  3. clear the craft cache  4. clear out all files present in the log folder (see step 2)  5. run the image optimiazation/creation command  6. if possible either upload and link your now present log files in your reply or say which files have been generated (name.log)  This should help in identifying wherein the problem lies, thanks!  
> **username_0**: Updated. I'm using Craft 3.3.17  
> **username_1**: Hmm ok I havent' found anything as of yet, one more thing though, can you copy-paste (or upload) your `craft/config/image-optimize.php` file, if you don't have one then it should be using the default settings. ----------------------------------------------------------------- One more thing: Could you also verify that you get the "same" output when edit an image asset [as seen here](https://nystudio107.com/docs/image-optimize/assets/img/image-variant-field.d22a9fbe.png) and try to open a webp variant in a new tab (according to github issues, there can also be issues in that area)  
> **username_1**: Two (hopfully) last things: 1. Do you have `devMode` turned on, if not, please do so and re-create webp images so it'll display debug output either in console or/and in logs. 2. https://nystudio107.com/docs/image-optimize/Using.html Have you tried the different methods mentioned herein to generate webp files not directly through the CLI?  
> **username_0**: Updated the question. devMode was on when images were generated. I have used the admin and command line to generate the images according to the documentation.  
> **username_1**: I grep'd the log files you've uploaded and found that there were only 2 types of lines which contained the text `image-optimize` and were adjusting images: one was `queue.log:2019-12-04 13:38:26 [-][-][-][info][image-optimize] image/jpeg` the other was `queue.log:2019-12-04 13:38:35 [-][-][-][info][image-optimize] image/png`, there was no mention of image/webp at all The term `webp` only ever pops up in queue.log in massive logged sql statements wherein links to images like [these](https://bit.ly/2OPqZil) are present - in no other place is the term `webp` present. => problem in settings?  

---

## 2 answers

### Answer by username_2 on 2019-12-05. Score: 2

Image Optimize hooks into regular old Craft transforms to do its thing. This means that any time an image transform is created, it'll piggyback on that to create any variants such as the `.webp` versions.

The thing is, Craft looks to see if the image transform is already on disk, and if so, skips the process of re-creating it. So if you enable `.webp` (or other image variants) after the regular transforms have already been created on disk, Craft will never throw the event to notify Image Optimize that the `.webp` variants should be made.

So what you can do is delete the image transform directories from the disk (they are all prefaced with an underscore `_`), clear the Asset Transform cache, and then re-save the volume (or use the built-in Image Optimized CLI command for generating the images).


---

### Answer by username_1 on 2019-12-04. Score: 1

Based on our discussion in the comments I'm very certain that the problem lies within the settings of the fields in your assets.

In your **Optimized Image Variants** have you set the **Image Format** wrongly?
[![enter image description here](https://i.sstatic.net/6zWGR.png)](https://i.sstatic.net/6zWGR.png)

If it's not that, then I'm still leaning towards some field/setting rather than the plugin acting wrongly as there were no errors/warnings logged containing `webp` in your logs.


---

