gifshot icon indicating copy to clipboard operation
gifshot copied to clipboard

Support array of Base64 images, and array of text for each image

Open jasonrojas opened this issue 10 years ago • 12 comments

Any chance we can get support for:

gifshot.createGIF({
    'images': ["data:image/jpeg;base64,/9...", "data:image/jpeg;base64,/9"],
    'text': ["Text1", "Text2"]
}, function (obj) {
    if(!obj.error) {
        var image = obj.image,
        animatedImage = document.createElement('img');
        animatedImage.src = image;
        document.body.appendChild(animatedImage);
    }
});

etc?

jasonrojas avatar Sep 30 '14 20:09 jasonrojas

We can definitely support base 64 existing images, but I don't like the idea of passing an array of text to add to each (the text should already be within the existing GIF)

gfranko avatar Sep 30 '14 20:09 gfranko

What if the text option supported a function, not just a static string? I would also like to layer on some frame-specific text.

adamb0mb avatar Oct 14 '14 21:10 adamb0mb

@adamb0mb I like the idea of providing function support for any options that could be applied per frame (e.g. interval, text, fontWeight, etc), so that a user could write their own logic. How would this look?

'text': function(currentFrame, defaultText) {
  return defaultText;
}

gfranko avatar Oct 15 '14 18:10 gfranko

Short answer: yes, that's roughly what I was thinking.

Longer answer, to make sure we're on the same page: My usage pattern is going to be something like this:

var snapshots = [
  {image: '/images/1.png', timestamp: '2014-10-15', message: 'gifshot is the best'},
  {image: '/images/2.png', timestamp: '2014-10-16', message: 'gifshot is still the best'},
  {image: '/images/3.png', timestamp: '2014-10-17', message: 'gifshot is stiller the best'}
];
gifshot.createGif({
  images: _.pluck(snapshots, 'image'),
  text: function (image, default) {
    // I'm using 'image' to key into my array of images. I don't know how this would work with videos though
    return _.where(snapshots, { image: image }).message || default;
  }
}, function (data) {
  // put that gif on the page!
})

adamb0mb avatar Oct 15 '14 22:10 adamb0mb

Ahh okay. I'll make sure to just return an object in each option's callback function that would look like this:


'text': function(obj) {
  return obj.default;
}
{
  currentFrame: 1,
  image: '/images/1.png',
  video: null,
  default: ''
}

gfranko avatar Oct 15 '14 23:10 gfranko

Yeah, that seems spot on.

Adam

On Wed, Oct 15, 2014 at 4:17 PM, Greg Franko [email protected] wrote:

Ahh okay. I'll make sure to just return an object in each option's callback function that would look like this:

{ currentFrame: 1, image: '/images/1.png', video: null, default: ''}

— Reply to this email directly or view it on GitHub https://github.com/yahoo/gifshot/issues/2#issuecomment-59292024.

adamb0mb avatar Oct 15 '14 23:10 adamb0mb

Hello,

The lonely thing avoiding the dataurl format support seems to be the systematic presence of the "crossorigin" attribute. Dealing with it allows to get base 64 images works. A straightforward and naive solution is to check wether the string begins with "data:image" before adding the attribute to the img tag.

There may be a nicer approach ...

(Great lib, thanks for it !)

fabiolab avatar Dec 21 '14 22:12 fabiolab

Will look into fixing this in the next release

gfranko avatar Jun 28 '17 19:06 gfranko

Is there a "resurrected from the dead" emoji? That could be useful here :-). Glad to see movement from y'all again!

adamb0mb avatar Jun 28 '17 20:06 adamb0mb

@adamb0mb Just took a little bit of a break from open source haha

gfranko avatar Jun 28 '17 20:06 gfranko

I am not using camera stream or any media from browser. I am only passing array of image, but still its giving error regarding 'getUserMedia permission'. How can i fixed this problem.

biplabmalakar avatar Oct 11 '17 05:10 biplabmalakar

hi, has anyone started doing PR for this? perhaps I could take a look. most important is the ability to pass image blob and text to individual frame.

themre avatar Feb 07 '18 09:02 themre