Skip to content

approaches to removing alpha channel (CLI) #3589

Answered by jcupitt
jrochkind asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @jrochkind,

In python it's just:

if image.hasalpha():
    image = image.flatten()

Ruby is something like:

image = image.flatten if image.has_alpha?

The libvips CLI is deliberately very basic. The idea was that anything fancy should be done in a proper scripting language anyway, so there's no point implementing a complete CLI environment. It's much better to make the library easy to bind to, and then pass the programming on to some other system.

libvips will flatten automatically if the destination format does not support alpha, but you're right, there's no way to force a flatten.

You can vipsthumbnail to a pipe with eg.:

$ vipsthumbnail k2.jpg -o .png | cat >x.png

Or even:

$ cat k2.jp…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@jrochkind
Comment options

@jcupitt
Comment options

@jrochkind
Comment options

@jcupitt
Comment options

@jrochkind
Comment options

Answer selected by jrochkind
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants