TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Best Self-Hosted, Server-Side Image Optimization Tools?

59 pointsby DivineTraubealmost 8 years ago
Compressing images is extremely important for web performance. There are several desktop apps (e.g., ImageOptim, Trimage, ImageAlpha) and web services (e.g., TinyPNG, Kraken, Cloudinary, Imgix, CompressPNG, ImageOptim) that perform optimizations.<p>Thumbor (http:&#x2F;&#x2F;thumbor.org&#x2F; ) is a tool that can be installed locally in an application architecture. However, it is focused on cropping &amp; resizing, though it can also transcode to WebP and call external optimizers.<p>What is the most complete solution you are aware of that compresses &amp; optimizes png, jpeg, and webp and can be operated on a server? It should not only be able to optimize as part of the build process but also in response to user-generated content.

22 comments

wsxiaoysalmost 8 years ago
I believe the most complete solution is a full unix environment with shell piping the image stream. so i make <a href="https:&#x2F;&#x2F;bash.rocks" rel="nofollow">https:&#x2F;&#x2F;bash.rocks</a>, which is a web frontend backed by a unix environment.<p>Snippets:<p>1. Resizing with imagemagick: <a href="https:&#x2F;&#x2F;bash.rocks&#x2F;Gxlg31&#x2F;3" rel="nofollow">https:&#x2F;&#x2F;bash.rocks&#x2F;Gxlg31&#x2F;3</a><p>2. Resizing and convert to webp: <a href="https:&#x2F;&#x2F;bash.rocks&#x2F;7J1jgB&#x2F;1" rel="nofollow">https:&#x2F;&#x2F;bash.rocks&#x2F;7J1jgB&#x2F;1</a><p>After creating the snippet, you could either use GET <a href="https:&#x2F;&#x2F;bash.rocks&#x2F;0Be95B" rel="nofollow">https:&#x2F;&#x2F;bash.rocks&#x2F;0Be95B</a> (query parameters become environment variable) or POST <a href="https:&#x2F;&#x2F;bash.rocks&#x2F;jJggWJ" rel="nofollow">https:&#x2F;&#x2F;bash.rocks&#x2F;jJggWJ</a> (request body become stdin).<p>It&#x27;s not hard to roll your backend like this for private usage (simply exec from node). I&#x27;m also working on an open source release.
评论 #14633910 未加载
matrixalmost 8 years ago
For Java (or other JVM languages such as Kotlin), TwelveMonkeys is powerful and does not have external dependencies:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;haraldk&#x2F;TwelveMonkeys" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;haraldk&#x2F;TwelveMonkeys</a>
Theodoresalmost 8 years ago
Google Pagespeed for Nginx and Apache is another way to go. The benefit of this approach is that you don&#x27;t have to bulk out your code.<p>As for metadata, today I decided to add it back in.<p><a href="https:&#x2F;&#x2F;www.gs1.org&#x2F;sites&#x2F;default&#x2F;files&#x2F;docs&#x2F;gdsn&#x2F;Product_Image_Specification.pdf" rel="nofollow">https:&#x2F;&#x2F;www.gs1.org&#x2F;sites&#x2F;default&#x2F;files&#x2F;docs&#x2F;gdsn&#x2F;Product_Im...</a><p>For ecommerce it will eventally help to have product data, e.g. brand, product name etc embedded in the image.<p>My other tip if you go the Imagemagick&#x2F;PAGESPEED route then you can use 4:2:2 colour space and ditch half the bits used for chroma.
tobltobsalmost 8 years ago
In my experience not the optimization is the hard part. But the eventually necessary scaling down you have to do first. Doing this with Imagemagick, Pillow or whatever will result in possible OOMs or gigabyte sized, not so temporary files filling your &#x2F;tmp dir for large source images.<p>The only tool I ever found which does this job reliable even for huge images is <a href="http:&#x2F;&#x2F;www.vips.ecs.soton.ac.uk" rel="nofollow">http:&#x2F;&#x2F;www.vips.ecs.soton.ac.uk</a> .
评论 #14613444 未加载
评论 #14617022 未加载
cbralmost 8 years ago
I used to work on mod_pagespeed &#x2F; ngx_pagespeed, and I&#x27;m very proud of our image optimization: <a href="https:&#x2F;&#x2F;modpagespeed.com&#x2F;doc&#x2F;filter-image-optimize" rel="nofollow">https:&#x2F;&#x2F;modpagespeed.com&#x2F;doc&#x2F;filter-image-optimize</a><p>It compresses and optimizes png, gif, and jpeg, creates webp for browsers that support it, inlines small images into your html, longcaches images, and even creates srcsets.
fweespeechalmost 8 years ago
&gt; What is the most complete solution you are aware of that compresses &amp; optimizes png, jpeg, and webp and can be operated on a server? It should not only be able to optimize as part of the build process but also in response to user-generated content.<p>Tbh the UGC side is just triggering the &quot;build process side&quot; as the upload occurs.<p>As far as best,<p><a href="https:&#x2F;&#x2F;github.com&#x2F;MediaCrush&#x2F;MediaCrush&#x2F;blob&#x2F;b32e2752d1a19dcf9b4a88945c9dc1441153f5a6&#x2F;mediacrush&#x2F;processing&#x2F;processors.py" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;MediaCrush&#x2F;MediaCrush&#x2F;blob&#x2F;b32e2752d1a19d...</a><p>I&#x27;d suggest you look there for some decent examples of how to go about it. They may be defunct but I use a similar approach (slightly different knob tweaks with the same binaries) and it works fine. May not be 100% optimal but its good enough imo.
vladdanilovalmost 8 years ago
I&#x27;m working on Optimage [1] for both lossless and visually lossless (lossy) optimizations. Right now it&#x27;s available for Mac only. But I have a Linux version working internally as part of the upcoming Server plan.<p>[1] <a href="http:&#x2F;&#x2F;getoptimage.com" rel="nofollow">http:&#x2F;&#x2F;getoptimage.com</a>
ikennachifoalmost 8 years ago
With this recent addition(<a href="https:&#x2F;&#x2F;webspeedtest.cloudinary.com" rel="nofollow">https:&#x2F;&#x2F;webspeedtest.cloudinary.com</a>) to tools you can use, Cloudinary(<a href="http:&#x2F;&#x2F;cloudinary.com" rel="nofollow">http:&#x2F;&#x2F;cloudinary.com</a>) is hands down the best for me, In all the time I&#x27;ve been using it, It usually has a way of meeting all my needs. I&#x27;m obsessed with page speeds and Optimization, like I have sleepless nights optimizing, but since using Cloudinary, I can sleep well on some nights now. And No! I don&#x27;t work there, but bless the people that work there.
eeepsalmost 8 years ago
Disclaimer: I work for Cloudinary. But: all of the services that you mention have an awful lot to offer, over roll-your-own solutions. Reliability and scalability, sure — but also, right now, just flat-out-better performance and output. From big flashy features like automatic optimization using perceptual metrics and on-the-fly responsive resizing with Client Hints ... all the way down to nitty gritty stuff that doesn’t get press releases like, say, dialed-in custom resizing algorithms... in 2017, hosted, paid services can do a lot more a lot better than anything you can set up yourself using free tools.<p>Images are complicated and important enough that I don&#x27;t see that changing any time soon.
评论 #14614267 未加载
rawrmaanalmost 8 years ago
Sharp for node.js has proven to be powerful, flexible and fast for my needs: <a href="https:&#x2F;&#x2F;github.com&#x2F;lovell&#x2F;sharp&#x2F;" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;lovell&#x2F;sharp&#x2F;</a>
评论 #14613879 未加载
NicoJuicyalmost 8 years ago
I use ImageResizer 4.3.2 for Asp.Net MVC ( it&#x27;s free), new versions are less free though... Best thing is, if you want to resize, you can just do it through the url. Eg. &#x2F;Assets&#x2F;img&#x2F;logo.png?Width=200
r1chalmost 8 years ago
I use a combination of jpegoptim, optipng, advpng and zopflipng.<p>Be especially careful with these utilities when running them on UGC. PNG &#x2F; JPEG bombs can easily cause OOM or CPU DoS conditions etc.
logicucealmost 8 years ago
I think Thumbor fits the bill very well. In fact, using something like APSL&#x27;s thumbor docker image [1], you get the complete setup including the optimizers, object detection, etc. ready to go.<p>It works really well for UGC as an ondemand optimizer but you can easily make some URL calls to include it in the build time as well.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;APSL&#x2F;docker-thumbor" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;APSL&#x2F;docker-thumbor</a>
v3ss0nalmost 8 years ago
pilbox is very powerful : <a href="https:&#x2F;&#x2F;pypi.python.org&#x2F;pypi&#x2F;pilbox" rel="nofollow">https:&#x2F;&#x2F;pypi.python.org&#x2F;pypi&#x2F;pilbox</a>
评论 #14613074 未加载
focusgroup0almost 8 years ago
<a href="https:&#x2F;&#x2F;github.com&#x2F;image-server&#x2F;image-server" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;image-server&#x2F;image-server</a>
tmalyalmost 8 years ago
I ended up writing something in Go that resizes images to different devices after a user uploads the food image.<p>I originally tried to use Google Pagespeed but I was getting some strange error message from image compression.
nielsolealmost 8 years ago
Haven&#x27;t tried it out, but looked quite promising: <a href="https:&#x2F;&#x2F;github.com&#x2F;thephpleague&#x2F;glide&#x2F;" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;thephpleague&#x2F;glide&#x2F;</a> Does everything basic, that I would look for in an image API
Mojahalmost 8 years ago
I automated my workflow server side with OptiPNG. <a href="https:&#x2F;&#x2F;ma.ttias.be&#x2F;optimize-size-png-images-automatically-webserver-optipng&#x2F;" rel="nofollow">https:&#x2F;&#x2F;ma.ttias.be&#x2F;optimize-size-png-images-automatically-w...</a>
silasbalmost 8 years ago
<a href="https:&#x2F;&#x2F;github.com&#x2F;h2non&#x2F;imaginary" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;h2non&#x2F;imaginary</a> appears to support quality&#x2F;compression settings.
评论 #14660334 未加载
iamonuwaalmost 8 years ago
pilbox is very powerful : <a href="https:&#x2F;&#x2F;pypi.python.org&#x2F;pypi&#x2F;pilbox" rel="nofollow">https:&#x2F;&#x2F;pypi.python.org&#x2F;pypi&#x2F;pilbox</a><p>However with the recent addition by cloudinary (<a href="https:&#x2F;&#x2F;webspeedtest.cloudinary.com" rel="nofollow">https:&#x2F;&#x2F;webspeedtest.cloudinary.com</a>), the tool is awesome for me.
tyingqalmost 8 years ago
<a href="https:&#x2F;&#x2F;pngquant.org" rel="nofollow">https:&#x2F;&#x2F;pngquant.org</a> lossy optimization of png images.
anilshanbhagalmost 8 years ago
optipng and jpegoptim are pretty good. Have a feeling most of these tools use these utilities inside them.