plan2net / webp

Create a WebP copy for images (TYPO3 CMS)
GNU General Public License v3.0
60 stars 34 forks source link

Convert images of different folder #3

Closed vruescas closed 5 years ago

vruescas commented 5 years ago

Hello,

i have a question, i try to use the webp plugin, but my project have a lot of images out of processed folder. You know how i can convert this images?

My try: ` RewriteEngine On RewriteCond %{HTTP_ACCEPT} image/webp RewriteCond %{DOCUMENT_ROOT}/$1.webp -f RewriteRule ^(fileadmin.+).(jpe?g|png)$ $1.webp [T=image/webp,E=accept:1]

Header append Vary Accept env=REDIRECT_accept

AddType image/webp .webp`

wazum commented 5 years ago

This extension handles only processed (resized, cropped) images.

You would have to script this yourself to batch-convert all (or other) images. Take a look at the methods in https://github.com/plan2net/webp/blob/master/Classes/Service/Image/Webp.php where I'm using imageMagickExec.

hth

the-hotmann commented 5 years ago

I would also be interested in a global WebP handeling from this extension. I think a lot of pictured gets included without cropping/resizing. Like Logos etc. Why should someone crop them/resize them just to get them handeled as webP..?

In your read me you have written from mod_pagespeed as alternative, but Mod Pagespeed is for every image, not just processed etc. So in this example I see mod_pagespeed as superior as it converts ALL the Images which are png/jpg.

wazum commented 5 years ago

I did take another look at the issue and now it's the default behaviour to convert all images in every local and writable storage (fileadmin/user_uploads, etc.). I updated the README accordingly and would like to get some feedback after your tests @vruescas @M4rt1n17 There's currently no new release on TER, but you can install 1.1.0 through packagist (via composer).

the-hotmann commented 5 years ago

I already tested the v1.1.0-dev and It seems not to generate any .webp for me. Is there a button to trigger the "convert all images" to WebP action or how does that get initiated?

I checked:

/fileadmin/
/fileadmin/user_upload/
/fileadmin/_processed_/
/fileadmin/_temp_/ 

but no .webp file have been in there. Does the generated webp gets generated somewhere else?

Also I have copied the standard .htaccess config (without the "other-storage" line) Is this basic config working for you?

Here my complete .htaccess:

# ------------------------------------------------------------------------------
# |                          ### WebP Support ###                              |
# ------------------------------------------------------------------------------
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_ACCEPT} image/webp
    RewriteCond %{DOCUMENT_ROOT}/$1.$2.webp -f
    RewriteRule ^(fileadmin/.+)\.(png|jpg|jpeg)$ $1.$2.webp [T=image/webp,E=accept:1]
</IfModule>

<IfModule mod_headers.c>
    Header append Vary Accept env=REDIRECT_accept
</IfModule>

This part is already included (more down in the htaccess) in the standard Typo3 .htaccess:

AddType image/webp .webp

But I also tried it with adding it right behind the other config. Did not change anything.

Here some Infos about my Setup:

Debian: v9.7 Plesk: v17.8.11 (Nr 37) TYPO3: v9.5.4 Apache: v2.4 PHP: v7.3.1 ImageMagick v6.9.7-4 I use CloudFlare [✓] a2enmod rewrite [✓] a2enmod headers [✓]

wazum commented 5 years ago

@M4rt1n17 if you had installed the extension before, you'll have to update (just save once) the extension configuration via the Extension Manager. The Webp copy is always stored in the same folder as the original file.

wazum commented 5 years ago

@M4rt1n17 and I guess you'll have to clear your processed files (via Install tool or manually) or test with a new image uploaded and included on a page

wazum commented 5 years ago

@M4rt1n17 I just double-checked with a fresh install and it works as advertised, hope you find the problem, would be curious to know

the-hotmann commented 5 years ago

@M4rt1n17 I just double-checked with a fresh install and it works as advertised, hope you find the problem, would be curious to know

I'm sorry to say, but I just uploaded a fresh image (jpg) and tested it with the new one. I also cleaned all processed files a lot times befor and also now, but I never got a .webp from this extension. Is there maybe one more dependency this extension needs?

I also added (befor) images via webinterface from server and not Typo3, so I have both now: fileswhich are uploaded from Server and files which are uploaded from Typo3 Backend. Problem is: its not working for both..

I think even if there would be a mistake in teh htaccess this would not affect the convertion to webp?? But this extension does not convert any Image to webp for me. This installation has access to 4GB Ram and 4 Cores a 3,2Ghz. This should be enough.

Log in Typo3 and at the Server is empty, ... well not empty, normal log files but not even a warning, and no errors

wazum commented 5 years ago

@M4rt1n17 So it did not work before your first comment on this thread either?

And yes, sure, there's another dependency: your version of ImageMagick oder GraphicsMagick on the server needs to support Webp (I'll update the README if that's not clear enough).

You can test it with (example for GraphicsMagick, see ImageMagick documentation if you use that): /usr/bin/gm convert +profile '*' -quality 95 -define webp:lossless=false 'myimage.jpg[0]' 'myimage.jpg.webp'

or simply: gm version |grep WebP should return yes

or with ImageMagick: convert version|grep webp should return a list with webp in it

the-hotmann commented 5 years ago

No I just checkt it afterwards, but never a webp got created in this Typo3 Installation.

You are right, my Version of ImageMagick does not support webp... I'm using the latest ImageMagick Version for Debian 9.

I just brew my own ImageMagick version, (version 7 which supports WebP) and also installed "webp" Now it works... at least all the webp Pics get generated.

wazum commented 5 years ago

Thanks, so I close this issue as resolved