Using nginx to check Accept header

1,031 views
Skip to first unread message

Kai Hendry

unread,
Aug 27, 2013, 3:39:47 AM8/27/13
to webp-d...@webmproject.org
I noticed https://groups.google.com/a/webmproject.org/forum/#!msg/webp-discuss/GWrE6nBWiNg/JUlnMmmy6UIJ for Apache.

Are there any nginx users out there?

And for the cherry on top, has anyone using dwebp on the fly for browsers that don't support Webp? When I decompress a simple WebP graphics I get a 2M PNG result which is a bit unusable. Wondering if people have good tips for this.

We use WEBP upon http://cam.hackerspace.sg

Thanks,

James Zern

unread,
Aug 28, 2013, 4:05:48 PM8/28/13
to webp-d...@webmproject.org


On Tuesday, August 27, 2013 12:39:47 AM UTC-7, Kai Hendry wrote:

There was a write-up about using the accept-header with nginx recently [1], maybe it's useful.
 

And for the cherry on top, has anyone using dwebp on the fly for browsers that don't support Webp? When I decompress a simple WebP graphics I get a 2M PNG result which is a bit unusable. Wondering if people have good tips for this.

There were a few recent changes which added writing the decoded output to stdout. So using this workflow you could now send that on for further processing:
$ dwebp input.webp -o - | convert - output.jpeg
 

We use WEBP upon http://cam.hackerspace.sg

Thanks,

Kai Hendry

unread,
Aug 28, 2013, 8:56:52 PM8/28/13
to webp-d...@webmproject.org
On 29 August 2013 04:05, James Zern <jz...@google.com> wrote:
> There were a few recent changes which added writing the decoded output to
> stdout. So using this workflow you could now send that on for further
> processing:
> $ dwebp input.webp -o - | convert - output.jpeg

Oh I think I see the change:
http://git.chromium.org/gitweb/?p=webm/libwebp.git;a=commit;h=61405a143d1af15b5d844b19c9c4e24d8fc3891c

I'm using 0.3.1-3 of libwebp on Archlinux. `dwebp` seems unable to
print a version identifier sadly.

Will look into building from source.

Thanks!

Pascal Massimino

unread,
Aug 28, 2013, 9:00:43 PM8/28/13
to WebP Discussion
Hi Kai,


 you can use 'dwebp -version' 

Will look into building from source.

Yes, this patch hasn't made it to any official release yet.


Thanks!

--
You received this message because you are subscribed to the Google Groups "WebP Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webp-discuss...@webmproject.org.
To post to this group, send email to webp-d...@webmproject.org.
Visit this group at http://groups.google.com/a/webmproject.org/group/webp-discuss/.
For more options, visit https://groups.google.com/a/webmproject.org/groups/opt_out.

Kai Hendry

unread,
Aug 28, 2013, 9:09:04 PM8/28/13
to webp-d...@webmproject.org
On 29 August 2013 09:00, Pascal Massimino <pascal.m...@gmail.com> wrote:
> you can use 'dwebp -version'

Oh I should have looked at the man page instead of the stdout help.
`-v` being useless confused me. :-)

Kai Hendry

unread,
Sep 1, 2013, 12:55:28 AM9/1/13
to webp-d...@webmproject.org
An nginx configuration with:

if ($http_accept !~* "webp") {
rewrite ^/(.*\.webp)$ /webp2jpg.php?f=$1 last; break;
}


And webp2jpg.php looking like:

<?php
header("Content-Type: image/jpeg");
$webp = $_REQUEST["f"];
if (file_exists($webp)) {
system("dwebp " . escapeshellarg($webp) . " -o - | convert - jpg:-");
} else {
echo "$webp did not exist";
}
?>


Seems to do the trick!
Reply all
Reply to author
Forward
0 new messages