Single File PHP Gallery 4.8.1

by Kenny Svalgaard


Single File PHP Gallery is a web gallery in one single PHP file. All you have to do is copy the script to any directory containing images to make a gallery. Sub directories will be sub galleries. Thumbnails for images and directories are generated automatically.
Single File PHP Gallery does not require any configuration or programming skills to use.

By default it looks like this:

sfpg    sfpg    sfpg
(click image to see the online demo)


  • Only one single file
  • Free for private non commercial use
  • Very simple Plug'n'Play like ease of use
  • Uses no database
  • Automatically creates thumbnails
  • Administrator options to upload, rename, move, delete...
  • Slideshow option
  • PayPal integration for simple selling
  • Displays EXIF and IPTC information
  • Option to password protect gallery
  • Option to delete directories, images and files
  • Rotates images using EXIF information
  • 3D MPO red/cyan anaglyph and stereo image generation
  • Keyboard navigation
  • Option to add watermark to all images in gallery
  • Supports JPG, JPEG, PNG, GIF and MPO
  • Unlimited numbers of sub galleries
  • See configuration information for all features


For private non commercial use Single File PHP Gallery can be used for free. When used commercially a donation for at least 10$ must be made per domain where it is used. See readme.txt for full EULA.

You are of course still more than welcome to donate if you like the gallery, even though you only use it privately.

Making a donation:
Domain name must be clearly stated in the donation, otherwise the donation will not grant use of the script under donating conditions. Donations are not refundable.
Use the following PayPal donate button for donations:


For this gallery to function you will need the following:
  • A web server capable of running PHP 5.4 or higher
  • The PHP GD library (php_gd) installed. See here for information:
  • PHP write access to server
  • PHP memory limit large enough to contain both full size image and preview/thumb (converted to BMP) See the FAQ section in readme.txt for further information on this.


Download latest version here: Single File PHP Gallery 4.8.1 (40kB)
Download SFPG TEST script here: SFPG TEST 1.5.1 (3kB)

NEWS IN SFPG 4.8.1 (14-Dec-2021)

  • Fixed issue where non-image files in the gallery could make gallery not work.
  • Fixed issue where description from a sub directrory could be shown in parent directory, when parent directory have no description.

News from previous version 4.8.0 (28-Sep-2021):
  • If you are upgrading from an older version to this version you need to delete the contents of DATA_ROOT.
  • Added EXIF GPS extraction. Latitude, longitude and a small Google map is shown in the Information box (map vendor can be changed in settings).
  • Added option (DIR_ROOT_BANNER_IN_SUBDIRS) to allow one banner file to be used in all directories.
  • Added option (HTML_DESCRIPTIONS) to allow enable/disable html in descriptions and other files in the gallery.
  • Added option (DIR_THUMB_FROM_ICONS_DIR) to allow setting an image to be used as thumb for all directories (override normal selection of thumbnails for directories)
  • Added options (TEXT_DIR_MARK_START and TEXT_DIR_MARK_END) to allow easy configuration of directory name representation. By default a small icon of a folder is printed in front of directory names.
  • Added "i" to keyboard navigation. Pressing "i" will open/close the information box.
  • Added array to define which IPTC data to include and what to call them. (Removed a lot of TEXT_IPTC_ options)
  • Changed so that EXIF box is only showed when there is EXIF information to show. (Removed setting for TEXT_EXIF_MISSING)
  • Changed so that IPTC box is only showed when there is IPTC information to show. (Removed setting for TEXT_IPTC_MISSING)
  • Changed so that Description box is only showed when a description exists for directory, image or file.
  • Changed image resize and other layout related things from using javascript to CSS. Removed a lot of javascript that had to do with the old methods.
  • Changed data format in both DATA_ROOT save files and javascript. This is the reason why you need to delete the contents of DATA_ROOT when upgrading to this version.
  • Replaced the PayPal inventory counter with a manual "Available" or "Sold" setting.
  • Removed image preview option.
  • Updated script to work with PHP 8.
  • Other minor changes and enhancements.

See here for changes in previous versions: Single File PHP Gallery Version History


Subscribe here to be notified via e-mail when a new version is released: eMail Notification

CONTACT / SUPPORT (English or Danish/Dansk)

Please use the link below if you have any comments, questions, requests, greetings etc.

If you are having problems getting the script to work, then please download the SFPG TEST script from the DOWNLOAD section above, and paste the output from it into the message, along with a description of the issue you are having.
Use the contact form on this page: Contact