strukturag / libheif

libheif is an HEIF and AVIF file format decoder and encoder.
Other
1.74k stars 301 forks source link

How encode multiple images? #703

Closed Kitsune2222 closed 1 year ago

Kitsune2222 commented 1 year ago

Actually the question is in the title, I did not find instructions, but the possibility is stated.

farindk commented 1 year ago

Have a look into issue #702. There is example code there.

Kitsune2222 commented 1 year ago

It turns out that I did everything right, I made a mistake in the decoder of several images and it displayed the first one. Thank you.

P.s. another question Code:

int width = 1050;
int height = 1500;
err = heif_image_create(width, height, heif_colorspace_RGB, heif_chroma_interleaved_RGBA, &img);
err = heif_image_add_plane(img, heif_channel_interleaved, width, height, 32);
int stride;
uint8 *enc_image = heif_image_get_plane(img, heif_channel_interleaved, &stride);

but stride is 4208, (1050*4=4200) it's 8 bytes more than it should be, is this normal? Final image resolution is correct 1050x1500.

bigcat88 commented 1 year ago

@Kitsune2222 it is a padding, all is fine

Kitsune2222 commented 1 year ago

Thanks for the quick response

pikatchu2k3 commented 1 year ago

Have a look into issue #702. There is example code there.

Sorry for typing into a closed thread. I am a basic Linux user and couldn´t figure out what I exactly have to do, when I want to convert multiple jpg files in a folder into Avif. helf-enc is not able to work with * .

silverbacknet commented 1 year ago

That's just basic shellcode:

for input in *; do
  heif-enc [args] "$input"
done

You can put it all on one line, between semicolons, if you want a one-liner: for input in *; do heif-enc [args] "$input"; done