Merge branch 'flex-grow' of git://github.com/QSchulz/prosopopee into QSchulz-flex-grow

This commit is contained in:
Adrien Beudin 2019-09-25 13:40:44 +02:00
commit 86be23bc82
3 changed files with 43 additions and 16 deletions

View File

@ -16,6 +16,7 @@ Options:
import os
import shutil
import socketserver
import subprocess
import http.server
import ruamel.yaml as yaml
@ -139,6 +140,17 @@ class Video(object):
return thumbnail_name
@property
def ratio(self):
if self.options["binary"] == "ffmpeg":
binary = "ffprobe"
else:
binary = "avprobe"
command = binary + " -v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 " + self.base_dir.joinpath(self.name)
out = subprocess.check_output(command.split())
width,height = out.split(',')
return float(width) / int(height)
def __repr__(self):
return self.name
@ -266,6 +278,13 @@ class Image(object):
return thumbnail_name
@property
def ratio(self):
command = "gm identify -format %w,%h " + self.base_dir.joinpath(self.name)
out = subprocess.check_output(command.split())
width,height = out.split(',')
return float(width) / int(height)
def __repr__(self):
return self.name

View File

@ -5,12 +5,19 @@
{% for line in section.images %}
<div class="pictures-line">
{% for image in line %}
<div class="picture caption">
{% set caption = image.text %}
{% if image.type == "video" %}
{% set video = Video(image) %}
{% set format = settings.ffmpeg.extension %}
{{ video.copy() }}
{% set ratio = video.ratio %}
{% else %}
{% set image = Image(image) %}
{{ image.copy() }}
{% set ratio = image.ratio %}
{% endif %}
<div class="picture caption" style="flex-grow: {{ ratio }}">
{% if image.type == "video" %}
{% set caption = image.text %}
{% set video = Video(image) %}
{% set format = settings.ffmpeg.extension %}
{{ video.copy() }}
<img class="lazy" data-original="{{ video.generate_thumbnail("600") }}" src="" alt="">
<video class="lazy responsive-video" id="{{ video }}" onclick="goFullscreen('{{ video }}');" poster="{{ video.generate_thumbnail("600") }}" alt="" autoplay="autoplay" loop="loop" preload="auto" muted>
<source src="{{ video }}.{{ format }}" type="video/{{ format }}">
@ -21,9 +28,6 @@
</div>
{% endif %}
{% else %}
{% set caption = image.text %}
{% set image = Image(image) %}
{{ image.copy() }}
<a href="{{ image }}" {% if caption %}data-caption="{{ caption }}"{% endif %}
data-at-450="{{ image.generate_thumbnail("x450") }}"
data-at-800="{{ image.generate_thumbnail("x800") }}"

View File

@ -5,12 +5,19 @@
{% for line in section.images %}
<div class="pictures-line">
{% for image in line %}
<div class="picture caption">
{% set caption = image.text %}
{% if image.type == "video" %}
{% set video = Video(image) %}
{% set format = settings.ffmpeg.extension %}
{{ video.copy() }}
{% set ratio = video.ratio %}
{% else %}
{% set image = Image(image) %}
{{ image.copy() }}
{% set ratio = image.ratio %}
{% endif %}
<div class="picture caption" style="flex-grow: {{ ratio }}">
{% if image.type == "video" %}
{% set caption = image.text %}
{% set video = Video(image) %}
{% set format = settings.ffmpeg.extension %}
{{ video.copy() }}
<img class="z-depth-2 lazy responsive-img" data-original="{{ video.generate_thumbnail("600") }}" src="" alt="">
<video class="lazy responsive-video" id="{{ video }}" onclick="goFullscreen('{{ video }}');" poster="{{ video.generate_thumbnail("600") }}" alt="" autoplay="autoplay" loop="loop" preload="auto" muted>
<source src="{{ video }}.{{ format }}" type="video/{{ format }}">
@ -21,9 +28,6 @@
</div>
{% endif %}
{% else %}
{% set caption = image.text %}
{% set image = Image(image) %}
{{ image.copy() }}
<a href="{{ image }}" {% if caption %}data-caption="{{ caption }}"{% endif %}
data-at-450="{{ image.generate_thumbnail("x450") }}"
data-at-800="{{ image.generate_thumbnail("x800") }}"