From 0b31eda1c2e65e2399192330bc95d99dd69c4c57 Mon Sep 17 00:00:00 2001 From: varlog Date: Tue, 9 Mar 2021 16:13:14 +0100 Subject: [PATCH 1/3] add tif/tiff support --- README.md | 3 ++- src/pathtraverser.cpp | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d4e8307..93faf69 100644 --- a/README.md +++ b/README.md @@ -46,9 +46,10 @@ slide [-t rotation_seconds] [-o background_opacity(0..255)] [-b blur_radius] -p * libexif * qt5 - +* qt5-image-formats-plugins for tiff ``` sudo apt install libexif12 qt5-default +sudo apt install qt5-image-formats-plugins ``` ## Build diff --git a/src/pathtraverser.cpp b/src/pathtraverser.cpp index 660af6b..54498b3 100644 --- a/src/pathtraverser.cpp +++ b/src/pathtraverser.cpp @@ -22,7 +22,9 @@ RecursivePathTraverser::~RecursivePathTraverser() {} QStringList RecursivePathTraverser::getImages() const { - QDirIterator it(QString(path.c_str()), QStringList() << "*.jpg" << "*.JPG" << "*.jpeg" << "*.JPEG" << "*.PNG" << "*.png", QDir::Files, QDirIterator::Subdirectories); + QDirIterator it(QString(path.c_str()), + QStringList() << "*.jpg" << "*.JPG" << "*.jpeg" << "*.JPEG" << "*.PNG" << "*.png" << "*.tiff" << "*.TIFF" << "*.tif" << "*.TIF", + QDir::Files, QDirIterator::Subdirectories); QStringList files; while (it.hasNext()) { @@ -46,7 +48,8 @@ DefaultPathTraverser::~DefaultPathTraverser() {} QStringList DefaultPathTraverser::getImages() const { - return directory.entryList(QStringList() << "*.jpg" << "*.JPG" << "*.jpeg" << "*.JPEG" << "*.PNG" << "*.png", QDir::Files); + return directory.entryList(QStringList() << "*.jpg" << "*.JPG" << "*.jpeg" << "*.JPEG" << "*.PNG" << "*.png"<< "*.tiff" << "*.TIFF"<< "*.tif" << "*.TIF", + QDir::Files); } const std::string DefaultPathTraverser::getImagePath(const std::string image) const From 128796c9e8ef17a1bbd3dc3f4ea2bf8a5160b173 Mon Sep 17 00:00:00 2001 From: Manuel Dewald Date: Thu, 11 Mar 2021 09:02:55 +0100 Subject: [PATCH 2/3] improve build tools --- Makefile | 36 ++++++++++++++++++++++++++++++++++++ README.md | 32 +++++++++++++++++++------------- sbin/package.sh | 17 +++++++---------- sbin/package_all.sh | 10 ++++++++++ sbin/package_remote.sh | 8 ++++---- 5 files changed, 76 insertions(+), 27 deletions(-) create mode 100644 Makefile create mode 100755 sbin/package_all.sh diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d7c1d8e --- /dev/null +++ b/Makefile @@ -0,0 +1,36 @@ +VERSION ?= 0.0.0 +BINARY ?= slide +ARCH ?= noarch + +.PHONY: all +all: build + +.PHONY: install-deps-deb +install-deps-deb: + apt install qt5-qmake libexif12 qt5-default libexif-dev qt5-image-formats-plugins + +check-deps-deb: + dpkg -l | grep qt5-qmake + dpkg -l | grep libexif12 + dpkg -l | grep libexif-dev + dpkg -l | grep qt5-default + dpkg -l | grep qt5-image-formats-plugins + +.PHONY: clean +clean: + rm -rf build + +build: + mkdir -p build + qmake src/slide.pro -o build/Makefile + make -C build + +PACKAGE_DIR=build/slide_$(VERSION) + +.PHONY: package +package: clean build + mkdir -p $(PACKAGE_DIR) + cp -r "./build/$(BINARY)" $(PACKAGE_DIR) + cp "INSTALL.md" $(PACKAGE_DIR) + cp "LICENSE" $(PACKAGE_DIR) + cd build && tar cfz slide_$(ARCH)_$(VERSION).tar.gz slide_$(VERSION) diff --git a/README.md b/README.md index 93faf69..f2880ea 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ Simple, lightweight slideshow selecting random images from specified directory. Tested versions: * Raspberry Pi 3 running Raspbian Stretch. * Raspberry Pi 3 running Raspbian Buster. + * Raspberry Pi Zero running Raspbian Buster. Screen background is filled with a scaled version of the image to prevent pure black background. @@ -44,27 +45,34 @@ slide [-t rotation_seconds] [-o background_opacity(0..255)] [-b blur_radius] -p ## Dependencies -* libexif +* qt5-qmake * qt5 -* qt5-image-formats-plugins for tiff +* qt5-image-formats-plugins +* libexif + +Ubuntu/Raspbian: + ``` -sudo apt install libexif12 qt5-default -sudo apt install qt5-image-formats-plugins +sudo make install-deps-deb ``` ## Build -dev libs needed to build slide on from source: +Install dependencies ``` -sudo apt install libexif-dev +make install-deps-deb ``` +Build project + ``` -mkdir -p make -cd make -qmake ../src/slide.pro make +``` + +Install binaries + +``` sudo make install ``` @@ -75,9 +83,7 @@ Prerequisite: brew ``` brew install qt5 brew install libexif -mkdir -p build -cd build -qmake ../src/slide.pro +brew install libexif make ``` @@ -88,7 +94,7 @@ This article has more helpful ways that you could use this repo as a picture fra https://opensource.com/article/19/2/wifi-picture-frame-raspberry-pi ``` -## Removing black border +## Removing black border (Raspberry Pi) ``` if you find that you have a black border around your screen you can remove it by disabling overscan. This is done by editing /boot/config.txt and uncommenting disable_overscan=1 diff --git a/sbin/package.sh b/sbin/package.sh index f5b1075..d77ed7c 100755 --- a/sbin/package.sh +++ b/sbin/package.sh @@ -2,8 +2,8 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -ARCH=$1 -VERSION=$2 +export ARCH=$1 +export VERSION=$2 set -euo pipefail @@ -22,11 +22,8 @@ if [[ "$ARCH" == "osx" ]]; then fi cd "$DIR/.." -mkdir -p make/slide_$VERSION -cd make -qmake ../src/slide.pro -make -cp -r "$BINARY" "slide_$VERSION/" -cp "../INSTALL.md" "slide_$VERSION/" -cp "../LICENSE" "slide_$VERSION/" -tar cfz slide_${ARCH}_$VERSION.tar.gz "slide_$VERSION" +if ! make check-deps-deb; then + sudo make install-deps-deb +fi + +make package diff --git a/sbin/package_all.sh b/sbin/package_all.sh new file mode 100755 index 0000000..2bb30ad --- /dev/null +++ b/sbin/package_all.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -euxo pipefail +VERSION=$1 +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +make clean +$DIR/package_remote.sh pi picframe pi $VERSION +$DIR/package_remote.sh pi raspberrypi pi-0 $VERSION +$DIR/package.sh amd64 $VERSION +mv build/slide_amd64_$VERSION.tar.gz . diff --git a/sbin/package_remote.sh b/sbin/package_remote.sh index 35856ab..4eb8d17 100755 --- a/sbin/package_remote.sh +++ b/sbin/package_remote.sh @@ -9,7 +9,7 @@ VERSION=$4 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -cd $DIR/.. -rsync -av --delete $(pwd)/* $USER@$HOSTNAME:/tmp/slide_build -ssh $USER@$HOSTNAME "rm -rf /tmp/slide_build/build;/tmp/slide_build/sbin/package.sh $ARCH $VERSION" -scp $USER@$HOSTNAME:/tmp/slide_build/make/slide_*.tar.gz . +cd "$DIR/.." +rsync -av --delete "$(pwd)"/* "$USER@$HOSTNAME:/tmp/slide_build" +ssh "$USER@$HOSTNAME" "rm -rf /tmp/slide_build/build;/tmp/slide_build/sbin/package.sh $ARCH $VERSION" +scp "$USER@$HOSTNAME:/tmp/slide_build/build/slide_*.tar.gz" . From 98344061c1f97573543169dc9be0243464f9549b Mon Sep 17 00:00:00 2001 From: Manuel Dewald Date: Thu, 11 Mar 2021 09:03:13 +0100 Subject: [PATCH 3/3] DRY image formats --- src/pathtraverser.cpp | 14 ++++++++++---- src/pathtraverser.h | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/pathtraverser.cpp b/src/pathtraverser.cpp index 54498b3..2d8c97b 100644 --- a/src/pathtraverser.cpp +++ b/src/pathtraverser.cpp @@ -13,6 +13,14 @@ PathTraverser::PathTraverser(const std::string path): PathTraverser::~PathTraverser() {} +QStringList PathTraverser::getImageFormats() const { + QStringList imageFormats; + imageFormats << "*.jpg" << "*.JPG" << "*.jpeg" << "*.JPEG"; + imageFormats << "*.PNG" << "*.png"; + imageFormats << "*.tiff" << "*.TIFF" << "*.tif" << "*.TIF"; + return imageFormats; +} + RecursivePathTraverser::RecursivePathTraverser(const std::string path): PathTraverser(path) {} @@ -22,8 +30,7 @@ RecursivePathTraverser::~RecursivePathTraverser() {} QStringList RecursivePathTraverser::getImages() const { - QDirIterator it(QString(path.c_str()), - QStringList() << "*.jpg" << "*.JPG" << "*.jpeg" << "*.JPEG" << "*.PNG" << "*.png" << "*.tiff" << "*.TIFF" << "*.tif" << "*.TIF", + QDirIterator it(QString(path.c_str()), getImageFormats(), QDir::Files, QDirIterator::Subdirectories); QStringList files; while (it.hasNext()) @@ -48,8 +55,7 @@ DefaultPathTraverser::~DefaultPathTraverser() {} QStringList DefaultPathTraverser::getImages() const { - return directory.entryList(QStringList() << "*.jpg" << "*.JPG" << "*.jpeg" << "*.JPEG" << "*.PNG" << "*.png"<< "*.tiff" << "*.TIFF"<< "*.tif" << "*.TIF", - QDir::Files); + return directory.entryList(getImageFormats(), QDir::Files); } const std::string DefaultPathTraverser::getImagePath(const std::string image) const diff --git a/src/pathtraverser.h b/src/pathtraverser.h index d400ce8..554c3e5 100644 --- a/src/pathtraverser.h +++ b/src/pathtraverser.h @@ -16,6 +16,7 @@ class PathTraverser protected: const std::string path; + QStringList getImageFormats() const; }; class RecursivePathTraverser : public PathTraverser