[TH] Image Optimizer [Deleted]

Can you add an option to resize images larger that W x H if admins choose to do so?

Unfortunately that's not really within the scope of what this add-on is meant to do - it intentionally doesn't take any action that changes the appearance of am image (unless you use a lossy provider with high compression). But I don't believe you need an add-on for this, I'm pretty sure XenForo lets you set max dimensions for image attachments by default
 
ThemeHouse updated [TH] Image Optimizer with a new update entry:

Version 1.1.0 released

New Features:
  • Support for multiple providers
    • ReSmush.it (Free API)
    • Kraken (Paid API)
    • jpegoptim (Open source software, must be installed on your server)
    • pngquant (Open source software, must be installed on your server)
  • Status list to show images that have been optimized, their original and new size, and percentage of disk space saved
  • Support for more content types
    • Attachments (as well as any system that uses attachments, such as...

Read the rest of this update entry...
 
I got a lot of errors.. :unsure:

Code:
ErrorException: Unable to determine file MIME type for status ID 1 src/XF/Error.php:75
Generiert durch: McAtze 15. Januar 2019 um 19:28 Uhr

Stapelverfolgung
#0 src/XF.php(189): XF\Error->logError('Unable to deter...', false)
#1 src/addons/ThemeHouse/ImageOptimizer/Service/ImageOptimizer/Optimize.php(32): XF::logError('Unable to deter...')
#2 src/addons/ThemeHouse/ImageOptimizer/ContentHandler/AbstractHandler.php(57): ThemeHouse\ImageOptimizer\Service\ImageOptimizer\Optimize->run()
#3 src/addons/ThemeHouse/ImageOptimizer/ContentHandler/AbstractHandler.php(156): ThemeHouse\ImageOptimizer\ContentHandler\AbstractHandler->optimize(Object(ThemeHouse\ImageOptimizer\Entity\Status))
#4 src/addons/ThemeHouse/ImageOptimizer/ImageOptimizer.php(103): ThemeHouse\ImageOptimizer\ContentHandler\AbstractHandler->createStatusAndOptimize(Object(ThemeHouse\ImageOptimizer\XF\Entity\AttachmentData))
#5 src/addons/ThemeHouse/ImageOptimizer/ImageOptimizer.php(34): ThemeHouse\ImageOptimizer\ImageOptimizer->optimizeEntity('attachment', Object(ThemeHouse\ImageOptimizer\XF\Entity\AttachmentData))
#6 src/addons/ThemeHouse/ImageOptimizer/XF/Service/Attachment/Preparer.php(15): ThemeHouse\ImageOptimizer\ImageOptimizer::optimize('attachment', Object(ThemeHouse\ImageOptimizer\XF\Entity\AttachmentData))
#7 src/XF/Service/Attachment/Preparer.php(23): ThemeHouse\ImageOptimizer\XF\Service\Attachment\Preparer->insertDataFromFile(Object(XF\FileWrapper), 1, Array)
#8 src/XF/Attachment/Manipulator.php(170): XF\Service\Attachment\Preparer->insertAttachment(Object(XFMG\Attachment\Media), Object(XF\FileWrapper), Object(SV\WarningImprovements\XF\Entity\User), '6727c0b7bc62ed2...')
#9 src/XF/Pub/Controller/Attachment.php(88): XF\Attachment\Manipulator->insertAttachmentFromUpload(Object(XF\Http\Upload), NULL)
#10 src/XF/Mvc/Dispatcher.php(321): XF\Pub\Controller\Attachment->actionUpload(Object(XF\Mvc\ParameterBag))
#11 src/XF/Mvc/Dispatcher.php(244): XF\Mvc\Dispatcher->dispatchClass('XF:Attachment', 'Upload', Object(XF\Mvc\RouteMatch), Object(Xfrocks\AttachmentStore\XF\Pub\Controller\Attachment), NULL)
#12 src/XF/Mvc/Dispatcher.php(100): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(Xfrocks\AttachmentStore\XF\Pub\Controller\Attachment), NULL)
#13 src/XF/Mvc/Dispatcher.php(50): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#14 src/XF/App.php(2177): XF\Mvc\Dispatcher->run()
#15 src/XF.php(392): XF\App->run()
#16 index.php(20): XF::runApp('XF\\Pub\\App')
#17 {main}

Benötigter Status
array(4) {
  ["url"] => string(96) "/attachments/upload?type=xfmg_media&context[category_id]=1&hash=6727c0b7bc62ed2871443ab79ed1872d"
  ["referrer"] => string(63) "https://www.xentutorials.com/media/categories/screenshots.1/add"
  ["_GET"] => array(3) {
    ["type"] => string(10) "xfmg_media"
    ["context"] => array(1) {
      ["category_id"] => string(1) "1"
    }
    ["hash"] => string(32) "6727c0b7bc62ed2871443ab79ed1872d"
  }
  ["_POST"] => array(11) {
    ["_xfToken"] => string(8) "********"
    ["_xfResponseType"] => string(4) "json"
    ["_xfWithData"] => string(1) "1"
    ["flowChunkNumber"] => string(1) "1"
    ["flowChunkSize"] => string(10) "4294967296"
    ["flowCurrentChunkSize"] => string(6) "213479"
    ["flowTotalSize"] => string(6) "213479"
    ["flowIdentifier"] => string(36) "213479-Screenshot2019-01-14211500png"
    ["flowFilename"] => string(34) "Screenshot 2019-01-14 21.15.00.png"
    ["flowRelativePath"] => string(34) "Screenshot 2019-01-14 21.15.00.png"
    ["flowTotalChunks"] => string(1) "1"
  }
}
Code:
ErrorException: [E_WARNING] getimagesize(): Filename cannot be empty src/addons/ThemeHouse/ImageOptimizer/Repository/Image.php:116
Generiert durch: Unbekanntes Benutzerkonto 15. Januar 2019 um 19:28 Uhr

Stapelverfolgung
#0 [internal function]: XF::handlePhpError(2, '[E_WARNING] get...', '/var/www/vhosts...', 116, Array)
#1 src/addons/ThemeHouse/ImageOptimizer/Repository/Image.php(116): getimagesize('')
#2 src/addons/ThemeHouse/ImageOptimizer/ImageOptimizer/Traits/ExecutableProviderTrait.php(30): ThemeHouse\ImageOptimizer\Repository\Image->fetchImageDataFromLocal(false)
#3 src/addons/ThemeHouse/ImageOptimizer/Service/ImageOptimizer/Optimize.php(43): ThemeHouse\ImageOptimizer\ImageOptimizer\Pngquant->optimizeImage(Object(ThemeHouse\ImageOptimizer\Service\ImageOptimizer\Optimize))
#4 src/addons/ThemeHouse/ImageOptimizer/ContentHandler/AbstractHandler.php(57): ThemeHouse\ImageOptimizer\Service\ImageOptimizer\Optimize->run()
#5 src/addons/ThemeHouse/ImageOptimizer/Cron/Optimize.php(18): ThemeHouse\ImageOptimizer\ContentHandler\AbstractHandler->optimize(Object(ThemeHouse\ImageOptimizer\Entity\Status))
#6 [internal function]: ThemeHouse\ImageOptimizer\Cron\Optimize::optimizeImages(Object(XF\Entity\CronEntry))
#7 src/XF/Job/Cron.php(34): call_user_func(Array, Object(XF\Entity\CronEntry))
#8 src/XF/Job/Manager.php(253): XF\Job\Cron->run(G)
#9 src/XF/Job/Manager.php(195): XF\Job\Manager->runJobInternal(Array, G)
#10 src/XF/Job/Manager.php(79): XF\Job\Manager->runJobEntry(Array, G)
#11 job.php(42): XF\Job\Manager->runQueue(false, 8)
#12 {main}

Benötigter Status
array(4) {
  ["url"] => string(8) "/job.php"
  ["referrer"] => string(73) "https://www.xentutorials.com/media/screenshot-2019-01-14-21-15-00-png.14/"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}
Code:
ErrorException: [Image Optimizer] Error received for status ID 1: Pngquant failed to optimize image with response code 127 src/XF/Error.php:75
Generiert durch: Unbekanntes Benutzerkonto 15. Januar 2019 um 19:28 Uhr

Stapelverfolgung
#0 src/XF.php(189): XF\Error->logError('[Image Optimize...', false)
#1 src/addons/ThemeHouse/ImageOptimizer/ImageOptimizer/Traits/ExecutableProviderTrait.php(24): XF::logError('[Image Optimize...')
#2 src/addons/ThemeHouse/ImageOptimizer/Service/ImageOptimizer/Optimize.php(43): ThemeHouse\ImageOptimizer\ImageOptimizer\Pngquant->optimizeImage(Object(ThemeHouse\ImageOptimizer\Service\ImageOptimizer\Optimize))
#3 src/addons/ThemeHouse/ImageOptimizer/ContentHandler/AbstractHandler.php(57): ThemeHouse\ImageOptimizer\Service\ImageOptimizer\Optimize->run()
#4 src/addons/ThemeHouse/ImageOptimizer/Cron/Optimize.php(18): ThemeHouse\ImageOptimizer\ContentHandler\AbstractHandler->optimize(Object(ThemeHouse\ImageOptimizer\Entity\Status))
#5 [internal function]: ThemeHouse\ImageOptimizer\Cron\Optimize::optimizeImages(Object(XF\Entity\CronEntry))
#6 src/XF/Job/Cron.php(34): call_user_func(Array, Object(XF\Entity\CronEntry))
#7 src/XF/Job/Manager.php(253): XF\Job\Cron->run(G)
#8 src/XF/Job/Manager.php(195): XF\Job\Manager->runJobInternal(Array, G)
#9 src/XF/Job/Manager.php(79): XF\Job\Manager->runJobEntry(Array, G)
#10 job.php(42): XF\Job\Manager->runQueue(false, 8)
#11 {main}

Benötigter Status
array(4) {
  ["url"] => string(8) "/job.php"
  ["referrer"] => string(73) "https://www.xentutorials.com/media/screenshot-2019-01-14-21-15-00-png.14/"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}
 

Attachments

  • Screenshot 2019-01-15 20.33.18.webp
    Screenshot 2019-01-15 20.33.18.webp
    59.7 KB · Views: 10
The unable to determine MIME type error is just something we log for informational purposes, and typically means that getimagesize didn't return a valid value for this, this may be safe to ignore, but to be sure could you create a ticket at themehouse.com with cPanel details?

getimagesize(): Filename cannot be empty is happening because, for some reason, the file doesn't exist. As above, if you can get us cPanel details we should be able to debug this further for you

response code 127 indicates that either pngquant isn't installed, or the path to it is incorrect, if you left it as the default value make sure that pngquant is in $PATH, (you can test this by running which pngquant in SSH) I'd recommend setting this to the full path to the binary to prevent issues like this from occurring though.
 
@Jake B. i use Plesk Onyx instead of cPanel. The pngquant issue is my fault, cause false entry in open_basedir. I will create a ticket at ThemeHouse..
 
@mcatze just saw in the logs the same error you have:

Code:
Unable to determine file MIME type for status ID 3
src/XF/Error.php:75
 
HI

Besides this error in the log, there is a couple of thinks I would like to comment.

Cron:

I thought that cron would optimize older images, but's it's not working. I disabled the addon, added a new image to a post, force the Image Optimize cron and enabled the addon. Nothing append!

Provider:

I would like to suggest a new local provider: gifsicle -> https://www.lcdf.org/gifsicle/

Proxy:

I would like to suggest that proxied images should be resized to W x H from Options -> Attachments -> Maximum attachment image dimensions
 
Last edited:
@mcatze just saw in the logs the same error you have:

Could you create a ticket at themehouse.com with XenForo Admin and cPanel details so we can collect as much information on this error as possible? I've tried a few different things locally but haven't been able to replicate it
 
I thought that cron would optimize older images, but's it's not working. I disabled the addon, added a new image to a post, force the Image Optimize cron and enabled the addon. Nothing append!

The cron will not retroactively work on older images, if you want to optimize old images you'll need to go to Tools -> Rebuild caches and run the job from there. I'd recommend creating a backup of both the database and the file system before running this though

I would like to suggest a new local provider: gifsicle -> https://www.lcdf.org/gifsicle/

We actually have an issue for this: https://github.com/Audentio/xf2addon-issues/issues/1316

I would like to suggest that proxied images should be resized to W x H from Options -> Attachments -> Maximum attachment image dimensions

Modifying the dimensions of an image isn't really in the scope of what this add-on is meant to do, we can potentially look into this for a separate add-on though if there is demand
 
Top Bottom