[TH] Image Optimizer [Deleted]

I'd definitely recommend installing jpegoptim and pngquant on your server and configuring these two providers to run before ReSmush, they're both free and open source and you or your host should be able to install them on your server without much trouble. You'll also get much better performance out of installing them locally as there won't be an unnecessary remote connection to optimize the images :)

I tried it again with smaller image. Original size 2.9Mb optimized to 2.3Mb, disk space saved 613.4kb (21%). I was hoping it would be possible to reduce the file size further. Is that possible with ReSmush, to configure the optimization settings?
 
Is that possible with ReSmush, to configure the optimization settings?

We have an issue to support some more options with ReSmush in a future update, right now it keeps everything as the default. If you use jpegoptiom (which is what ReSmush will ultimately end up using for JPEG images) you can configure the compression level to further reduce the image size
 
We have an issue to support some more options with ReSmush in a future update, right now it keeps everything as the default. If you use jpegoptiom (which is what ReSmush will ultimately end up using for JPEG images) you can configure the compression level to further reduce the image size

Ok I will install the other services to gain more configuration settings. Thanks so much you guys have been great.
 
@Jake B. i am sorry, but i got another error..
Code:
InvalidArgumentException: Failed to convert to JSON. Error: Malformed UTF-8 characters, possibly incorrectly encoded [exif_data] src/XF/Mvc/Entity/Entity.php:740
Generiert durch: McAtze 18. Januar 2019 um 20:57 Uhr

Stapelverfolgung
#0 src/XF/Mvc/Entity/Entity.php(618): XF\Mvc\Entity\Entity->_castValueToType(Array, 'exif_data', 65552, Array)
#1 src/XF/Mvc/Entity/Entity.php(548): XF\Mvc\Entity\Entity->set('exif_data', Array)
#2 src/addons/XFMG/Service/Media/TempCreator.php(108): XF\Mvc\Entity\Entity->__set('exif_data', Array)
#3 src/addons/XFMG/Attachment/Media.php(138): XFMG\Service\Media\TempCreator->setExif(Array)
#4 src/XF/Service/Attachment/Preparer.php(232): XFMG\Attachment\Media->onNewAttachment(Object(XF\Entity\Attachment), Object(XF\FileWrapper))
#5 src/XF/Service/Attachment/Preparer.php(24): XF\Service\Attachment\Preparer->insertTemporaryAttachment(Object(XFMG\Attachment\Media), Object(ThemeHouse\ImageOptimizer\XF\Entity\AttachmentData), '10cde1f5d8e2662...', Object(XF\FileWrapper))
#6 src/XF/Attachment/Manipulator.php(170): XF\Service\Attachment\Preparer->insertAttachment(Object(XFMG\Attachment\Media), Object(XF\FileWrapper), Object(SV\WarningImprovements\XF\Entity\User), '10cde1f5d8e2662...')
#7 src/XF/Pub/Controller/Attachment.php(88): XF\Attachment\Manipulator->insertAttachmentFromUpload(Object(XF\Http\Upload), NULL)
#8 src/XF/Mvc/Dispatcher.php(321): XF\Pub\Controller\Attachment->actionUpload(Object(XF\Mvc\ParameterBag))
#9 src/XF/Mvc/Dispatcher.php(248): XF\Mvc\Dispatcher->dispatchClass('XF:Attachment', 'Upload', Object(XF\Mvc\RouteMatch), Object(Xfrocks\AttachmentStore\XF\Pub\Controller\Attachment), NULL)
#10 src/XF/Mvc/Dispatcher.php(100): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(Xfrocks\AttachmentStore\XF\Pub\Controller\Attachment), NULL)
#11 src/XF/Mvc/Dispatcher.php(50): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#12 src/XF/App.php(2177): XF\Mvc\Dispatcher->run()
#13 src/XF.php(392): XF\App->run()
#14 index.php(20): XF::runApp('XF\\Pub\\App')
#15 {main}

-------------

Previous InvalidArgumentException: Failed to convert to JSON. Error: Malformed UTF-8 characters, possibly incorrectly encoded - src/XF/Mvc/Entity/ValueFormatter.php:164
#0 src/XF/Mvc/Entity/Entity.php(736): XF\Mvc\Entity\ValueFormatter->castValueToType(Array, 65552, Array)
#1 src/XF/Mvc/Entity/Entity.php(618): XF\Mvc\Entity\Entity->_castValueToType(Array, 'exif_data', 65552, Array)
#2 src/XF/Mvc/Entity/Entity.php(548): XF\Mvc\Entity\Entity->set('exif_data', Array)
#3 src/addons/XFMG/Service/Media/TempCreator.php(108): XF\Mvc\Entity\Entity->__set('exif_data', Array)
#4 src/addons/XFMG/Attachment/Media.php(138): XFMG\Service\Media\TempCreator->setExif(Array)
#5 src/XF/Service/Attachment/Preparer.php(232): XFMG\Attachment\Media->onNewAttachment(Object(XF\Entity\Attachment), Object(XF\FileWrapper))
#6 src/XF/Service/Attachment/Preparer.php(24): XF\Service\Attachment\Preparer->insertTemporaryAttachment(Object(XFMG\Attachment\Media), Object(ThemeHouse\ImageOptimizer\XF\Entity\AttachmentData), '10cde1f5d8e2662...', Object(XF\FileWrapper))
#7 src/XF/Attachment/Manipulator.php(170): XF\Service\Attachment\Preparer->insertAttachment(Object(XFMG\Attachment\Media), Object(XF\FileWrapper), Object(SV\WarningImprovements\XF\Entity\User), '10cde1f5d8e2662...')
#8 src/XF/Pub/Controller/Attachment.php(88): XF\Attachment\Manipulator->insertAttachmentFromUpload(Object(XF\Http\Upload), NULL)
#9 src/XF/Mvc/Dispatcher.php(321): XF\Pub\Controller\Attachment->actionUpload(Object(XF\Mvc\ParameterBag))
#10 src/XF/Mvc/Dispatcher.php(248): XF\Mvc\Dispatcher->dispatchClass('XF:Attachment', 'Upload', Object(XF\Mvc\RouteMatch), Object(Xfrocks\AttachmentStore\XF\Pub\Controller\Attachment), NULL)
#11 src/XF/Mvc/Dispatcher.php(100): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(Xfrocks\AttachmentStore\XF\Pub\Controller\Attachment), NULL)
#12 src/XF/Mvc/Dispatcher.php(50): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#13 src/XF/App.php(2177): XF\Mvc\Dispatcher->run()
#14 src/XF.php(392): XF\App->run()
#15 index.php(20): XF::runApp('XF\\Pub\\App')
#16 {main}

Benötigter Status
array(4) {
  ["url"] => string(73) "/attachments/upload?type=xfmg_media&hash=10cde1f5d8e26621fdb1c0294ed7d626"
  ["referrer"] => string(48) "https://www.xentutorials.com/media/albums/create"
  ["_GET"] => array(2) {
    ["type"] => string(10) "xfmg_media"
    ["hash"] => string(32) "10cde1f5d8e26621fdb1c0294ed7d626"
  }
  ["_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) "346819"
    ["flowTotalSize"] => string(6) "346819"
    ["flowIdentifier"] => string(23) "346819-IMG_5290Largejpg"
    ["flowFilename"] => string(20) "IMG_5290 (Large).jpg"
    ["flowRelativePath"] => string(20) "IMG_5290 (Large).jpg"
    ["flowTotalChunks"] => string(1) "1"
  }
}

Edit: I could figure out that has nothing to do with this add-on. I create a bug report at the XFMG forum. That relates to the new XFMG 2.1 RC1
 
Last edited:

I noted this in an earlier discussion, but I don't think it was addressed. My large forum with nearly 2 million posts relies on this addon heavily.

Can this image optimizer play nicely with the convert image addon, and if not is there a work around?

For instance, can I disable one addon for the evening, and run the other to process un-optimized images, and then switch back in the morning?

Looking for a solution to save some hard disk space, I've got over 120GB of attachments to optimize....
 
I noted this in an earlier discussion, but I don't think it was addressed. My large forum with nearly 2 million posts relies on this addon heavily.

Can this image optimizer play nicely with the convert image addon, and if not is there a work around?

For instance, can I disable one addon for the evening, and run the other to process un-optimized images, and then switch back in the morning?

Looking for a solution to save some hard disk space, I've got over 120GB of attachments to optimize....

As long as that add-on is correctly inserting attachments there is no reason it wouldn't work. What exactly happens when you try using it?
 
I haven't used both addons together yet, so I don't know if they are compatible or not myself, just doing some investigating....

The Convert Image addon grabs any photo inserted in a post as with the IMG tag and converts into an attachment if possible.

This process happens moments after a new thread is created or after a new reply is made, I can see that the image does make it into the Image Proxy logs before becoming an attachment, so I don't know where the optimizer falls in the order of events....

At any rate, I didn't know if you had run into this issue before, or if you had already worked it out. If it's still a question, I may end up being the one to troubleshoot it.
 
At any rate, I didn't know if you had run into this issue before, or if you had already worked it out. If it's still a question, I may end up being the one to troubleshoot it.
So far on my test install they seem to be cooperating. I have not gone through the code of each yet (nothing seems to be broken so I haven't had a need/want to tear apart the code) but so far it appears that this add-on works in batch mode after an attachment entity is saved so in the order of things the convert image add-on by @AndyB kicks in first, creates an attachment, when that attachment is created TH Image Optimizer kicks in and adds an entry to it's queue, and everything is normal after that. On my test install I'm using image proxy turned on, Andy's convert, and TH Image Optimizer.
 
I wanted to try and see the results when changing from lossless to lossy. I tried to run the cron automatically after that, but seems like no images were optimized.
 
Thoughts on tracking down what images are causing this error?
ErrorException: Unable to find a suitable image optimizer provider for status ID 190. Note: This is most likely not a bug and this message is only generated to notify you of the issue. Details: File size: 1150, Mime type: image/vnd.microsoft.icon src/XF/Error.php:75
The only allowed attachment types are png, jpg, jpeg, jpe & gif so I'm not sure where it would even be finding an .ico file. Would an entry of what it tried to optimized when that error got thrown be in one of the TH tables?
 
Thoughts on tracking down what images are causing this error?
The only allowed attachment types are png, jpg, jpeg, jpe & gif so I'm not sure where it would even be finding an .ico file. Would an entry of what it tried to optimized when that error got thrown be in one of the TH tables?

It'd be in xf_th_imageoptimizer_status with a status_id of 190, should give you content_type and content_id
 
It'd be in xf_th_imageoptimizer_status with a status_id of 190, should give you content_type and content_id
Found it, it's tied in to XF 2.1 explicitly.... in short, somebody entered a URL that was then 'unfurled' in the post by XF 2.1, the images are attempting to be proxied which includes the unfurled link's favicon.ico file. TH Optimizer is then attempting to optimize the proxied images including the favicon.ico file.

I like the fact that TH Optimizer tried giving me a 'heads up' that it encountered an image with no defined provider but, at the same time, maybe if it wasn't showing up in the ACP in the "Server Error" alerts it'd be a better Admin experience. :)
 
Hello,

Just installed this add-on, am using it with kraken.io

Seemed to work flawlessly, processed about 3,000 images, reporting an average of 14% reduction in file size after optimization.

Then I look at my before and after disc usage in cPanel. I am now using significantly more disc space. That's the opposite of what i was expecting.

Are there some duplicate images or other files I need to be deleting after this runs?

Thanks.
 
Last edited:
Hello,

Just installed this add-on, am using it with kraken.io

Seemed to work flawlessly, processed about 3,000 images, reporting an average of 14% reduction in file size after optimization.

Then I look at my before and after disc usage in cPanel. I am now using significantly more disc space. That's the opposite of what i was expecting.

Are there some duplicate images or other files I need to be deleting after this runs?

Thanks.
Rather weird issue there, go ahead and create a ticket on our support portal so that we can take a closer look.
 
taking a look at this.....one thing im wondering that i didnt see yet is can this optimize ALL images?....or just newly uploaded ones? or single selected ones or something...im talking batch..
 
taking a look at this.....one thing im wondering that i didnt see yet is can this optimize ALL images?....or just newly uploaded ones? or single selected ones or something...im talking batch..

By default it'll only optimize images uploaded after you installed the add-on. If you want to optimize all previously uploaded images you can go to Tools -> Rebuild caches and run the job from there. I'd recommend taking a backup first since it will touch all images. Nothing bad should happen as there are a lot of safeguards in place, but still a good idea :)
 
ok i see now thank you.......trying to guess at how many to try and let it do per page....dealing with over 400k here...pretty decent server power tho..
 
Top Bottom