OiO.lk Blog pdf Converting pdf to avif with Imagick results in images that dont display in Safari
pdf

Converting pdf to avif with Imagick results in images that dont display in Safari


I use Imagick to convert pdf-files to avif files. It is done in a container and I install imagemagick, imagemagick-pdf and imagemagick-heic.

My initial approach was magick -density 600 ./$f -resize 400x ./output/${f%.*}.avi but this resulted in blank images when viewied in Safari.

After a bit of trial an error I managed to get a result with magick -density 600 ./$f -resize 400x -alpha off ./output/${f%.*}.avi, but then some images got a black background. I tried setting the background to white magick -density 600 ./$f -resize 400x -background white -alpha background ./output/${f%.*}.avi, but then we were back to blank images.

The solution was to use -alpha remove:
magick -density 600 ./$f -resize 400x -alpha remove ./output/${f%.*}.avi.

So I have something that works, but it is a result of trial an error.

I would like to understand if this is a bug with avif in Safari. I would also like to know if there is a more robust way of doing this.



You need to sign in to view this answers

Exit mobile version