thumbnailing

59 views
Skip to first unread message

gry

unread,
Apr 12, 2011, 5:03:02 PM4/12/11
to Hyde
Hello.

Is there any support for thumbnailing images in hyde? How do you think
it should be implemented? Some template tag?

sport4minus

unread,
May 15, 2011, 1:01:04 PM5/15/11
to Hyde
excellent question. is there something like a thumbnail plugin in one
of the several repositiories?

Vincent Bernat

unread,
May 15, 2011, 4:18:29 PM5/15/11
to hyde...@googlegroups.com
OoO Pendant le repas du dimanche 15 mai 2011, vers 19:01, sport4minus
<jens.wu...@gmail.com> disait :

> excellent question. is there something like a thumbnail plugin in one
> of the several repositiories?

I plan to make one. I also would like to be able to incorporate some
gallery on top of this. Something like:
{% site.gallery('blah/*.jpg') %}

Hope to do this this week but any idea on the best way to do is welcome!
--
Don't use conditional branches as a substitute for a logical expression.
- The Elements of Programming Style (Kernighan & Plauger)

Grygoriy Fuchedzhy

unread,
May 15, 2011, 4:49:37 PM5/15/11
to hyde...@googlegroups.com
On Sun, May 15, 2011 at 10:18:29PM +0200, Vincent Bernat wrote:
> I plan to make one. I also would like to be able to incorporate some
> gallery on top of this. Something like:
> {% site.gallery('blah/*.jpg') %}
>
> Hope to do this this week but any idea on the best way to do is welcome!

I think its important to allow to specify exact width, height for individual
thumbnail, like
{% site.thumbnail('pic.jpg', 100, 200) %}
and if not specified, take defaults from meta plugin

--
Grygoriy Fuchedzhy

Lakshmi Vyas

unread,
May 16, 2011, 12:44:23 AM5/16/11
to hyde...@googlegroups.com
Hi,

There is a thumbnail implementation right here that can be ported pretty much as is:
https://github.com/lakshmivyas/hyde/blob/master/hydeengine/media_processors.py#L264-287

Thanks
Lakshmi

> --
> You received this message because you are subscribed to the Google Groups "Hyde" group.
> To post to this group, send email to hyde...@googlegroups.com.
> To unsubscribe from this group, send email to hyde-dev+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/hyde-dev?hl=en.
>

Vincent Bernat

unread,
May 16, 2011, 1:28:27 AM5/16/11
to hyde...@googlegroups.com
OoO En cette fin de nuit blanche du lundi 16 mai 2011, vers 06:44,
Lakshmi Vyas <lakshm...@gmail.com> disait :

> There is a thumbnail implementation right here that can be ported pretty much as is:
> https://github.com/lakshmivyas/hyde/blob/master/hydeengine/media_processors.py#L264-287

I think that thumbnails should be added to the list of resources to be
processed later by other plugins. Since this would be resources that do
not exist in content path (only in deploy path), do you think this could
cause problem?
--
Make sure comments and code agree.

Lakshmi Vyas

unread,
May 16, 2011, 1:34:28 AM5/16/11
to hyde...@googlegroups.com
> I think that thumbnails should be added to the list of resources to be
> processed later by other plugins

Since they are generated files it is better for them not to be in the list of resources.

If there is additional processing required, the thumbnail plugin should provide options for them.

The only additional processing I can think of is compression. But compression should be included by
default in thumbnail generation I think.

=======

If there definitely is a need for them to be added to the list of resources, they should be generated inside the source
area in `begin_site` event - in that case they can be safely added to the list of resources.


HTH
Lakshmi

Vincent Bernat

unread,
May 16, 2011, 1:57:14 AM5/16/11
to hyde...@googlegroups.com
OoO En cette aube naissante du lundi 16 mai 2011, vers 07:34, Lakshmi
Vyas <lakshm...@gmail.com> disait :

> Since they are generated files it is better for them not to be in the
> list of resources.

> If there is additional processing required, the thumbnail plugin
> should provide options for them.

> The only additional processing I can think of is compression. But
> compression should be included by default in thumbnail generation I
> think.

I was thinking about image sizer plugin but the thumbnail plugin could
directly provide height and width.
--
BOFH excuse #170:
popper unable to process jumbo kernel

Vincent Bernat

unread,
May 24, 2011, 6:11:01 PM5/24/11
to hyde...@googlegroups.com
OoO En cette aube naissante du lundi 16 mai 2011, vers 07:34, Lakshmi
Vyas <lakshm...@gmail.com> disait :

>> I think that thumbnails should be added to the list of resources to be


>> processed later by other plugins

> Since they are generated files it is better for them not to be in the
> list of resources.

Well, I have done something.
https://github.com/vincentbernat/hyde/tree/thumbnail-plugin
https://github.com/vincentbernat/hyde/commit/478a783274546a7c95cc6a653116ad2d9c4b38dd

I was a bit lost when I wrote this. I wanted to return some kind of
resource and to be able to make it depends on the original resource to
allow it to be regenerated if the original changed. I also find the way
to write the thumb into its target directory a bit hacky. Moreover, it
does not check if a thumbnail exists before retrying to create
one. Again, a resource would do the work for me.

I use it like this:

{% macro gallery(directory) %}
<div class="gallery">
{% for image in site.content.walk_resources()
if image.source_file.kind in ("jpg","png") and
(image.name.startswith(directory) or image.source_file.parent.name == directory) %}
{% set thumb = image.thumb(height=150) %}
<a href="/{{ image.get_relative_deploy_path() }}"><img src="/{{ thumb }}" height="{{ thumb.height }}" width="{{ thumb.width }}"></a>
{% endfor %}
</div>
{% endmacro %}

And this is again something that I don't like. I would like to pass
everything in media_url function but I did not succeed in getting the
paths right...

I have not quite finished my example of use. I will post it when it is done.
--
Vincent Bernat ☯ http://www.luffy.cx

Each module should do one thing well.

Vincent Bernat

unread,
May 26, 2011, 6:07:44 PM5/26/11
to hyde...@googlegroups.com
OoO En cette nuit nuageuse du mercredi 25 mai 2011, vers 00:11, je
disais:

>>> I think that thumbnails should be added to the list of resources to be
>>> processed later by other plugins

>> Since they are generated files it is better for them not to be in the
>> list of resources.

Here is an example of use:
http://www.luffy.cx/en/blog/2011-thinkpad-edge-11.html
https://github.com/vincentbernat/www.luffy.cx/tree/master/content/en/blog/2011-thinkpad-edge-11.html

--
Vincent Bernat ☯ http://www.luffy.cx

Write clearly - don't be too clever.

Lakshmi

unread,
Jun 19, 2011, 1:45:14 AM6/19/11
to hyde...@googlegroups.com
Hi Vincent,

How about this:

A.  The plugin operates in begin site
B.  It checks for the existence of the thumbnail (as a resource)
C.  It checks if the resource is older than the thumbnail
D. If B or C return false, it generates the thumbnail in the source area
E. It informs the site of the newly generated thumbnail (it gets added as a resource if it does not exist)
F. The plugin also regenerates the thumbnail in binary_resource_complete if needed

Would this solve the problems?

Vincent Bernat

unread,
Jun 19, 2011, 5:12:37 AM6/19/11
to hyde...@googlegroups.com
OoO En cette aube naissante du dimanche 19 juin 2011, vers 07:45,
Lakshmi <lakshm...@gmail.com> disait :

> How about this:

So, all images will be thumbnailed?


--
Vincent Bernat ☯ http://www.luffy.cx

panic("CPU too expensive - making holiday in the ANDES!");
2.2.16 /usr/src/linux/arch/mips/kernel/traps.c

Lakshmi Vyas

unread,
Jun 19, 2011, 5:17:09 AM6/19/11
to hyde...@googlegroups.com
Only the ones that are configured for thumbnailing .

Example:
=======


In site.yaml:

thumbnail:
include:
- 'media/images/gallery/*.png'
- 'media/images/gallery/*.jpg'
- 'media/images/slideshow/*.png'
other_settings:
-...

or using meta data:


meta.yaml:


thumbnails:
generate: true
include:
- *.png

Thanks
Lakshmi

Vincent Bernat

unread,
Jun 19, 2011, 5:29:15 AM6/19/11
to hyde...@googlegroups.com
OoO En cette fin de matinée radieuse du dimanche 19 juin 2011, vers
11:17, Lakshmi Vyas <lakshm...@gmail.com> disait :

> Only the ones that are configured for thumbnailing .

OK. What is the best way to add a file as a new resource?

> Example:
> =======


> In site.yaml:

> or using meta data:


> meta.yaml:

> Thanks
> Lakshmi

Don't over-comment.

Lakshmi Vyas

unread,
Jun 19, 2011, 5:32:44 AM6/19/11
to hyde...@googlegroups.com
> OK. What is the best way to add a file as a new resource?

site.content.add_resource(File(path))

Grygoriy Fuchedzhy

unread,
Aug 23, 2011, 5:34:38 PM8/23/11
to hyde...@googlegroups.com
On Sun, Jun 19, 2011 at 02:47:09PM +0530, Lakshmi Vyas wrote:
> Only the ones that are configured for thumbnailing .
>
> Example:
> =======
>
>
> In site.yaml:
>
> thumbnail:
> include:
> - 'media/images/gallery/*.png'
> - 'media/images/gallery/*.jpg'
> - 'media/images/slideshow/*.png'
> other_settings:
> -...
>
>
> or using meta data:
>
>
> meta.yaml:
>
>
> thumbnails:
> generate: true
> include:
> - *.png
>

I've looked into thumbnails plugin written by Vincent Bernat, and rewrote it in
the way you proposed.

Now you can set optional default values for thumbnailing options in site.yaml:
thumbnails:
width: 100
height: 120
prefix: thumb_

And then define actual images to thumbnail using meta plugin, for example in
nodemeta.yaml:
thumbnails:
- width: 50
prefix: thumbs1_
include:
- '*.png'
- '*.jpg'

Notice that thumbnails in the metadata is a list of option sets, this way you
can make thumbnails with different sizes from different images or several
thumbnails from single image, for example:
thumbnails:
- width: 50
prefix: thumbs1_
include:
- '*.png'
- '*.jpg'
- height: 100
prefix: thumbs2_
include:
- '*.png'
- '*.jpg'
which means - make from every picture two thumbnails with different prefixes and
sizes

Can anyone see any issues with this? Should I create pull-request for this?

--
Grygoriy Fuchedzhy

Grygoriy Fuchedzhy

unread,
Aug 23, 2011, 5:37:06 PM8/23/11
to hyde...@googlegroups.com
I've forgot to add a link to implementation:
https://github.com/gfuchedzhy/hyde/commit/d0bfc4f78478790e7a99be812069b76261a1f38f

--
Grygoriy Fuchedzhy

Reply all
Reply to author
Forward
0 new messages