support for .avif images

50 views
Skip to first unread message

tlahuizcalpantecutli

unread,
Jan 30, 2024, 6:03:18 PM1/30/24
to Gallery 3 Users
Team, I confess my sin: I patched (poorly) my gallery 3.1.5 installation to allow images in the .avif format to be uploaded and displayed.
A user came up with these .avif files which incidentally, and much to my surprise, proved to be smaller than the equivalent .webp, that I believed to be the crème de la crème of compactness.  And we can't visually detect any difference in quality either... which only shows how little I know.

This is what I did:
- I added '  ,”avif" => "image/avif"' to /modules/gallery/helpers/legal_file.php, line 42
- I added " , IMAGETYPE_AVIF => 'avif'," to /system/libraries/Image.php, line 34
- I commented out the 'if' at /system/libraries/Image.php, lines 57 & 58, to avoid the rejection due to invalid file type.  Ugly, I know, but I couldn't find a way to convince this routine to accept .avif and in my impatience, I erased this control... so sue me.
If anyone has a better suggestion other than for me to keep my fingers out of gallery3, I'd appreciate your comments.

Best regards,

t

Stian Lund

unread,
Mar 7, 2026, 7:14:09 AMMar 7
to Gallery 3 Users
Hi, I guess I need to dig this subject up :)

AVIFs are quite new so I wasn't sure if Gallery3 would ever work with it, 

I've been trying the exact same thing, and I can't make it work.
However, I couldn't find any "if" statement on lines 57-58 of Image.php so I assume you meant these lines - 96-97?

if ( ! isset(Image::$allowed_types[$image_info[2]]))
throw new Kohana_Exception('The specified image, :type:, is not an allowed image type.', array(':type:' => $image));

Still, commenting these lines out didn't help, and I suspect the issue on my system lies deeper in the code or in underlying libraries. 
The error in the logs does not seem to indicate it hits this exception.

In fact the same procedure was used by Brad years ago to add support for WebP images and they work just fine, even WebP animations.

I've tried disabling all modules as well in case the problem was caused there, it didn't help.

Some info about the system:
PHP Version 8.1.34 (old...)
Debian 6.1.140-1 (2025-05-22) x86_64
nginx/1.22.1 (Problem might lie there but it works for all other image types)
Imagick 3.8.1, AVIF listed under supported formats
GD 2.3.3 (not used), AVIF Support is enabled

The main problem here is that this is a shared system (sdf.org), so I can't really update anything myself without nagging the admins and they are really slow.

The error received in the log related to "ORM Validation" but I'm way out of my depth when it comes to this stuff...

2026-03-07 12:46:51 +01:00 --- error: ORM Validation has failed for items model
#0 /gallery/system/libraries/ORM.php(755): ORM_Validation_Exception_Core::handle_validation()
#1 /gallery/modules/gallery/models/item.php(900): ORM_Core->validate()
#2 /gallery/system/libraries/ORM.php(778): Item_Model_Core->validate()
#3 /gallery/modules/gallery/libraries/MY_ORM.php(34): ORM_Core->save()
#4 /gallery/modules/gallery/libraries/ORM_MPTT.php(76): ORM->save()
#5 /gallery/modules/gallery/models/item.php(397): ORM_MPTT_Core->save()
#6 /gallery/modules/gallery/controllers/uploader.php(192): Item_Model_Core->save()
#7 /gallery/modules/gallery/controllers/uploader.php(62): Uploader_Controller->_add_item()
#8 [internal function]: Uploader_Controller->add_photo()
#9 /gallery/system/core/Kohana.php(302): ReflectionMethod->invokeArgs()
#10 /gallery/system/core/Event.php(208): Kohana_Core::instance()
#11 /gallery/application/Bootstrap.php(67): Event_Core::run()
#12 /gallery/index.php(124): require('...')
#13 {main}
2026-03-07 12:46:51 +01:00 --- error: Validation errors: Array
(
    [mime_type] => invalid
    [name] => invalid_data_file
)


It IS able to extract the thumbnail during the upload, so I'm assuming the ImageMagick library does that correctly.
Clipboard_03-07-2026_01.jpg

Hope someone has some idea :)

regards,
Stian

Info.RockEdge

unread,
Mar 10, 2026, 5:42:13 PM (12 days ago) Mar 10
to gallery...@googlegroups.com

have you tried finding where the array is populated for allowed image types? 

Perhaps adding AVIF to the array stack might work if the Gallery 3 site is using Imagick

--
WHEN USING AN EMAIL PROGRAM to reply to this message, click REPLY TO LIST or REPLY TO ALL so your reply goes out to everyone in the group. If you click REPLY or REPLY TO SENDER Google will *only* send your reply to the original author (not recommended).
 
To post a NEW MESSAGE to the group, send an new email to:
gallery...@googlegroups.com
 
To view or sign in to this group on the web, use this URL:
https://groups.google.com/forum/#!forum/gallery-3-users
---
You received this message because you are subscribed to the Google Groups "Gallery 3 Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gallery-3-use...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/gallery-3-users/86938bd4-84ab-4b80-b409-4074059fb376n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages