Prefer AVIF to WebP encoding

This commit is contained in:
Gabriel Arazas 2023-05-15 13:25:45 +08:00
parent 316ee79445
commit c08511a1ce
No known key found for this signature in database
GPG Key ID: ADE0C41DAB221FCC
24 changed files with 7 additions and 6 deletions

View File

@ -18,7 +18,7 @@ Otherwise, you might have to manually install the following components:
- link:https://git.sr.ht/~sircmpwn/openring[openring] for generating a webring which is used on the site homepage. - link:https://git.sr.ht/~sircmpwn/openring[openring] for generating a webring which is used on the site homepage.
- link:https://imagemagick.org/[ImageMagick] for processing the image files. - link:https://imagemagick.org/[ImageMagick] for processing the image files.
With the things installed, you can just clone the Git repo of this project, run `make serve`, and voila! With the things installed, you can just clone the Git repo of this project, run `rake serve`, and voila!
You're now a content creator! You're now a content creator!
Most of the usual tasks done with this project should be handled by this project already which is listed in its link:./Rakefile[Rakefile]. Most of the usual tasks done with this project should be handled by this project already which is listed in its link:./Rakefile[Rakefile].
@ -162,12 +162,13 @@ Once it is done, a rebase should be done with a squashed commit publishing the c
- The link:./assets/svg/avatars[avatar images] are processed with ImageMagick. - The link:./assets/svg/avatars[avatar images] are processed with ImageMagick.
Furthermore, they should be optimized. Furthermore, they should be optimized.
The simple avatar designs such as link:./assets/svg/avatars/ezran/default.svg[./assets/svg/avatars/ezran/default.svg] can be reduced and optimized up to 90% of its quality. The simple avatar designs such as link:./assets/svg/avatars/ezran/default.svg[./assets/svg/avatars/ezran/default.svg] can be reduced and optimized up to 90% of its quality.
Though, this depends on the encoding of the format (e.g., WebP, AVIF).
The following command should show how it is done. The following command should show how it is done.
+ +
-- --
[source, shell] [source, shell]
---- ----
magick convert $AVATAR -quality 10 $AVATAR_OUTPUT magick convert $AVATAR -quality 30 $AVATAR_OUTPUT
---- ----
-- --

View File

@ -24,10 +24,10 @@ end
desc 'Export the avatar images' desc 'Export the avatar images'
task :export_avatars, [:base_dir, :output_dir, :output_extension] do |_, args| task :export_avatars, [:base_dir, :output_dir, :output_extension] do |_, args|
args.with_defaults(base_dir: './assets/svg/', output_dir: './static/icons/', output_extension: 'webp') args.with_defaults(base_dir: './assets/svg/', output_dir: './static/icons/', output_extension: 'avif')
Dir.glob('avatars/**/*.svg', base: args.base_dir) do |f| Dir.glob('avatars/**/*.svg', base: args.base_dir) do |f|
output_file = "#{File.dirname(f)}/#{File.basename(f, '.svg')}.#{args.output_extension}" output_file = "#{File.dirname(f)}/#{File.basename(f, '.svg')}.#{args.output_extension}"
sh "magick #{args.base_dir}#{f} -quality 10 #{args.output_dir}#{output_file}" sh "magick #{args.base_dir}#{f} -quality 30 #{args.output_dir}#{output_file}"
end end
end end

View File

@ -21,7 +21,7 @@ reproducible = true
stem = "latexmath" stem = "latexmath"
avatarsdir = "/icons/avatars" avatarsdir = "/icons/avatars"
avatarstype = "webp" avatarstype = "avif"
icons = "image" icons = "image"
iconsdir = "/icons/asciidoctor" iconsdir = "/icons/asciidoctor"

View File

@ -6,7 +6,7 @@ class ChatBlock < Asciidoctor::Extensions::BlockProcessor
named :chat named :chat
on_context :example on_context :example
name_positional_attributes 'avatar', 'state' name_positional_attributes 'avatar', 'state'
default_attributes 'state' => 'default', 'avatarstype' => 'webp' default_attributes 'state' => 'default', 'avatarstype' => 'avif'
def process(parent, reader, attrs) def process(parent, reader, attrs)
block = create_block parent, :pass, nil, attrs, content_model: :compound block = create_block parent, :pass, nil, attrs, content_model: :compound

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB