Code Monkey home page Code Monkey logo

hugophotoswipe's Introduction

Hi there! πŸ‘‹

  • πŸ’‘ My name is Gertjan van den Burg1

  • 🌱 I'm a Machine Learning researcher based in London, UK.

  • πŸ“š My research spans generative models, time series analysis, automated data wrangling, supervised learning and more!

  • 🌊 I'm passionate about making my research accessible (1, 2, 3, 4) and reproducible (1, 2, 3, 4).

  • 🎨 In my spare time I enjoy writing open-source software and usually code in Python.

  • πŸ“« You can find me:

1 "Gertjan" is not so easy to pronounce unless you know Dutch, so I also respond to Gerrit, which is pronounced like this.

hugophotoswipe's People

Contributors

couldbethis avatar eloo avatar fazalmajid avatar gjjvdburg avatar halogenica avatar sebastiaan-lampo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hugophotoswipe's Issues

ImportError: cannot import name indent

Python 2.7.13
pip 9.0.1

I keep getting this error when I run hps init:

  File "/usr/local/bin/hps", line 11, in <module>
    from hugophotoswipe.ui import main
  File "/usr/local/lib/python2.7/site-packages/hugophotoswipe/ui.py", line 14, in <module>
    from .hugophotoswipe import HugoPhotoSwipe
  File "/usr/local/lib/python2.7/site-packages/hugophotoswipe/hugophotoswipe.py", line 14, in <module>
    from .album import Album
  File "/usr/local/lib/python2.7/site-packages/hugophotoswipe/album.py", line 19, in <module>
    from .photo import Photo
  File "/usr/local/lib/python2.7/site-packages/hugophotoswipe/photo.py", line 18, in <module>
    from textwrap import wrap, indent
ImportError: cannot import name indent 

If I remove indent from from textwrap import wrap, indent I get this error:

Traceback (most recent call last):
  File "/usr/local/bin/hps", line 12, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/site-packages/hugophotoswipe/ui.py", line 19, in main
    hps = HugoPhotoSwipe()
  File "/usr/local/lib/python2.7/site-packages/hugophotoswipe/hugophotoswipe.py", line 24, in __init__
    self._albums = self._load_albums()
  File "/usr/local/lib/python2.7/site-packages/hugophotoswipe/hugophotoswipe.py", line 92, in _load_albums
    local_objects = os.listdir()
TypeError: listdir() takes exactly 1 argument (0 given)

layouts/index.html in small windows

Hi, in the file layouts/index.html as described in the wiki, there is a problem with the CSS. I was driving myself nuts trying to figure out where all the content was going.. been a long time since I did much web design so I guess my troubleshooting skills are a wee bit rusty. But finally I cracked it.

In a small viewport it appears blank/broken. I tile my windows to be narrow.

This is how it displays at ~800px (and in some iterations, was a totally blank page):
withCSS

Now I have noticed that if you make the window >1300px wide, it will display correctly:

withCSS-wide

However by changing this line:

<main class="container" style="margin-left: calc((100vw - 2*600px - 2*40px)/2);margin-right: auto;">

to this (removing the hardcoded style)

<main class="container">

Now it's like this even at 800px:

withoutCSS

Don't mind the emojis they were helping me troubleshoot. :)

The CSS is over my head so I can't fix it any better than that unfortunately.

thank you for the repo, very helpful.

On a Mac with Firefox 94 and also looked in safari v 15.1 with same result.

Photoswipe not defined

Hi again,

Moving forward in integrating hps in my theme, I stumbled upon an error in the javascript file:

Uncaught ReferenceError: PhotoSwipe is not defined
    at openPhotoSwipe (pswp_gallery.js:197)
    at initPhotoSwipeFromDOM (pswp_gallery.js:273)
    at pswp_gallery.js:278

I can see that PhotoSwipe is not defined in pswp_gallery.js. I followed the rest of the wiki to the letter.

Any ideas?

catkfr

AttributeError: 'NoneType' object has no attribute 'items'

Thanks for the help with #1, and thank you for building this script!

I am now able to run hps init and hps new. I have configured my YAML file to point to my Hugo site directory:

---
album_file: album.yml
cover_filename: coverimage.jpg
dim_coverimage: 600
dim_max_large: 1600
dim_max_small: 800
dim_thumbnail: 256
dirname_large: large
dirname_small: small
dirname_thumb: thumb
markdown_dir: /Users/iammatthias/Sites/Hugo/com/content/gal
output_dir: /Users/iammatthias/Sites/Hugo/com/src/images
output_format: jpg
photo_dir: photos
smartcrop_js_path:
url_prefix:
use_smartcrop_js: False

and now I'm getting this issue when I run hps update:

Traceback (most recent call last):
  File "/usr/local/bin/hps", line 12, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/site-packages/hugophotoswipe/ui.py", line 23, in main
    hps.update(name=album)
  File "/usr/local/lib/python2.7/site-packages/hugophotoswipe/hugophotoswipe.py", line 58, in update
    album.update()
  File "/usr/local/lib/python2.7/site-packages/hugophotoswipe/album.py", line 252, in update
    self.create_markdown()
  File "/usr/local/lib/python2.7/site-packages/hugophotoswipe/album.py", line 115, in create_markdown
    proptxt = ["%s = \"%s\"" % (k, v) for k, v in self.properties.items()]
AttributeError: 'NoneType' object has no attribute 'items'

I get the same error when I try to run the scrip with Python 3:

Traceback (most recent call last):
  File "/usr/local/bin/hps", line 12, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/site-packages/hugophotoswipe/ui.py", line 23, in main
    hps.update(name=album)
  File "/usr/local/lib/python3.6/site-packages/hugophotoswipe/hugophotoswipe.py", line 58, in update
    album.update()
  File "/usr/local/lib/python3.6/site-packages/hugophotoswipe/album.py", line 252, in update
    self.create_markdown()
  File "/usr/local/lib/python3.6/site-packages/hugophotoswipe/album.py", line 115, in create_markdown
    proptxt = ["%s = \"%s\"" % (k, v) for k, v in self.properties.items()]
AttributeError: 'NoneType' object has no attribute 'items'

Making HPS work directly from catalog software to Hugo

Thanks for the great work you've done on HPS and for considering my PR's Gertjan! I'm using it to migrate a 1000+ photo website from piwigo to hugo.

My vision is to use HPS as part of a continuous integration workflow where it gets triggered after exporting photos from DigiKam (photo catalog). Thus, the goal is to have as much information be used from the photo files as possible. Then I can avoid having to edit the album yml files. To that end, my roadmap includes the following features as well as the two PR's I've already submitted. If you are interested in including any of those as well then I'll gladly make a PR including those changes you like.

Feature / change list

  • Allow for photos_dir to be "" or None. -- done
  • Allow for albums to be nested -- done
  • Allow for "non-photo directory" in _load_albums to be automatically added as an album
  • Allow for tags to have priority over album.yml file (or to drop items such as caption / alt from the yml template so that it falls back on the tags)

To solve: integrating album-level content. I rarely do this but sometimes it's nice to add context to an album with text or links. I haven't figured out yet if the album.yml or the markdown output would be the right spot to add it. Either way, it would require some way of integrating that information without HPS overriding it in the next update.

`hps init` failing if not run in clean directory

Just a small idea for improvement: from the usage instructions it was not clear to me that hps init needs to be ran in a new directory:

First, initialize a new HugoPhotoSwipe directory with: hps init

This sounds like the hps init command will initialize the new directory for me. So when I ran hps init in an existing Hugo repo the command failed.

Perhaps it would be a good idea for the init script to check if it is being ran in a clean directory and if not, return an error to the user?

NameError: name *** is not defined

I'm getting an error when trying to set up a new (initial) album.

I've followed the install steps exactly (though I'm unsure about where the photos markdown and output directories should live within the hugo structure, but nonetheless...) and am now on the create new album step. Here is what I am using on the command line, under root/hugophotos:

hugophotos git:(master) βœ— hps new
Please provide a name for the new album: photos-work
Traceback (most recent call last):
  File "/usr/local/bin/hps", line 12, in <module>
    sys.exit(main())
  File "/Library/Python/2.7/site-packages/hugophotoswipe/ui.py", line 38, in main
    hps.new(name=album)
  File "/Library/Python/2.7/site-packages/hugophotoswipe/hugophotoswipe.py", line 40, in new
    name = input("Please provide a name for the new album: ")
  File "<string>", line 1, in <module>
NameError: name 'photos' is not defined

Any idea what i may be doing wrong here? I haven't seen anyone else with the same issue so it's most likely my fault or my environment. I've also tried shorter names for the album like "work".

Allow for any number of output sizes

Currently, HugoPhotoSwipe allows for three output sizes: large, small, and thumbnail. Additionally it supports the coverimage output using the cover output size. A feature idea I had was to generalize this to allow users to specify more different sizes. This would change the configuation from the current form (v0.0.15):

dim_max_cover: 600x600
dim_max_large: 1200
dim_max_small: 600
dim_max_thumb: 256x256
dirname_large: large
dirname_small: small
dirname_thumb: thumb

to something like this:

sizes:
  large:
    max_dim: '1600'
    use_smartcrop: false
  small:
    max_dim: '800'
    use_smartcrop: false
  thumb:
    max_dim: '256x256'
    use_smartcrop: true
  cover:
    max_dim: '600x600'
    use_smartcrop: true

In this setup, cover would have a special role, but for all the other sizes the name of the size will correspond to the old dirname_ setting, and there is the added option of using smartcrop for other sizes too. Additional sizes can be added by adding an item under the sizes setting. This could allow users to add other sizes for their specific website design, such as a super size for downloading a really large version of the image for instance. A side benefit for this setup is that it would simplify the code of HugoPhotoSwipe.

Is this a feature that you find interesting and useful? If so, leave a πŸ‘ reaction to this issue

Ideas on how it could be implemented differently? Let me know below!

Suggestion for image size detection

Hello again!

Since Hugo 0.19 there is a new imageConfig function to detect an image's size.

Maybe you want to integrate it with HugoSwipe since imageConfig is native to Hugo.

Here is an example shortcode that works for me:

    <figure>
    {{ $src := .Get "src" }}
    {{ $config := imageConfig (printf "/static/%s" $src) }}
    <img src="{{ $.Page.Site.BaseURL }}{{ .Get "src" }}" alt="{{ .Get "title" }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt"}}{{.}}{{else}}{{ .Get "caption" }}{{ end }}"{{ end }} height="{{$config.Height}}" width="{{$config.Width}}" />
    </figure>

And on each markdown I use it like so:

`{{< img src="PATH TO IMAGE" title="Lorem Ipsum">}}`

minor edits to wiki

Hi, While I was reading your wiki I made some minor edits basically for legibility. But it seems there is actually no way to make a PR for a wiki. So if you want, here is a zip of the file + .git with commit history. Sorry not sure if there is a better way?

HugoPhotoSwipe.wiki.zip

Summary of changes:

  • $ from the beginning of code blocks where they were there by mistake
  • changed lists of files to be vertical instead of horizontal (easier to read) or used tree to display complete structure.
    • I assume in the section about copying files from PhotoSwipe repo you intended for the image files to be included along with CSS and JS so that's what is written
  • made one tiny content change in "Adding our first album" to clarify something that tripped me up.

(I did not make any change to reflect #37 because I don't know if my solution is very good.)

If updating this way is too much of a PITA then just close/ignore, you won't hurt my feelings. Just that I'd already done it the work.

Sort order

Hi.

I would like to define the sort order of images, since all my images have a caption that contains a number and I'd like to have them in order.
Right now it orders by file name, which would require me to rename all files.

Is there a way to configure this somehow?

Error on First Run (Ubuntu 16.04/Python 2.7.12)

After a trouble-free install follwing the recommended procedure, running hps with any argument (or none) results in:

  File "/usr/local/bin/hps", line 11, in <module>
    from hugophotoswipe.ui import main
  File "/usr/local/lib/python2.7/dist-packages/hugophotoswipe/ui.py", line 19, in <module>
    from .hugophotoswipe import HugoPhotoSwipe
  File "/usr/local/lib/python2.7/dist-packages/hugophotoswipe/hugophotoswipe.py", line 19, in <module>
    from .album import Album
  File "/usr/local/lib/python2.7/dist-packages/hugophotoswipe/album.py", line 22, in <module>
    from .conf import settings
  File "/usr/local/lib/python2.7/dist-packages/hugophotoswipe/conf.py", line 132, in <module>
    settings = load_settings()
  File "/usr/local/lib/python2.7/dist-packages/hugophotoswipe/conf.py", line 129, in load_settings
    return Settings(**data)
TypeError: type object argument after ** must be a mapping, not NoneType```

Suggestions please as to why this is falling apart even before doing an "init" as Python is not my thing.  This is Python 2.7.12.

Dependency issue?

Hi! First off, thanks a lot for this. I successfully installed HugoPhotoSwipe on my laptop, then successfully used it on a website I developed using Hugo.

I now tried to install on my desktop as per the wiki instructions and got this:

minilek@minilek:~$ pip install --process-dependency-links hugophotoswipe
Collecting hugophotoswipe
Collecting tzlocal (from hugophotoswipe)
Collecting tqdm (from hugophotoswipe)
  Using cached tqdm-4.19.6-py2.py3-none-any.whl
Requirement already satisfied: pytz in /usr/lib/python2.7/dist-packages (from hugophotoswipe)
Collecting smartcrop>=0.1 (from hugophotoswipe)
  Could not find a version that satisfies the requirement smartcrop>=0.1 (from hugophotoswipe) (from versions: )
No matching distribution found for smartcrop>=0.1 (from hugophotoswipe)

Do you know why this might be happening? (Warning: I'm a noob and this is probably not an issue with your package at all but is only related to my own incompetence.) I noticed hugophotoswipe depends on tqdm, so I tried installing that as well but also run into a problem:

minilek@minilek:~$ pip install tqdm
Collecting tqdm
  Using cached tqdm-4.19.6-py2.py3-none-any.whl
Installing collected packages: tqdm
Exception:
Traceback (most recent call last):
  File "/home/minilek/.local/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/home/minilek/.local/lib/python2.7/site-packages/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/home/minilek/.local/lib/python2.7/site-packages/pip/req/req_set.py", line 784, in install
    **kwargs
  File "/home/minilek/.local/lib/python2.7/site-packages/pip/req/req_install.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/home/minilek/.local/lib/python2.7/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,
  File "/home/minilek/.local/lib/python2.7/site-packages/pip/wheel.py", line 345, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/home/minilek/.local/lib/python2.7/site-packages/pip/wheel.py", line 316, in clobber
    ensure_dir(destdir)
  File "/home/minilek/.local/lib/python2.7/site-packages/pip/utils/__init__.py", line 83, in ensure_dir
    os.makedirs(path)
  File "/usr/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/tqdm-4.19.6.dist-info'

Demo broken

Demo website broken, at least it does not look like what I expected, it is just a website with a list of images, no gallery... wait, quick screenshot added...

image

Documentation improvements

Hi,

I really want to make HPS work on my system: it's exactly what I want! Thanks for building it.

I'm having difficulties trying HPS out. I feel some clarifications in the documentation could help.

In particular, having a complete example of a proper working hugophotoswipe.yml would be very helpful in my clumsy attempts to guess the proper way to set each variable.

We solved the issues for dependencies (previous issue): thanks.

I have hps installed in a virtualenv and am trying to create a first gallery. For the moment, I just want to see a result and defined nothing in the url_prefix: of the hugophotoswipe.yml

This generates an error when running hps update:

Traceback (most recent call last):
  File "hps8/bin/hps", line 12, in <module>
    sys.exit(main())
  File "hps8/lib/python3.6/site-packages/hugophotoswipe/ui.py", line 23, in main
    hps.update(name=album)
  File "hps8/lib/python3.6/site-packages/hugophotoswipe/hugophotoswipe.py", line 58, in update
    album.update()
  File "hps8/lib/python3.6/site-packages/hugophotoswipe/album.py", line 256, in update
    self.create_markdown()
  File "hps8/lib/python3.6/site-packages/hugophotoswipe/album.py", line 132, in create_markdown
    txt.append(photo.shortcode)
  File "hps8/lib/python3.6/site-packages/hugophotoswipe/photo.py", line 326, in shortcode
    self.large_path[len(settings.output_dir):])
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

Then it was issues with directory naming. To test, I had specified:

markdown_dir: md
output_dir: output
photo_dir: photos

Those didn't work either causing a crash (because no backslash at the end?). I now imagine that it would be better to specify complete paths...

I also stumbled on smartcrop.js configuration. First I want to manage to successfully create a gallery but once again, a short clarification in the documentation (to install smartcrop.js then configure the .yml file) for newbies such as myself would be a great help.

Looking ahead, I wonder what you recommend in terms of including this in a hugo website.

  • Should the output be set in the static directory? Is this a pre-requisite given your choice to use "url-prefix"?
  • Should the md directory be somewhere in the content folder? I think for my personal site, I'll have content/post and content/gallery to have two separate categories created by hugo. How do you do it?
  • I also took a look in the docs/readme.md. Given my current proficiency with hugo, I don't understand what I need to do. I think you suggest to create two files in the layout/shortcodes directory, a javascript file. If these files should be used as is, why not just create these files somewhere in the HPS repository and in the documentation just tell us where we should put them?
  • Concerning the Photoswipe HTML block, I don't understand what I should do with it? Create a file? include it in a pre-existing file?

I imagine these questions may seem quite trivial to you, but for me, they are not. I hope these comments will help you make this package more newbie-friendly and enjoy a wider user base.

Regards,

catkfr

error doing `hps update`

The photos folder contain iPhone images (I removed MOV files since these caused problems):

> hps update
[2023-09-10 18:06:06] - Skipping non-album directory: resources
[2023-09-10 18:06:06] - Skipping non-album directory: themes
[2023-09-10 18:06:06] - Skipping non-album directory: content
[2023-09-10 18:06:06] - Skipping non-album directory: archetypes
[2023-09-10 18:06:06] - Skipping non-album directory: static
[2023-09-10 18:06:06] - Skipping non-album directory: public
[2023-09-10 18:06:06] - Skipping non-album directory: git
[2023-09-10 18:06:06] - Skipping non-album directory: layouts
[2023-09-10 18:06:06] - Skipping non-album directory: data
Updating album: tOKvdGhp
[2023-09-10 18:06:07] - [2023-07-29_18-10-50.JPG] Scaling up image from (1119, 920) to (1600, 1315). Scaling up may not be desirable.
[2023-09-10 18:06:09] - [2023-08-23_16-53-16.JPG] Scaling up image from (1200, 824) to (1600, 1099). Scaling up may not be desirable.
[2023-09-10 18:06:09] - [2023-08-23_16-53-25.JPG] Scaling up image from (1200, 824) to (1600, 1099). Scaling up may not be desirable.
[2023-09-10 18:06:09] - [2023-08-23_17-05-53.JPG] Scaling up image from (1150, 751) to (1600, 1045). Scaling up may not be desirable.
[2023-09-10 18:06:09] - [2023-08-23_17-06-42.JPG] Scaling up image from (1170, 763) to (1600, 1043). Scaling up may not be desirable.
Traceback (most recent call last):
  File "/home/me/.local/bin/hps", line 8, in <module>
    sys.exit(main())
  File "/home/me/.local/lib/python3.10/site-packages/hugophotoswipe/__main__.py", line 13, in main
    sys.exit(realmain())
  File "/home/me/.local/lib/python3.10/site-packages/hugophotoswipe/ui.py", line 50, in main
    hps.update(name=album)
  File "/home/me/.local/lib/python3.10/site-packages/hugophotoswipe/hugophotoswipe.py", line 55, in update
    self.update_all() if name is None else self.update_single(name)
  File "/home/me/.local/lib/python3.10/site-packages/hugophotoswipe/hugophotoswipe.py", line 60, in update_all
    album.update()
  File "/home/me/.local/lib/python3.10/site-packages/hugophotoswipe/album.py", line 340, in update
    photo.create_sizes()
  File "/home/me/.local/lib/python3.10/site-packages/hugophotoswipe/photo.py", line 141, in create_sizes
    self.create_thumb(mode="thumb", pth=self.thumb_path)
  File "/home/me/.local/lib/python3.10/site-packages/hugophotoswipe/photo.py", line 177, in create_thumb
    return self.create_thumb_py(mode=mode, pth=pth)
  File "/home/me/.local/lib/python3.10/site-packages/hugophotoswipe/photo.py", line 209, in create_thumb_py
    ret = sc.crop(img, crop_width, crop_height)
  File "/home/me/.local/lib/python3.10/site-packages/smartcrop/library.py", line 158, in crop
    Image.Resampling.LANCZOS)
  File "/usr/lib/python3/dist-packages/PIL/Image.py", line 65, in __getattr__
    raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
AttributeError: module 'PIL.Image' has no attribute 'Resampling'

Dependencies

Hi,

I wasn't able to install hps without a prior installation of smartcrop. Maybe the readme could be amended:

This works within a clean virtualenv:

bin/pip install --upgrade git+https://github.com/hhatto/smartcrop.py.git
bin/pip install hugophotoswipe

This is the output from trying to install hps in a clean virtualenv:

bin/pip install hugophotoswipe
Collecting hugophotoswipe
  Downloading hugophotoswipe-0.0.7.tar.gz
Collecting six (from hugophotoswipe)
  Downloading six-1.10.0-py2.py3-none-any.whl
Collecting tzlocal (from hugophotoswipe)
  Downloading tzlocal-1.3.tar.gz
Collecting pytz (from hugophotoswipe)
  Downloading pytz-2016.10-py2.py3-none-any.whl (483kB)
Collecting smartcrop>=0.1 (from hugophotoswipe)
  Could not find a version that satisfies the requirement smartcrop>=0.1 (from hugophotoswipe) (from versions: )
No matching distribution found for smartcrop>=0.1 (from hugophotoswipe)

Regards,

catkfr

Error while running hps update

Hello I just upgraded to HugoPhotoswipe 0.0.15 and when I ran hps update I got the following

Traceback (most recent call last):
  File "/usr/local/bin/hps", line 12, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/hugophotoswipe/ui.py", line 36, in main
    hps.update(name=album)
  File "/usr/local/lib/python2.7/dist-packages/hugophotoswipe/hugophotoswipe.py", line 56, in update
    album.update()
  File "/usr/local/lib/python2.7/dist-packages/hugophotoswipe/album.py", line 276, in update
    photo.create_sizes()
  File "/usr/local/lib/python2.7/dist-packages/hugophotoswipe/photo.py", line 120, in create_sizes
    self.create_rescaled('large')
  File "/usr/local/lib/python2.7/dist-packages/hugophotoswipe/photo.py", line 138, in create_rescaled
    nimg = self.original_image.resize((nwidth, nheight), Image.ANTIALIAS)
  File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 1645, in resize
    return self._new(self.im.resize(size, resample))
TypeError: integer argument expected, got float

The contents of hugophotoswipe.yml are the following:

album_file: album.yml
cover_filename: coverimage.jpg
dim_max_cover: 600x600
dim_max_large: 1280
dim_max_small: 1024
dim_max_thumb: 256x256
dirname_large: large
dirname_small: small
dirname_thumb: thumb
jpeg_optimize: True
jpeg_progressive: False
jpeg_quality: 75
markdown_dir: /home/alex/hps/md
output_dir: /home/alex/hps/out
output_format: jpg
photo_dir: images
smartcrop_js_path:
url_prefix:
use_smartcrop_js: False

Any pointers?

EDIT
As HugoPhotoSwipe is crucial for my work flow I have downgraded to version 0.0.14 for now.

I've looked around the web for this error. And it seems that something is wrong with the way the images are resized.

Preserve thumbnail aspect ratio?

Is there a way to change the thumbnail aspect ratio? I'd like to preserve the aspect ratio of the original image for a visually interesting grid.

Suggestions to help integrate in a theme

Hi again,

For future reference if someone wants to include hps in casper theme. The current casper theme supposes that all posts are in the "post" section. Therefore, I needed to create galleries in /content/post/galleries. In order to handle the differences in html file, I chose to add a "gallery" tag and then use the following approach: e.g. in footer.html:

    <!-- photoswipe -->
  {{ if in .Params.tags "gallery" }}
    <script type="application/javascript" src="{{ .Site.BaseURL }}js/photoswipe.min.js"></script>
    <script type="application/javascript" src="{{ .Site.BaseURL }}js/photoswipe-ui-default.min.js"></script>
    <script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
  {{ end }}

I had planned to add the "gallery" tag to my posts anyway so this works fine for me.

What I would like is for hps to handle the setting of custom lines in the TOML front matter or even a short description (for a nicer front page).
Today, hps provides a .md file that I can modify to my liking. But running hps update rewrites the .md gallery file (even if there are no modifications to the gallery file) and I have to start over.

catkfr

Request: Ability to set image width instead of max dimension

Again thank you for the great script. It's a super time saver and I really appreciate it.

But is there a way to set the width instead of the max dimension on image resize?

For example when I set dim_max_large to 1920 in hugophotoswipe.yml I would like it to output images that are 1920 px wide.

output gallery data to data file instead of content

Great job with this. I'd be interested in everything here except outputting the image galleries to their content files. By outputting the hps udpate result to a hugo data file I'd be free to pipe that data through a shortcode that I could embed in the body of any content file (like a blog post) and use my own HTML/UI.

I'm currently using a go function to get the filenames from a directory I specify and looping over them. I'll probably try to do the same with your tool but point to the output directories and files generated.

local Demo not working

first, sorry for bothering here, but I'm a hugo beginner and tried to get this working.
having completed all steps from the tutorial (and changed baseurl = "http://localhost" in config.toml) I get this:

ERROR 2024/02/19 10:46:17 render of "page" failed: "/home/josswern/docker/hugo/src/hps_example/layouts/galleries/single.html:7:15": execute of template failed: template: galleries/single.html:7:15: executing "galleries/single.html" at <.URL>: can't evaluate field URL in type *hugolib.pageState Error: Error building site: failed to render pages: render of "page" failed: "/home/josswern/docker/hugo/src/hps_example/layouts/galleries/single.html:7:15": execute of template failed: template: galleries/single.html:7:15: executing "galleries/single.html" at <.URL>: can't evaluate field URL in type *hugolib.pageState

when trying to run the demo with hugo -w server
any hints how to solve this ?

Very slow performance

I decided to try the galery generation and the performance is let's say less than slowish.

The setup is as follows:

  • Python - 2.7.3
  • HugoPhotoSwipe - 0.0.12 (installed from pip)
  • hugophotoswipe.yml (attached). It is default with just markdown_dir and output_dir set.
    hugophotoswipe.txt
  • Single album
  • Album has 37 640x480 images

Performance is ... not good

37/37 [13:40<00:00, 22.17s/it]

Strace shows nothing usable. No verbose mode available so no idea what is happening on the inside.

$ pip freeze
Pillow==4.0.0
PyYAML==3.12
argparse==1.2.1
distribute==0.6.24
hugophotoswipe==0.0.12
olefile==0.44
pytz==2016.10
six==1.10.0
smartcrop==0.1
tqdm==4.11.2
tzlocal==1.3
wsgiref==0.1.2

Setting up HugoPhotoSwipe

Hi,

Hope you are well.

I am trying to setup a gallery using:

HugoPhotoSwipe

I have my Hugo site saved in:

~/Documents/Cyber Bunker/Sites/M'S Kitchen

I am using the http://demo.themefisher.com/agico-hugo/ 1 theme

Per the instructions I installed pip while in my home directory:

pip install hugophotoswipe

Next I downloaded PhotoSwipe-master.zip to ~/Documents/

I am in `~/Documents/Cyber Bunker/Sites/M’S Kitchen``

mkdir content/galleries

The next step says:

The layouts directory in the Hugo root directory contains all the information for how our site will look (we won’t use themes in this example).
First, we create a file called index.html in the layouts directory, which contains the following HTML code

However in my sites root directory there is no layouts folder there is howvever a layouts folder under themes there already exists a index.html file

So what am I doing wrong ?

Here is a zip of my site

https://mega.nz/folder/UXpzSA4Z#h6fDoqPilWpaT8HSde8yNQ

Essentially in ~/Documents/Cyber Bunker/Sites/M'S Kitchen/static/images/gallery/Watermark

I want those images on the gallery.yml page in data / en

Would be grateful for a step by step and I can turn it into a video to help others

Unable to install

Hi!

I'm getting the following error while trying to install HugoPhotoSwipe on Ubuntu 16.04
Could not find a version that satisfies the requirement smartcrop>=0.1 (from hugophotoswipe) (from versions: ) No matching distribution found for smartcrop>=0.1 (from hugophotoswipe)

I have already installed smartcrop.js using npm install smartcrop

What am I doing wrong?

Click on first thumbnail not detected when no text before first picture

Hello,

Very happy with the new updates to hps! Thanks!

Here is a sample .md file that was initially generated by hps.

+++
title = "something"
date = "2018-04-22"
tags = ["gallery"]
image = "static/cover.jpg"
+++
bla

{{< wrap >}}
{{< photo href="/pics/test/large/20170901-img_7122_1600x901.jpg" largeDim="1600x901" smallUrl="/pics/test/small/20170901-img_7122_800x450.jpg" smallDim="800x450" alt="None" thumbSize="256x256" thumbUrl="/pics/test/thumb/20170901-img_7122_256x256.jpg" caption="" copyright="" >}}

... #Other photos 
{{< /wrap >}}

This example only has one picture where as the actual album has 69.
When the text bla is present, everything works as expected.
When there is no text (remove bla), clicking on the first picture does nothing. Clicking on the second picture opens the first picture.

And if I add 8 paragraphs, it will create 8 <p>text</p>sections and it will open photo 8 when I click on the first image.

I could not find in pswp_gallery.js what is causing this issue.

Path separator issue on Windows

This is with reference to the wiki.

In Windows the generated output of content/galleries/cats.md files is:

+++
title = "Cats"
date = "2017-02-07T22:53:32-05:00"
animal = """cat"""
cover = "/pics/cats\coverimage.jpg"
+++

This causes a problem with hugo :

D:\projects\hps_example>hugo -w server
Started building sites ...
ERROR 2017/06/23 14:01:19 failed to parse page metadata for "galleries\\cats.md": Near line 4 (last key parsed 'cover'): invalid escape character 'c'; only the following escape characters are allowed: \b, \t, \n, \f, \r, \", \\, \uXXXX, and \UXXXXXXXX
Error: Error building site: Errors reading pages: Error: failed to parse page metadata for "galleries\\cats.md": Near line 4 (last key parsed 'cover'): invalid escape character 'c'; only the following escape characters are allowed: \b, \t, \n, \f, \r, \", \\, \
uXXXX, and \UXXXXXXXX for cats.md

The problem is the cover property, it should be be :

cover = "/pics/cats/coverimage.jpg"

Line 207/208 of cover.py

        album.cover_path = os.path.join(settings.output_dir, album.name, 
                settings.cover_filename)

Maybe:

        album.cover_path = os.path.join(settings.output_dir, album.name, 
            settings.cover_filename).replace("\\","/")

Regards, Paul.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.