1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.3 Invalid image type while rebuilding attachments

Discussion in 'Troubleshooting and Problems' started by Renegade, Mar 15, 2014.

  1. Renegade

    Renegade Well-Known Member

    I ran rebuild attachments and it got stuck with the following error. Now I cannot install or uninstall anything till this rebuild is complete. How do I resolve this?

    XenForo_Exception: Invalid image type given. Expects IMAGETYPE_XXX constant. - library/XenForo/Image/Gd.php:100
    Generated By: Admin, 2 minutes ago
    Stack Trace
    #0 [internal function]: XenForo_Image_Gd::createFromFileDirect('/home/techencl/...', 6)
    #1 /home/techencl/public_html/community/library/XenForo/Image/Abstract.php(254): call_user_func(Array, '/home/techencl/...', 6)
    #2 /home/techencl/public_html/community/library/XenForo/Deferred/AttachmentThumb.php(38): XenForo_Image_Abstract::createFromFile('/home/techencl/...', 6)
    #3 /home/techencl/public_html/community/library/XenForo/Model/Deferred.php(256): XenForo_Deferred_AttachmentThumb->execute(Array, Array, 7.99999403954, '')
    #4 /home/techencl/public_html/community/library/XenForo/Model/Deferred.php(390): XenForo_Model_Deferred->runDeferred(Array, 7.99999403954, '', false)
    #5 /home/techencl/public_html/community/library/XenForo/Model/Deferred.php(335): XenForo_Model_Deferred->_runInternal(Array, NULL, '', false)
    #6 /home/techencl/public_html/community/library/XenForo/ControllerAdmin/Tools.php(159): XenForo_Model_Deferred->run(true, NULL, '', false)
    #7 /home/techencl/public_html/community/library/XenForo/FrontController.php(347): XenForo_ControllerAdmin_Tools->actionRunDeferred()
    #8 /home/techencl/public_html/community/library/XenForo/FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
    #9 /home/techencl/public_html/community/admin.php(13): XenForo_FrontController->run()
    #10 {main}
  2. Brogan

    Brogan XenForo Moderator Staff Member

    Are you able to determine which actual image it is from the full stack trace?
    Does it give the complete path?
  3. Mike

    Mike XenForo Developer Staff Member

    It appears to be a BMP file, but the system is saying that it already had a thumb generated.

    Just to check, do you have any add-ons that accept attachments?
  4. Renegade

    Renegade Well-Known Member

    I am not sure how to do that. It doesn't show in the error logs.

    I have the following add-ons installed that have anything to do with attachments
    • Convert image all - converts linked images to attachments
    • sonnb - XenGallery - image gallery for xenforo which imports attachments into gallery
    • [oxy] News Portal - picks up attachments and resizes to show on portal
  5. AndyB

    AndyB Well-Known Member

    I just checked my add-on "Convert Image All" and it does convert hot linked bmp images to attachments.

    You can use phpMyAdmin to find bmp images. Run this SQL query in phpMyAdmin.

    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%'
    Each file that ends with .bmp file will need to be converted to a jpg.

    Use the content_id number which is the post number to go to the post. Once at the post, either delete or convert the bmp to a jpg.

    On my server I had three bmp files out of 350,000 attachments, hopefully yours will only have one or two also.
    Last edited: Mar 15, 2014
  6. Chris D

    Chris D XenForo Developer Staff Member

    I'd recommend changing your add-on so it only handles the image types that XF does by default.
  7. Mike

    Mike XenForo Developer Staff Member

    It's ok if it converts it -- but it can't thumbnaili it unexpectedly (that would require some forced manipulation I think).

    (We could potentially support bmp without a significant issue, but seriously - don't use bmp on the internet. It's like using a wav file instead of an mp3.)

    I would be curious about the file in question and how it got into the system though, so that query is useful, though I'd probably run:

    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'
    So we get the full details.
  8. AndyB

    AndyB Well-Known Member

    At this time my add-on "Convert Image All" will convert all image files, that's how it got into the system. The add-on takes hot linked images and makes them into attachments.
  9. Renegade

    Renegade Well-Known Member

    Thanks Andy and Mike. There are 10 such files.

    @Mike - do you still need all the details now that Andy has clarified how they got in.
  10. Mike

    Mike XenForo Developer Staff Member

    I would like to see the data from that query if possible.
  11. Renegade

    Renegade Well-Known Member

    Data from the query. Assuming you dont need the headers. :p

    10856;"26639";"1336042815";"Msinfo 1.bmp";"1769526";"ea5e514360b4df2c7dded3bc2846d757";"0";"0";"0";"0";"1";"11564";"11564";"10856";"post";"1638640";"1336042815";;"0";"10"
    10857;"26639";"1336043378";"MSinfo 2.bmp";"1769526";"d8d037776372ab8913f2bd55a3a48d04";"0";"0";"0";"0";"1";"11565";"11565";"10857";"post";"1638640";"1336043378";;"0";"6"
    10858;"26639";"1336043823";"Msinfo 3.bmp";"1769526";"534de93d35bbc4e136c6fa78f3222f22";"0";"0";"0";"0";"1";"11566";"11566";"10858";"post";"1638640";"1336043823";;"0";"9"
  12. Mike

    Mike XenForo Developer Staff Member

    The headers would help so I know what each column is. :)
  13. Renegade

    Renegade Well-Known Member

    I didnt save them and now I have cleaned up the images. I will simulate it and then run the query.

Share This Page