Image optimisation - kraken.io

    • 303 posts
    November 22, 2018 1:20 PM EST

    Has anyone any plans to create a plugin that can use 3rd party image optimizations? 

     

    I used to use Kraken.io and it worked like a dream. I think this would be a well worthwhile plugin as when im checking developer themes they are taking a very long time to loads and it does seem to be more of an issue when there is a lot of images to load. With users uploading images that can be 5mb plus in size it would be ideal. 

     

    Thanks 

    • 303 posts
    November 27, 2018 5:37 PM EST
    Can I bump ?
    • Moderator
    • 6892 posts
    November 28, 2018 5:06 AM EST

    LOL you just did sealed

    • 629 posts
    November 30, 2018 1:36 AM EST

    Bump.

    Bump.

    Bump.

    Responsive images should be a thing. To be loaded via ajax after the site has loaded. Gifs would be ideal.

    • 303 posts
    January 18, 2019 5:46 PM EST

    I got this working myself,think ive mentioned it in another thread but I will share it here anyways incase someone looks. 

     

    I have managed to have all uploaded image files optimised using S3 for AWS , Lambda from AWS and Kraken.io api. 

     

    Get your Kraken Api key from kraken.io

    Create your S3 bucket.

    Create a Lambda Trigger for Each File Type ( .jpg .png .gif )

    Fill int he storage details on the social engine acp for S3 storage 

     

    Below is the code that will reduce the file size, just replace the 'REPLACE ME' with your details.

     

    var kraken = require('kraken') var https = require('https') var querystring = require('querystring') exports.handler = (event, context, callback) => { let records = event.Records for (let i = 0; i < records.length; i++) { getdata(records) } } //This is the lambda function to store images in s3 bucket function getdata (file) { let destination = file.s3.object.key //destination set to object key from s3 bucket let s3_bucket = file.s3.bucket.name // let imageSource = destination.split('/') imageSource = imageSource[imageSource.length - 1] if (imageSource.indexOf('rl-') === 0) { return } if (!(destination.indexOf('.jpg') > 0 || destination.indexOf('.png') > 0)) { return } var Kraken = require('kraken') var kraken = new Kraken({ 'api_key': 'REPLACE ME', // kraken.io api key 'api_secret': 'REPLACE ME' // kraken.io api secret key }) var bucketInfo = { url: 'https://s3.{location}.amazonaws.com/{bucketName}/' + destination, // replace bucketName and location. wait: true, lossy: false, resize: { // resize image according to your needs 'width': 800, 'height': 600, 'strategy': 'auto' }, 's3_store': { 'key': 'REPLACE ME', // replace bucket-key with your key 'secret': 'REPLACE ME', // replace bucket-secret key with your key 'bucket': 'bucketName', // replace bucketName with your name 'path': destination.replace(imageSource, 'rl-' + imageSource), 'region': 'eu-west-1' // replace bucket-region with your region } } //Callback function from server and failure message kraken.url(bucketInfo, function (data, status) { if (status && status.success) { } else { console.log('Fail. Error message: %s', JSON.stringify(data)) } }) };
    • 275 posts
    January 22, 2019 7:52 PM EST

    Peppa, Elshara - Thanks for this post. It looks real awesome.

    Not an expert,, but could sure use your help !!

     

    #1 How do you separate only the images of the social engine website to be stored say, in S3 or an external AWS EC2 bucket??

    * Its always been on my mind - cause we would love to do that , so that we can optimize images.

    (We use all SEAO plugins currently )

     

    #2 Is it possible to store audio/video & photos separately from the main volume (we use aws) ???

     

    Your help and expertise would be greatly appreciated.:))

     

    Thanks in advance.!

     

     

     

    • 275 posts
    January 30, 2019 5:55 AM EST

    If anyone can help explain how to implement this to rookie,

    heres where I've opened a new thread,.

    https://community.socialengine.com/forums/topic/1586/separating-audio-video-photoson-s3-and-kraken-optimize

    Thanks !

    • 36 posts
    March 6, 2019 12:05 PM EST

    This is a great topic which I am looking to implement but I have a question. From the looks of this, this will only optimize images uploaded after the time of implementation. Is it possible to also optimize all the images already stored on S3?

    • 303 posts
    March 6, 2019 12:09 PM EST

    I suppose it depends on how many you have unoptimized. 

     

    When i had a small amount I transferred from s3 to local storage and then back again. 

     

    Drawbacks to this are bandwidth usage, lamda trigger amounts and time. 

    • 36 posts
    March 6, 2019 12:13 PM EST

    We have about 290k images currently on S3 with a total storage of about 14gb. Not sure if transferring local and then back to S3 is the best option.

    • 303 posts
    March 6, 2019 12:16 PM EST

    yeah probably best to not do that, 

    • 275 posts
    March 6, 2019 6:43 PM EST

    Thanks Guys,

     

    Right Now I hvae local storage AND s3 enabled

     

    All files have transferred to S3.

     

    Qtn#1 Is it ok to disable Localstorage ? - It has only 13 files left.

     

    Qtn#2 Should I change the default to S3?

     

    Not sure how these settings in storage system works.

     

     

     


    This post was edited by playmusician at March 6, 2019 6:45 PM EST
    • 303 posts
    March 6, 2019 6:45 PM EST
    I’d leave it active. Them 3 files could be important. Make s3 default though.
    • 303 posts
    March 6, 2019 6:46 PM EST
    Thinking about it. It’s because local storage is default you have 13 images there. Make s3 default, transfer last 3 files then you could disable it. Doubt it’s any harm having it active unless someone knows different.
    • 275 posts
    March 6, 2019 7:23 PM EST

    thanks PPK

     

    have good backups , so i can experiment and check

    will try it

     


    This post was edited by playmusician at March 6, 2019 7:24 PM EST