Hi,
I've successfully installed a local Piwigo server on an Orange Pi. I had over 8000 pictures on my pretty old Synology NAS, which I wanted to browse in a user-friendly way. I mount the NAS over cifs on my Orange Pi and used a script to sync all images. With some googling you can find it. I had to use it because Piwigo would return a timeout when syncing the large albums.
I noticed that generating the thumbnails takes very long on the Pi, so I ended up writing a wrapper for epeg (https://github.com/koofr/epeg) in Python, named it "convert", put it in /usr/local/bin and change the config file to use ext_imagick and point to the wrapper. This wrapper will effectively call imagemagick convert for all commands that are not supported by epeg, but use epeg when resizing.
Now the first time a page is loaded, it's much faster.
I also had to add ob_end_clean() before fpassthru in i.php, because the generated thumbnails would not be shown immediately after generation and I first had to reload the page. That's fixed with ob_end_clean().
Thanks for Piwigo! I can finally browse my photo's again and also let my family enjoy the pictures.
#!/usr/bin/python3
import os, sys, shutil, subprocess
def main(argc: int, argv: list[str]) -> int:
if "-resize" in argv:
geom_ix = argv.index("-resize")+1
if geom_ix == argc:
print("Should provide geometry for resize", file=sys.stderr)
return -1
geom = argv[geom_ix]
if "x" not in geom:
print("Should have geometery <width>x<height>", file=sys.stderr)
return -1
geom = geom.split("x")
# Executing convert is usually done by providing the source file name at the beginning
# of the arguments and the destination file name at the end
source = argv[0]
dest = argv[argc-1]
# Before we execute epeg, we first allow ImageMagick convert to crop the picture if neeeded
convert_args = ["/usr/bin/convert", source]
if "-crop" in argv:
convert_args.extend(["-crop", argv[argv.index("-crop")+1]])
argv.pop(argv.index("-crop")+1)
argv.remove("-crop")
if len(convert_args) > 2:
convert_args.append(dest)
print(convert_args)
convert = subprocess.run(convert_args)
if convert.returncode != 0:
return convert.returncode
source = dest
# We resize with epeg as it should be faster
epeg = subprocess.run(["/usr/local/bin/epeg", source, "-w", geom[0], "-h", geom[1], dest])
if epeg.returncode != 0:
return epeg.returncode
argv.pop(argv.index("-resize")+1)
argv.remove("-resize")
source = dest
# Now we execute the rest of the commands with convert
if len(argv) > 2: # source and destination file names are still in there
argv.remove(argv[0])
argv.pop(len(argv)-1)
convert_args = ["/usr/bin/convert", source]
convert_args.extend(argv)
convert_args.append(dest)
print(convert_args)
convert = subprocess.run(convert_args)
return convert.returncode
return epeg.returncode
else:
convert = subprocess.run(["/usr/bin/convert"] + argv)
return convert.returncode
if __name__ == "__main__":
quit(main(len(sys.argv)-1, sys.argv[1:]))
Offline