Update brew and snap

This commit is contained in:
Aaron Liu 2022-02-02 21:38:04 +08:00
parent 9004bb3f47
commit 1b89356729
4 changed files with 57 additions and 60 deletions

View file

@ -20,32 +20,39 @@ See the difference by disabling this optimization using the `-0` option. Or just
- 2020-04-09: @aaronliu0130 has added homebrew support.
- 2020-07-05: @cxwx has fixed homebrew support.
- 2021-05-21: @aaronliu0130 has added Apple Clang support.
- 2021-02-02: @aaronliu0130 added homebrew support from homebrew-core.
## Installation
### Build from source (Linux)
### Build from source
sudo apt install imagemagick || yum install ImageMagick
git clone https://github.com/stefanhaustein/TerminalImageViewer.git
cd TerminalImageViewer/src/main/cpp
make
sudo make install
### Homebrew (MacOS)
### Homebrew
Option 1:
```
brew install tiv
```
Option 2(deprecated):
```
brew tap stefanhaustein/TerminalImageViewer https://github.com/stefanhaustein/TerminalImageViewer
brew install tiv
```
Option 2(deprecated, for macOS Mojave and below):
Option 3(deprecated, for macOS Mojave and below):
```
brew tap stefanhaustein/TerminalImageViewer https://github.com/stefanhaustein/TerminalImageViewer
brew install terminalimageviewer
```
Option 3(deprecated):
```
brew install https://raw.githubusercontent.com/stefanhaustein/TerminalImageViewer/master/terminalimageviewer.rb
```
### Snap (outdated)
@ -55,32 +62,31 @@ brew install https://raw.githubusercontent.com/stefanhaustein/TerminalImageViewe
tiv [options] <filename(s)>
The shell will expand wildcards. By default, thumbnails and file names will be displayed if more than one image is provided. To display a list of options, just run the command without any parameters.
The shell will expand wildcards. By default, thumbnails and file names will be displayed if more than one image is provided. To display a list of options, just run the command without any parameters.
## Packages / Contributions
- megamaced has created a RPM for SUSE:
https://build.opensuse.org/package/show/home:megamaced/terminalimageviewer
- bperel has created a Docker image:
https://hub.docker.com/r/bperel/terminalimageviewer
- teresaejunior has created a snapcraft.yaml file, which can build a Snap package with `sudo docker run -it --rm -v "$PWD:$PWD" -w "$PWD" snapcore/snapcraft sh -c 'apt-get update && snapcraft'`, and then installed with `sudo snap install --dangerous ./*.snap`.
- aaronliu0130 has added brew support.
- megamaced has created a RPM for SUSE:
<https://build.opensuse.org/package/show/home:megamaced/terminalimageviewer>
- bperel has created a Docker image:
<https://hub.docker.com/r/bperel/terminalimageviewer>
- teresaejunior has created a snapcraft.yaml file, which can build a Snap package with `sudo docker run -it --rm -v "$PWD:$PWD" -w "$PWD" snapcore/snapcraft sh -c 'apt-get update && snapcraft'`, and then installed with `sudo snap install --dangerous ./*.snap`.
- aaronliu0130 has added brew support.
I am happy to accept useful contributions under the Apache 2.0 licencse, but...
- Before investing in larger contributions, please use an issue to discuss this
- Pull requests should be as "atomic" as possible. I won't accept any pull request doing multiple things at once.
- This library currently only depends on ImageMagic as an image processing library and I'd prefer to keep it that way.
- Support for additional platforms, CPUs or similar will require somebody who is happy to help with maintenance, in particular, if I don't have access to it.
- Before investing in larger contributions, please use an issue to discuss this
- Pull requests should be as "atomic" as possible. I won't accept any pull request doing multiple things at once.
- This library currently only depends on ImageMagic as an image processing library and I'd prefer to keep it that way.
- Support for additional platforms, CPUs or similar will require somebody who is happy to help with maintenance, in particular, if I don't have access to it.
## Common problems
- On some linux platforms, an extra flag seems to be required: `make LDLIBS=-lstdc++fs` (but it also breaks MacOs), see https://github.com/stefanhaustein/TerminalImageViewer/issues/103
- If you see strange horizontal lines, the characters don't fully fill the character cell. Remove additional line spacing in your terminal app
- Wrong colors? Try -256 to use a 256 color palette instead of 24 bit colors
- Strange characters? Try -0 or install an use full unicode font (e.g. inconsolata or firacode)
- On some linux platforms, an extra flag seems to be required: `make LDLIBS=-lstdc++fs` (but it also breaks MacOs), see <https://github.com/stefanhaustein/TerminalImageViewer/issues/103>
- If you see strange horizontal lines, the characters don't fully fill the character cell. Remove additional line spacing in your terminal app
- Wrong colors? Try -256 to use a 256 color palette instead of 24 bit colors
- Strange characters? Try -0 or install an use full unicode font (e.g. inconsolata or firacode)
## Examples
![Examples](https://i.imgur.com/8UyGjg8.png)
@ -94,4 +100,3 @@ If multiple images match the filename spec, thumbnails are shown.
The top image was generated with the character optimization disabled via the `-0` option.
![Comparison](https://i.imgur.com/OzdCeh6.png)

View file

@ -1,5 +1,5 @@
name: tiv
version: "v1.0.0"
version: "v1.1.1"
summary: Terminal Image Viewer
description: |
tiv is a small C++ program to display images in a (modern) terminal using
@ -17,7 +17,7 @@ parts:
tiv:
plugin: make
source-type: tar
source: https://github.com/stefanhaustein/TerminalImageViewer/archive/v1.0.0.tar.gz
source: https://github.com/stefanhaustein/TerminalImageViewer/archive/v1.1.1.tar.gz
source-subdir: src/main/cpp
build-packages:
- g++
@ -29,7 +29,7 @@ parts:
install $SNAPCRAFT_PART_BUILD/tiv $SNAPCRAFT_PART_INSTALL/usr/bin/
imagemagick:
plugin: autotools
source: https://www.imagemagick.org/download/releases/ImageMagick-7.0.7-39.tar.xz
source: https://www.imagemagick.org/download/releases/ImageMagick-7.1.0-22.tar.xz
source-type: tar
configflags:
- --enable-hdri=yes

View file

@ -1,40 +1,27 @@
class Terminalimageviewer < Formula
desc "Display images in a terminal using block graphic characters"
homepage "https://github.com/stefanhaustein/TerminalImageViewer"
url "https://github.com/stefanhaustein/TerminalImageViewer/archive/v1.1.0.tar.gz"
sha256 "727ddaa048643cb0a13e23bc308415060d99d8b1853883ad339ad7b952050d61"
head "https://github.com/stefanhaustein/TerminalImageViewer.git"
uses_from_macos "curl" => :test
depends_on "gcc" => :build unless OS.linux?
url "https://github.com/stefanhaustein/TerminalImageViewer/archive/refs/tags/v1.1.1.tar.gz"
sha256 "9a5f5c8688ef8db0e88dfcea6a1ae30da32268a7ab7972ff0de71955a75af0db"
license "Apache-2.0"
head "https://github.com/stefanhaustein/TerminalImageViewer.git", branch: "master"
depends_on "imagemagick"
def install
odie "This formula is for macOS 10.14-, please use tiv from homebrew-core instead!" if OS.linux?
cd "src/main/cpp" do
system "make"
if OS.mac?
# No expermimental/filesystem.h on mac.
system "/usr/local/bin/g++-#{Formula["gcc"].version_suffix}", "-std=c++17",
"-Wall",
"-fpermissive",
"-fexceptions",
"-O2", "-c",
"-L/usr/local/opt/gcc/lib/gcc/11/",
"tiv.cpp", "-o", "tiv.o"
system "/usr/local/bin/g++-#{Formula["gcc"].version_suffix}", "tiv.o", "-o", "tiv",
"-L/usr/local/opt/gcc/lib/gcc/11/", "-pthread", "-s"
else
system "make"
end
system "/usr/local/bin/g++-#{Formula["gcc"].version_suffix}", "-std=c++17", "-Wall", "-fpermissive",
"-fexceptions", "-O2", "-c", "-L/usr/local/opt/gcc/lib/gcc/#{Formula["gcc"].version_suffix}/", "tiv.cpp",
"-o", "tiv.o"
system "/usr/local/bin/g++-#{Formula["gcc"].version_suffix}", "tiv.o", "-o", "tiv",
"-L/usr/local/opt/gcc/lib/gcc/#{Formula["gcc"].version_suffix}/", "-pthread", "-s"
bin.install "tiv"
end
end
test do
# Downloads a public domain test file from wikimedia commons and displays it.
# NOTE: Test will fail. Will fix when I get to my mac.
system "curl -o \"test.png\" https://upload.wikimedia.org/wikipedia/commons/2/24/Cornell_box.png"
assert_equal "▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
",
shell_output("#{bin}/tiv -0 -w 400 -h 400 test.png").strip
assert_equal "\e[48;2;0;0;255m\e[38;2;0;0;255m \e[0m",
shell_output("#{bin}/tiv #{test_fixtures("test.png")}").strip
end
end
end

13
tiv.rb
View file

@ -5,9 +5,14 @@ class Tiv < Formula
sha256 "9a5f5c8688ef8db0e88dfcea6a1ae30da32268a7ab7972ff0de71955a75af0db"
license "Apache-2.0"
head "https://github.com/stefanhaustein/TerminalImageViewer.git", branch: "master"
depends_on "imagemagick"
uses_from_macos "curl" => :test
on_linux do
depends_on "gcc"
end
fails_with gcc: "5"
def install
cd "src/main/cpp" do
@ -17,7 +22,7 @@ class Tiv < Formula
end
test do
assert_equal "\e[48;2;0;0;255m\e[38;2;0;0;255m  \e[0m",
shell_output("#{bin}/tiv #{test_fixtures("test.png")}").strip
assert_equal "\e[48;2;0;0;255m\e[38;2;0;0;255m \e[0m",
shell_output("#{bin}/tiv #{test_fixtures("test.png")}").strip
end
end
end