Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question about gif format #84

Open
aHyunjaePark opened this issue May 26, 2014 · 5 comments
Open

question about gif format #84

aHyunjaePark opened this issue May 26, 2014 · 5 comments

Comments

@aHyunjaePark
Copy link

Hi,

thanks for the awesome open source, it literally helped me a lot :)

I'm trying to make a preview image viewer, before uploading with plupload.

followed this code.

  function showImagePreview( file ) {

            var item = $( "<li></li>" ).prependTo( dom.uploads );
            var image = $( new Image() ).appendTo( item );

            // Create an instance of the mOxie Image object. This
            // utility object provides several means of reading in
            // and loading image data from various sources.
            // --
            // Wiki: https://github.com/moxiecode/moxie/wiki/Image
            var preloader = new mOxie.Image();

            // Define the onload BEFORE you execute the load()
            // command as load() does not execute async.
            preloader.onload = function() {

                // This will scale the image (in memory) before it
                // tries to render it. This just reduces the amount
                // of Base64 data that needs to be rendered.
                preloader.downsize( 300, 300 );

                // Now that the image is preloaded, grab the Base64
                // encoded data URL. This will show the image
                // without making an Network request using the
                // client-side file binary.
                image.prop( "src", preloader.getAsDataURL() );

                // NOTE: These previews "work" in the FLASH runtime.
                // But, they look seriously junky-to-the-monkey.
                // Looks like they are only using like 256 colors.

            };

            // Calling the .getSource() on the file will return an
            // instance of mOxie.File, which is a unified file
            // wrapper that can be used across the various runtimes.
            // --
            // Wiki: https://github.com/moxiecode/plupload/wiki/File
            preloader.load( file.getSource() );

        }

source :

http://www.bennadel.com/blog/2563-showing-plupload-image-previews-using-base64-encoded-data-urls.htm

In here, this works fine, if the upload file is png, or jpg format.

but it doesn't work, when the format is gif format :(

gif format is not supported? or is the code bug?

in here,

https://github.com/moxiecode/moxie/wiki/Image#getAsDataURL-typeimagejpegquality90-method

it says,

[type="image/jpeg"] String
Mime type of resulting blob. Can either be image/jpeg or image/png

so it means gif is not supported?

I'll be waiting for response

Thank you!

@aHyunjaePark
Copy link
Author

used FileReader instead of Image. and now it works :)

you can close this issue.

@jayarjo
Copy link
Contributor

jayarjo commented Jun 13, 2014

We do not support gifs in our Image wrapper currently. There are various reasons for this, but mainly because requirement for this seems to be very rare :)

@jayarjo jayarjo closed this as completed Jun 13, 2014
@pminf
Copy link

pminf commented May 26, 2015

I vote for this. Need gif support to embed image thumbnails, going to be uploaded with plupload.

@jayarjo
Copy link
Contributor

jayarjo commented May 27, 2015

What do you think we should do with animated gifs (having in mind that people might expect Plupload to resize them on client-side as well)?

@jayarjo jayarjo reopened this May 27, 2015
@pminf
Copy link

pminf commented May 27, 2015

Good point. The basic version could only render the first frame of the GIF. While I'm using moxie image for embedded preview thumbnails in a Plupload queue, this would be OK for my use case. Although it is possible to scale an animated GIF (including all frames) with software like ImageMagick, I don't now if there is a relatively easy way to accomplish this with pure JavaScript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants