•  » Extensions
  •  » Thumbnail Generation Script, Piwigo 16 edition

#1 2025-12-02 18:42:08

GJSchaller
Member
2022-05-26
34

Thumbnail Generation Script, Piwigo 16 edition

Hello, I am setting up a new instance of Piwigo using v16, which is great so far.  Of note, I will be enabling TOTP, and I'd like to set up an API key for scheduled tasks (see below).

Ages ago, I found and set up a script to automatically generate thumbnails on photos that were missing them.  Over the years, that script has been updated to work with newer versions of Piwigo as they came out.

I'm looking for help with v16, to make sure the script works, and specifically to update the script to use an API key instead of a name and password.  Can anyone offer help with this?

The script in its current form is at:

https://github.com/GJSchaller/piwigo-thumb-generate

Thank you!

Offline

 

#2 2025-12-02 19:50:18

moberley
Member
2025-11-10
90

Re: Thumbnail Generation Script, Piwigo 16 edition

If I understand your script it looks like you probably can remove the login and saving cookies portion (lines 13 and 31). Then change the calls to pwg.getMissingDerivatives to include the Authorization header and the API key ("id:secret") generated on the Piwigo profile page for the user you want to use on lines 15 and 28.

Code:

wget -nv --header='Authorization: pkid-xxxxxxxx-xxxxxxxxxxxxxxxxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' -O missing.json "http://(Path-To-Piwigo)/ws.php?format=json&method=pwg.getMissingDerivatives"

Offline

 

#3 2025-12-02 21:08:13

GJSchaller
Member
2022-05-26
34

Re: Thumbnail Generation Script, Piwigo 16 edition

Thank you for the help on this!  It's mostly working, but I am getting an "Authorization Failed" message - I'll try to troubleshoot a bit and report back if I can't figure it out.

Offline

 

#4 2025-12-02 21:52:45

moberley
Member
2025-11-10
90

Re: Thumbnail Generation Script, Piwigo 16 edition

Since I updated to the latest version (16.1.0) I have been having trouble invoking any of the admin only WS methods. I have not figured out why that is happening yet (the web services were working fine before the update) but I thought I would mention it in case it is something that is affecting other people as well.

Offline

 

#5 2025-12-02 22:04:23

GJSchaller
Member
2022-05-26
34

Re: Thumbnail Generation Script, Piwigo 16 edition

This is the error I am getting:

Code:

geoffrey@TrueNAS:/mnt/data/scripts/1-CRON$ ./piwigo-thunb-generate.sh

http://photos.aiskon.net/ws.php?format=json&method=pwg.session.login:
2025-12-02 16:03:14 ERROR 405: This method requires HTTP POST.

geoffrey@TrueNAS:/mnt/data/scripts/1-CRON$

Offline

 

#6 2025-12-02 22:19:42

moberley
Member
2025-11-10
90

Re: Thumbnail Generation Script, Piwigo 16 edition

The pwg.session.login method does require the payload to be sent as POST data but you shouldn't need to call that method at all if you have a valid Authorization header on the call to pwg.getMissingDerivatives. Try commenting out or removing the pwg.session.login line from your script.

Offline

 

#7 2025-12-02 22:24:36

GJSchaller
Member
2022-05-26
34

Re: Thumbnail Generation Script, Piwigo 16 edition

My current script:

Code:

set -e

cd /mnt/data/scripts/1-CRON/

wget -nv --header='Authorization: pkid-20251202-REDACTED:REDACTED' -O missing.json "http://photos.aiskon.net/ws.php?format=json"

while [ `wc -c missing.json | awk '{print $1}'` -gt 50 ]
do
  sed -e 's/[\\\"]//g' \
  -e 's/{stat:ok,result:{next_page:[0-9]*,urls:\[//' \
  -e 's/{stat:ok,result:{urls:\[//' \
  -e 's/\]}}/\n/' \
  -e 's/,/\n/g' \
  -e 's/\&b=[0-9]*//g' missing.json | \
  while read line ; do
    wget -nv -O /dev/null $line
  done
  wget -nv --header='Authorization: pkid-20251202-REDACTED:REDACTED' -O missing.json "http://photos.aiskon.net/ws.php?format=json"
done

rm missing.json

The results:

Code:

geoffrey@TrueNAS:/mnt/data/scripts/1-CRON$ ./piwigo-thunb-generate.sh

http://photos.aiskon.net/ws.php?format=json:
2025-12-02 16:21:59 ERROR 501: Missing "method" name.

geoffrey@TrueNAS:/mnt/data/scripts/1-CRON$

Offline

 

#8 2025-12-02 22:43:13

moberley
Member
2025-11-10
90

Re: Thumbnail Generation Script, Piwigo 16 edition

Try adding the following between format=json and the closing quote on your wget lines.

Code:

&method=pwg.getMissingDerivatives

Offline

 

#9 2025-12-02 22:46:46

GJSchaller
Member
2022-05-26
34

Re: Thumbnail Generation Script, Piwigo 16 edition

Result:

Code:

geoffrey@TrueNAS:/mnt/data/scripts/1-CRON$ ./piwigo-thunb-generate.sh

Username/Password Authentication Failed.

geoffrey@TrueNAS:/mnt/data/scripts/1-CRON$

Offline

 

#10 2025-12-02 23:03:58

moberley
Member
2025-11-10
90

Re: Thumbnail Generation Script, Piwigo 16 edition

Do you get the same result if you just run the wget command by itself?

I ran the following script against my testing server and walked through the list of files as expected. Sorry, but I'm really not sure why you are getting that error.

Code:

#!/bin/sh

set -e

cd /home/dcg

wget -nv --header='Authorization: pkid-20251202-XXXXX:XXXXX' -O missing.json "https://MY-PIWIGO-SERVER/ws.php?format=json&method=pwg.getMissingDerivatives"

while [ `wc -c missing.json | awk '{print $1}'` -gt 50 ]
do
  sed -e 's/[\\\"]//g' \
  -e 's/{stat:ok,result:{next_page:[0-9]*,urls:\[//' \
  -e 's/{stat:ok,result:{urls:\[//' \
  -e 's/\]}}/\n/' \
  -e 's/,/\n/g' \
  -e 's/\&b=[0-9]*//g' missing.json | \
  while read line ; do
    wget -nv -O /dev/null $line
  done
  wget -nv --header='Authorization: pkid-20251202-XXXXX:XXXXX' -O missing.json "https://MY-PIWIGO-SERVER/ws.php?format=json&method=pwg.getMissingDerivatives"
done

rm missing.json

Offline

 

#11 2025-12-02 23:33:38

moberley
Member
2025-11-10
90

Re: Thumbnail Generation Script, Piwigo 16 edition

Okay I did a bit more testing and I am now consistently getting the same "Username/Password Authentication Failed." when I run that wget command against 16.1.0 but it works when run against 16.0.0 on the same server. The only change is installing the upgrade or manually reverting back to 16.0.0.

Offline

 

#12 2025-12-02 23:38:16

GJSchaller
Member
2022-05-26
34

Re: Thumbnail Generation Script, Piwigo 16 edition

I'm using the Docker image, so I am on 16.1 at the moment.  Who do I tag to let them know this may be an issue?

Offline

 

#13 2025-12-02 23:43:37

moberley
Member
2025-11-10
90

Re: Thumbnail Generation Script, Piwigo 16 edition

I have made a thread specifically about this issue I am having with the web services API on 16.1.0 but I'm just a user so I don't know who needs to be tagged.

https://piwigo.org/forum/viewtopic.php? … 16#p193616

Offline

 

#14 2025-12-02 23:43:53

Linty
Piwigo Team
2023-11-03
58

Re: Thumbnail Generation Script, Piwigo 16 edition

Hello,

There is a change regarding API keys in version 16.1.0: the header is no longer "Authorization" but "X-PIWIGO-API". [Github] Piwigo issue #2460


“An adventure between passion and logic.”

Offline

 

#15 2025-12-02 23:46:39

GJSchaller
Member
2022-05-26
34

Re: Thumbnail Generation Script, Piwigo 16 edition

That did it!  Thank you!  I'll post the working code in a bit.

Offline

 
  •  » Extensions
  •  » Thumbnail Generation Script, Piwigo 16 edition

Board footer

Powered by FluxBB

github linkedin newsletter Piwigo.org © 2002-2026 · Contact