You are not logged in.

#1 2018-04-08 04:28:23

Batou
Member
Registered: 2017-01-03
Posts: 259

[Solved] PKGBUILD Request: tifig - HEIC/HEIF image converter

Today I came across HEIC files. They're the new 'High Efficiency Image File Format' and all the phones and OSes like Win/macOS/Android/iOS now support it.

https://en.wikipedia.org/wiki/High_Effi … ile_Format

After a lot of searching, I finally managed to find a converter that actually works and gives you a usable jpeg after the conversion:

https://github.com/monostream/tifig

They have a static build on the releases page: https://github.com/monostream/tifig/releases I think that would suffice.

AUR has HEIF lib: https://aur.archlinux.org/packages/heif/ but that lib doesn't have an executable and nothing popular (Imagemagick, common viewers etc) seems to use it.

Could someone please create a PKGBUILD for it? Anyone interested in putting it into AUR since this format will now become a lot more common?

Thanks!

Last edited by Batou (2018-04-11 05:38:24)


Please vote for all the AUR packages you're using. You can mass-vote for all of them by doing: "pacman -Qqm | xargs aurvote -v" (make sure to run "aurvote --configure"  first)

Offline

#2 2018-04-08 11:16:15

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Re: [Solved] PKGBUILD Request: tifig - HEIC/HEIF image converter

Batou wrote:

After a lot of searching, I finally managed to find a converter that actually works and gives you a usable jpeg after the conversion

As an aside, have you tried guetzli which is in [community]?

From the readme you linked, compiling the software seems pretty straight forward.  You could use this is a learning example.  Read the PKGBULD wiki page and look at a few PKGBUILD files that build from cmake and try on your own.

Last edited by graysky (2018-04-08 11:18:17)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#3 2018-04-08 14:29:49

loqs
Member
Registered: 2014-03-06
Posts: 17,322

Re: [Solved] PKGBUILD Request: tifig - HEIC/HEIF image converter

Batou wrote:

AUR has HEIF lib: https://aur.archlinux.org/packages/heif/ but that lib doesn't have an executable and nothing popular (Imagemagick, common viewers etc) seems to use it.

https://github.com/nokiatech/heif/blob/ … SE.TXT#L37 that license is not the most compatible with respect to open source licenses.
https://github.com/ImageMagick/ImageMagick/issues/507
https://github.com/ImageMagick/ImageMag … e.ac#L2271

Offline

#4 2018-04-08 15:39:59

progandy
Member
Registered: 2012-05-17
Posts: 5,190

Re: [Solved] PKGBUILD Request: tifig - HEIC/HEIF image converter


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#5 2018-04-08 20:18:45

Batou
Member
Registered: 2017-01-03
Posts: 259

Re: [Solved] PKGBUILD Request: tifig - HEIC/HEIF image converter

graysky wrote:

As an aside, have you tried guetzli which is in [community]?

That's from Google, right? I remember trying it when it came out. Was not that impressed. I'll give it a try again since it's been a while and was probably improved a lot. There's a really interested package called jpeg-archive which has some really amazing jpeg (re)compression utilities. It's even better than Mozjpeg. It's similar to JpegMini program for Mac/Windows that I tried a while back.  I'm an amateur photographer and I take lots of images so I added it to my toolchain. It massively compresses images from shittier cameras without reducing their fidelity (my phone produces 7+MB jpeg images that compress to 1.2MB without any visual loss of quality).

loqs wrote:

that license is not the most compatible with respect to open source licenses.

Very interesting. I guess that's why nothing uses it.

progandy wrote:

Yep... especially the patent part. Really disappointing. I guess we can forget about GIMP/Krita/ImageMagick supporting it anytime soon.

I dislike this new format but it will be a lot more common soon. At least there's one tool that we now have that can reliably convert it to common formats.


Please vote for all the AUR packages you're using. You can mass-vote for all of them by doing: "pacman -Qqm | xargs aurvote -v" (make sure to run "aurvote --configure"  first)

Offline

#6 2018-04-09 00:06:21

loqs
Member
Registered: 2014-03-06
Posts: 17,322

Re: [Solved] PKGBUILD Request: tifig - HEIC/HEIF image converter

Batou wrote:

I dislike this new format but it will be a lot more common soon. At least there's one tool that we now have that can reliably convert it to common formats.

https://github.com/nokiatech/heif/blob/ … SE.TXT#L21 does not seem to allow using the library for anything other than verifying standards complicance
and you would still need patent licences if software patents exist in your legal jurisdiction.

Offline

#7 2018-04-09 02:13:32

Batou
Member
Registered: 2017-01-03
Posts: 259

Re: [Solved] PKGBUILD Request: tifig - HEIC/HEIF image converter

loqs wrote:

https://github.com/nokiatech/heif/blob/ … SE.TXT#L21 does not seem to allow using the library for anything other than verifying standards compliance
and you would still need patent licences if software patents exist in your legal jurisdiction.

So it's basically useless. Thanks Nokia. They should have released it in a public domain or under MIT license and then just shifted the patent responsibilities onto users. I doubt anyone will come after tifig. No one came after LAME or ffmpeg over anything in the past.


Coming back to  guetzli, I just tried optimizing an 5152x3864 image and it took 980.44s to optimize and compress a file on an i7. jpeg-recompress took under a second. I can't tell the difference between all three images at 100% and 150% zoom.

Original jpg: 6.7M
guetzli jpg: 5.3M
jpeg-archive: 1.2M

guetzli is still to be avoided.

Last edited by Batou (2018-04-09 02:15:21)


Please vote for all the AUR packages you're using. You can mass-vote for all of them by doing: "pacman -Qqm | xargs aurvote -v" (make sure to run "aurvote --configure"  first)

Offline

#8 2018-04-09 09:49:45

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Re: [Solved] PKGBUILD Request: tifig - HEIC/HEIF image converter

Batou wrote:

Original jpg: 6.7M
guetzli jpg: 5.3M
jpeg-archive: 1.2M

guetzli is still to be avoided.

Settings used for each?  It isn't apples-to-apples... or is it?  We don't have enough info.


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#9 2018-04-09 18:12:04

Batou
Member
Registered: 2017-01-03
Posts: 259

Re: [Solved] PKGBUILD Request: tifig - HEIC/HEIF image converter

graysky wrote:

Settings used for each?  It isn't apples-to-apples... or is it?  We don't have enough info.

OK, I did another test. Settings used were 'default' when not stated:

original: 4.5M : https://my.mixtape.moe/lzlzxb.jpg

guetzli: 1.4M  : 605.67s :  https://my.mixtape.moe/tgguwi.jpg

jpeg-recompress (default): 591K : 2.71s : https://my.mixtape.moe/ezxnoq.jpg

jpeg-recompress ( --quality high --accurate --method smallfry): 1.4M : 0.26s : https://my.mixtape.moe/lgcaqm.jpg

jpeg-archive at high quality and accurate flag is of comparable size as guetzli but at 223x the time decrease.  Is the massive CPU time increase of guetzli worth it? You be the judge.

CPU: i7-4770K CPU @ 3.50GHz with 32GB of RAM

Last edited by Batou (2018-04-09 18:17:52)


Please vote for all the AUR packages you're using. You can mass-vote for all of them by doing: "pacman -Qqm | xargs aurvote -v" (make sure to run "aurvote --configure"  first)

Offline

#10 2018-04-11 01:50:49

Batou
Member
Registered: 2017-01-03
Posts: 259

Re: [Solved] PKGBUILD Request: tifig - HEIC/HEIF image converter

Okay, I finally had an hour or so today so I spent it learning about how to create PKGBUILDs. I've learned a lot and managed to iron out most of the issues I have except for one. This is the PKGBUILD that I wrote:

# Maintainer: Batou
pkgname=tifig-git
pkgver=r73.7dea067
pkgrel=1
pkgdesc="A fast HEIF/HEIC image converter"
arch=("any")
url="https://github.com/monostream/tifig"
license=('Apache License')
depends=('ffmpeg' 'vips' 'cmake')
makedepends=('git')
provides=("${pkgname%-git}")
conflicts=("${pkgname}")
source=('git+https://github.com/monostream/tifig.git')
md5sums=('SKIP')

pkgver() {
	cd "$srcdir/${pkgname%-git}"
	printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
	cd "$srcdir/${pkgname%-git}"
	git submodule update --init --recursive
}

build() {
	cd "$srcdir/${pkgname%-git}"
	mkdir -p "build" && cd "build"
	cmake ..
	make
}

package() {
	cd "$srcdir/${pkgname%-git}/build"
	make DESTDIR="$pkgdir/" install
} 

The issue is that at the end, tar.xz does not contain the binary but a bunch of CMake header files. There are no errors and the binary builds fine. I can't figure out what's wrong.

Could one of you experts please look this over? I'd really like for this package to end up in AUR and would like to learn how to maintain it so i can give back to the community. Thanks!

Last edited by Batou (2018-04-11 05:41:58)


Please vote for all the AUR packages you're using. You can mass-vote for all of them by doing: "pacman -Qqm | xargs aurvote -v" (make sure to run "aurvote --configure"  first)

Offline

#11 2018-04-11 02:22:03

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: [Solved] PKGBUILD Request: tifig - HEIC/HEIF image converter

1) This is not an "any" package, it installs binary executables.

2) See https://wiki.archlinux.org/index.php/VC … Submodules for properly doing submodules in source=()

3) It seems unlikely you need cmake as a runtime depends.

4) Should not conflict itself, should conflict the same thing it provides (the non-git version). Typo? tongue

5) The license is not "Apache License", use the directory name in /usr/share/licenses/common/ -- so that would be just "Apache".

...

As for why there are no files, if you posted a makepkg log this would be more clear (since cmake prints a list of each file as it gets installed), but looking at the upstream CMakeLists.txt I don't think they actually instructed cmake to install the binary... it doesn't use https://cmake.org/cmake/help/latest/com … ng-targets at all.

Last edited by eschwartz (2018-04-11 02:28:05)


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#12 2018-04-11 03:30:25

Batou
Member
Registered: 2017-01-03
Posts: 259

Re: [Solved] PKGBUILD Request: tifig - HEIC/HEIF image converter

THANK YOU Eschwartz!

Eschwartz wrote:

1) This is not an "any" package, it installs binary executables.

Thanks! I replaced it with 'x86_64'. Not sure if there's any point to add i686 since Arch doesn't support it anymore.

2) See https://wiki.archlinux.org/index.php/VC … Submodules for properly doing submodules in source=()

I think I fixed it properly. There are multiple submodules.

3) It seems unlikely you need cmake as a runtime depends.

Right! Moved it over to makedepends.

4) Should not conflict itself, should conflict the same thing it provides (the non-git version). Typo? tongue

LOL... yes.  I switched the provides and conflicts around. Fixed.

5) The license is not "Apache License", use the directory name in /usr/share/licenses/common/ -- so that would be just "Apache".

Got it. Had no idea it was referring to these files.

...

As for why there are no files, if you posted a makepkg log this would be more clear (since cmake prints a list of each file as it gets installed), but looking at the upstream CMakeLists.txt I don't think they actually instructed cmake to install the binary... it doesn't use https://cmake.org/cmake/help/latest/com … ng-targets at all.

OK, how about just using install?

Please take a look. This actually works on my machine! Do I have a winner with this one? LOL smile

# Maintainer: Batou 
pkgname=tifig-git
pkgver=r73.7dea067
pkgrel=1
pkgdesc="A fast HEIF/HEIC image converter"
arch=('x86_64')
url="https://github.com/monostream/tifig"
license=('Apache')
depends=('ffmpeg' 'vips')
makedepends=('git' 'cmake')
provides=("${pkgname}")
conflicts=("${pkgname%-git}")
source=(
	'git+https://github.com/monostream/tifig.git'
)
md5sums=(
	'SKIP'
)

pkgver() {
	cd "$srcdir/${pkgname%-git}"
	printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
  cd "$srcdir/${pkgname%-git}"
  local submodules=(
    'lib/heif'
    'lib/cxxopts'
  )
  for submodule in "${submodules[@]}"; do
    git submodule init "$submodule"
    git config "submodule.$submodule.url" "$srcdir/${submodule##*/}"
    git submodule update "$submodule"
  done
}

build() {
	cd "$srcdir/${pkgname%-git}"
	mkdir -p "build" && cd "build"
	cmake ..
	make
}

package() {
	cd "$srcdir/${pkgname%-git}/build"
	mkdir -p ${pkgdir}/usr/bin
	install -m755 tifig "${pkgdir}/usr/bin"
}

Last edited by Batou (2018-04-11 05:41:44)


Please vote for all the AUR packages you're using. You can mass-vote for all of them by doing: "pacman -Qqm | xargs aurvote -v" (make sure to run "aurvote --configure"  first)

Offline

#13 2018-04-11 03:54:42

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: [Solved] PKGBUILD Request: tifig - HEIC/HEIF image converter

Batou wrote:

2) See https://wiki.archlinux.org/index.php/VC … Submodules for properly doing submodules in source=()

I think I fixed it properly. There are multiple submodules.

No, you still need to download it in the source array too in order to guarantee that the submodules are available in the same directory as the tifig repository.

This would still work if you cloned the repo *outside* of makepkg, but not on other people's computers.

4) Should not conflict itself, should conflict the same thing it provides (the non-git version). Typo? tongue

LOL... yes.  I switched the provides and conflicts around. Fixed.

Well, I meant it should both conflict and provide the non-git version... not that they're switched around. So now it correctly conflicts the non-git version, but incorrectly provides itself (it is itself, it doesn't need to provide it too wink)


As for why there are no files, if you posted a makepkg log this would be more clear (since cmake prints a list of each file as it gets installed), but looking at the upstream CMakeLists.txt I don't think they actually instructed cmake to install the binary... it doesn't use https://cmake.org/cmake/help/latest/com … ng-targets at all.

OK, how about just using install?

This is exactly what I mean, but in addition you may wish to submit an upstream issue asking them to implement this in their CMakeLists.txt


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#14 2018-04-11 04:23:48

Batou
Member
Registered: 2017-01-03
Posts: 259

Re: [Solved] PKGBUILD Request: tifig - HEIC/HEIF image converter

Eschwartz wrote:

No, you still need to download it in the source array too in order to guarantee that the submodules are available in the same directory as the tifig repository.

This would still work if you cloned the repo *outside* of makepkg, but not on other people's computers.

Got it. Added submodules to sources array. I've deleted all of the submodules from my computer and tried it again. Now it downloads them if they're not there to be updated.

Well, I meant it should both conflict and provide the non-git version... not that they're switched around. So now it correctly conflicts the non-git version, but incorrectly provides itself (it is itself, it doesn't need to provide it too wink)

OK, so the soultion is this:


provides=("${pkgname%-git}")
conflicts=("${pkgname%-git}")


This is exactly what I mean, but in addition you may wish to submit an upstream issue asking them to implement this in their CMakeLists.txt

Will do! I'll file a bug with upstream.

So this is what I have now... does this work well for you?

# Maintainer: Batou
pkgname=tifig-git
pkgver=r73.7dea067
pkgrel=1
pkgdesc="A fast HEIF/HEIC image converter"
arch=('x86_64')
url="https://github.com/monostream/tifig"
license=('Apache')
depends=('ffmpeg' 'vips')
makedepends=('git' 'cmake')
provides=("${pkgname%-git}")
conflicts=("${pkgname%-git}")
source=(
	'git+https://github.com/monostream/tifig.git'
	'git+https://github.com/monostream/heif.git'
	'git+https://github.com/jarro2783/cxxopts.git'
)
md5sums=(
	'SKIP'
	'SKIP'
	'SKIP'
)

pkgver() {
	cd "$srcdir/${pkgname%-git}"
	printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
  cd "$srcdir/${pkgname%-git}"
  local submodules=(
    'lib/heif'
    'lib/cxxopts'
  )
  for submodule in "${submodules[@]}"; do
    git submodule init "$submodule"
    git config "submodule.$submodule.url" "$srcdir/${submodule##*/}"
    git submodule update "$submodule"
  done
}

build() {
	cd "$srcdir/${pkgname%-git}"
	mkdir -p "build" && cd "build"
	cmake ..
	make
}

package() {
	cd "$srcdir/${pkgname%-git}/build"
	mkdir -p ${pkgdir}/usr/bin
	install -m755 tifig "${pkgdir}/usr/bin"
}
 

Last edited by Batou (2018-04-11 05:41:27)


Please vote for all the AUR packages you're using. You can mass-vote for all of them by doing: "pacman -Qqm | xargs aurvote -v" (make sure to run "aurvote --configure"  first)

Offline

#15 2018-04-11 04:28:56

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: [Solved] PKGBUILD Request: tifig - HEIC/HEIF image converter

Looks okay. smile Definitely not bad for your first work. smile

I'd optimize the install command to use `install -Dm755` instead of `install -m755` and skip mkdir since one command is better than two -- this also circumvents the issue where you forgot to quote the pkgdir in `mkdir -p ${pkgdir}/usr/bin`


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#16 2018-04-11 04:50:44

Batou
Member
Registered: 2017-01-03
Posts: 259

Re: [Solved] PKGBUILD Request: tifig - HEIC/HEIF image converter

Eschwartz wrote:

Looks okay. smile Definitely not bad for your first work. smile

I'd optimize the install command to use `install -Dm755` instead of `install -m755` and skip mkdir since one command is better than two -- this also circumvents the issue where you forgot to quote the pkgdir in `mkdir -p ${pkgdir}/usr/bin`

I've replaced that package function with this (no hardcoded names):

package() {
    cd "$srcdir/${pkgname%-git}/build"
    install -Dm755 "${pkgname%-git}" "${pkgdir}/usr/bin/${pkgname%-git}"
}

So the final PKGBUILD:

 # Maintainer: Batou 
pkgname=tifig-git
pkgver=r73.7dea067
pkgrel=1
pkgdesc="A fast High Efficiency Image File Format (HEIF/HEIC) converter"
arch=('x86_64')
url="https://github.com/monostream/tifig"
license=('Apache')
depends=('ffmpeg' 'vips')
makedepends=('git' 'cmake')
provides=("${pkgname%-git}")
conflicts=("${pkgname%-git}")
source=(
	'git+https://github.com/monostream/tifig.git'
	'git+https://github.com/monostream/heif.git'
	'git+https://github.com/jarro2783/cxxopts.git'
)
md5sums=(
	'SKIP'
	'SKIP'
	'SKIP'
)

pkgver() {
	cd "$srcdir/${pkgname%-git}"
	printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
  cd "$srcdir/${pkgname%-git}"
  local submodules=(
    'lib/heif'
    'lib/cxxopts'
  )
  for submodule in "${submodules[@]}"; do
    git submodule init "$submodule"
    git config "submodule.$submodule.url" "$srcdir/${submodule##*/}"
    git submodule update "$submodule"
  done
}

build() {
	cd "$srcdir/${pkgname%-git}"
	mkdir -p "build" && cd "build"
	cmake ..
	make
}

package() {
	cd "$srcdir/${pkgname%-git}/build"
	install -Dm755 "${pkgname%-git}" "${pkgdir}/usr/bin/${pkgname%-git}"
}

Thank you again! I couldn't have done it without your help. I'm actually disappointed in myself that I ran into so many issues. It's a quite complex system and I thought it was a bit simpler and rushed over a few things. Info is also spread among 5-6 wiki pages and there are some gotchas. I'm glad I got it in the end. Well worth the effort! Now I can start cleanly adding things I use.

In the next few days when I get some free time I'll tackle another one. I have an HDMI capture dongle that has some working code up on github but it will be more complex since it involves extraction of firmware. I'll start tomorrow afternoon and see how far I get.

Now, how do I get this into AUR? big_smile

Last edited by Batou (2018-04-11 05:41:13)


Please vote for all the AUR packages you're using. You can mass-vote for all of them by doing: "pacman -Qqm | xargs aurvote -v" (make sure to run "aurvote --configure"  first)

Offline

#17 2018-04-11 05:02:56

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: [Solved] PKGBUILD Request: tifig - HEIC/HEIF image converter

https://wiki.archlinux.org/index.php/Ar … g_packages (second & third sections)

Last edited by eschwartz (2018-04-11 05:04:13)


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#18 2018-04-11 05:29:57

Batou
Member
Registered: 2017-01-03
Posts: 259

Re: [Solved] PKGBUILD Request: tifig - HEIC/HEIF image converter

Eschwartz wrote:

It's alive!

https://aur.archlinux.org/packages/tifig-git/

Thanks Eli!

Edit: Bug filed upstream: https://github.com/monostream/tifig/issues/33

Last edited by Batou (2018-04-11 06:15:30)


Please vote for all the AUR packages you're using. You can mass-vote for all of them by doing: "pacman -Qqm | xargs aurvote -v" (make sure to run "aurvote --configure"  first)

Offline

Board footer

Powered by FluxBB