Skip to content

Commit

Permalink
Merge pull request #3 from chaos-bodensee/guetzli
Browse files Browse the repository at this point in the history
dont use guetzli anymore
  • Loading branch information
DO1JLR authored Aug 28, 2021
2 parents 3f22d97 + fc1a055 commit 2feac63
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 25 deletions.
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ The difference between this plugin and the lektor [thumbnail](https://www.getlek
TL;DR: What does this plugin do?
---------------------------------
+ It will generate ``JPEG`` images in the sizes you configured of all images in your Lektor content.
+ It can optionally optimize the images with the [guetzli](https://github.com/google/guetzli) JPEG encoder. *(You have to install the guetzli binary by yourself)*

Usage
-------
Expand All @@ -29,12 +28,6 @@ To install the plugin, just add ``lektor-image-resize`` to your plugins from the
lektor plugins add lektor-image-resize
```

If you want to use the [guetzli](https://github.com/google/guetzli) JPEG encoder for image post-processing, you have to install it manually.
```bash
# example
apt install guetzli
```

If you have trouble, see the [plugin
installation](https://www.getlektor.com/docs/plugins/) section of the Lektor
documentation.
Expand All @@ -54,7 +47,6 @@ max_height = 800

[woowee]
max_width = 2000
use_guetzli = True
```

Will take a file called `waffle.jpg` and create the files `waffle-small.jpg`,
Expand All @@ -63,7 +55,6 @@ of whether the original file is smaller, so you can link without worrying
whether a file will exist or not. If the original file is smaller than the width
you have specified, the file will only be copied, and will not be resized.

If you want to run guetzli at the generated output, set ``use_guetzli`` to ``True``.

The `max_width`/`max_height` parameters work like for the [Lektor
thumbnail](https://www.getlektor.com/docs/api/db/record/thumbnail/) command.
16 changes: 1 addition & 15 deletions lektor_image_resize.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def process_image(
height=None,
mode=None,
quality=None,
use_guetzli=False,
extra_params=None,
):
"""Build image from source image, optionally compressing and resizing.
Expand All @@ -33,8 +32,6 @@ def process_image(
if width is None and height is None:
raise ValueError("Must specify at least one of width or height.")

guetzli = locate_executable('guetzli')

im = find_imagemagick(ctx.build_state.config["IMAGEMAGICK_EXECUTABLE"])

if quality is None:
Expand All @@ -47,20 +44,15 @@ def process_image(
resize_key += "x" + str(height)

cmdline = [im, source_image, "-auto-orient"]
cmd2line = [guetzli]
cmdline += ["-resize", resize_key]

if extra_params:
cmdline.extend(extra_params)

cmdline += ["-quality", str(quality), dst_filename]
cmd2line += ["--quality", str(quality), dst_filename, dst_filename]

reporter.report_debug_info("imagemagick cmd line", cmdline)
portable_popen(cmdline).wait()
if use_guetzli:
reporter.report_debug_info("guetzli cmd line", cmd2line)
portable_popen(cmd2line).wait()

@buildprogram(Image)
class ResizedImageBuildProgram(AttachmentBuildProgram):
Expand Down Expand Up @@ -88,11 +80,6 @@ def build_artifact(self, artifact):
if not height:
_, height = compute_dimensions(width, None, w, h)

use_guetzli = bool(conf.get("use_guetzli", "0"))

if not use_guetzli:
use_guetzli = False

df = artifact.source_obj.url_path
ext_pos = df.rfind(".")
dst_filename = "%s-%s.%s" % (df[:ext_pos], item, df[ext_pos + 1 :])
Expand All @@ -113,7 +100,6 @@ def build_thumbnail_artifact(artifact):
width,
height,
quality=89,
use_guetzli=use_guetzli,
extra_params=[
"-strip",
"-interlace",
Expand All @@ -129,7 +115,7 @@ def build_thumbnail_artifact(artifact):

class ImageResizePlugin(Plugin):
name = u"thumbnail-generator"
description = u"A configurable way to generate thumbnails and optimize them with guetzli."
description = u"A configurable way to generate thumbnails."
image_exts = ["jpg", "jpeg"]

@cached_property
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
packages=find_packages(),
py_modules=['lektor_image_resize'],
url='https://github.com/chaos-bodensee/lektor-image-resize.git',
version='0.3.0',
version='0.4.0',
classifiers=[
'Framework :: Lektor',
'Environment :: Plugins',
Expand Down

0 comments on commit 2feac63

Please sign in to comment.