XF 1.4 Invalid image type while rebuilding attachments


@AndyB @Mike @Chris D I ran a google search and read this thread:


That thread is exactly what I am experiencing, except my issue has not been resolved.

I ran this query first by Mike:

SELECT xf_attachment_data.*, xf_attachment.attachment_id, xf_attachment.*
FROM xf_attachment_data
INNER JOIN xf_attachment ON xf_attachment.data_id = xf_attachment_data.data_id
WHERE filename LIKE '%.bmp'
I went through and removed every BMP file (7) from the site and ran the query again. This is the result of the second running.

MySQL returned an empty result set (i.e. zero rows). (Query took 0.0002 sec)

The issue persisted when I attempted to rebuild the caches again so I ran this query by Andy:

SELECT xf_attachment_data.data_id, xf_attachment_data.filename, xf_attachment.attachment_id, xf_attachment.content_id
FROM xf_attachment_data
INNER JOIN xf_attachment ON xf_attachment.data_id = xf_attachment_data.data_id
WHERE filename LIKE '%bmp%'
This displayed an additional 12 images that had fullscreenshot3-BMP.jpg as the ending file. I went in and removed them all as well. I then ran the query again and got the same message.

MySQL returned an empty result set (i.e. zero rows). (Query took 0.0001 sec)

I still can't rebuild the caches. This displays every time I run it:

Server Error

Invalid image type given. Expects IMAGETYPE_XXX constant.

call_user_func() in XenForo/Image/Abstract.php at line 254
XenForo_Image_Abstract::createFromFile() in XenForo/Deferred/AttachmentThumb.php at line 38
XenForo_Deferred_AttachmentThumb->execute() in XenForo/Model/Deferred.php at line 256
XenForo_Model_Deferred->runDeferred() in XenForo/Model/Deferred.php at line 390
XenForo_Model_Deferred->_runInternal() in XenForo/Model/Deferred.php at line 335
XenForo_Model_Deferred->run() in XenForo/ControllerAdmin/Tools.php at line 159
XenForo_ControllerAdmin_Tools->actionRunDeferred() in XenForo/FrontController.php at line 347
XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 134
XenForo_FrontController->run() in /home/iguana11/public_html/admin.php at line 13
I went in and emptied the TMP folder to make sure that wasn't causing the issue. It wasn't. The issue persists. This is my attachment stuff:

file size: 4096
per message: 10


max size: 1600 x 1600
flash uploader enabled

Any ideas?

Jake Bunce

XenForo moderator
Staff member
The problem was a TIFF image mislabeled as a PNG. I ran into a few instances of this. So to "avoid" the problem I edited this file:


I replaced this line:

if ($imageInfo)
...with this:

if ($imageInfo AND in_array($imageInfo[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG)))
This allowed the rebuild to finish by not attempting to resize images outside of those 3 types.

Maybe the devs would like to consider implementing a check like this in the default code rather than letting the image handler throw an exception on image types that it is not equipped to handle. Or perhaps something less obstructive than the current exception...

@Chris D

Tracy Perry

Well-known member
What would be nice, if they are going to have to change the code up - if possible, to send an alert in the log to let the administrator know what image it was having problems with so actions can be taken to resolve it.