•  » Your Piwigo
  •  » Piwigo on Orange Pi (Can also be Raspberry Pi

#1 2024-04-22 08:27:11


Piwigo on Orange Pi (Can also be Raspberry Pi


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 ( 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.

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]])

    if len(convert_args) > 2:
      convert =
      if convert.returncode != 0:
        return convert.returncode
      source = dest

    # We resize with epeg as it should be faster
    epeg =["/usr/local/bin/epeg", source, "-w", geom[0], "-h", geom[1], dest])
    if epeg.returncode != 0:
      return epeg.returncode
    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
      convert_args = ["/usr/bin/convert", source]
      convert =
      return convert.returncode

    return epeg.returncode

    convert =["/usr/bin/convert"] + argv)
    return convert.returncode

if __name__ == "__main__":
  quit(main(len(sys.argv)-1, sys.argv[1:]))


  •  » Your Piwigo
  •  » Piwigo on Orange Pi (Can also be Raspberry Pi

Board footer

Powered by FluxBB

github twitter newsletter Donate © 2002-2024 · Contact