Giter Site home page Giter Site logo

mhretab / ember-cli-image-cropper Goto Github PK

View Code? Open in Web Editor NEW
41.0 41.0 19.0 547 KB

Ember-cli addon for cropping/resizing images based on the jQuery Cropper plugin.

Home Page: http://mhretab.github.io/ember-cli-image-cropper/

License: MIT License

JavaScript 65.12% HTML 10.06% Handlebars 8.43% SCSS 16.39%

ember-cli-image-cropper's People

Contributors

0000marcell avatar bekzod avatar dguettler avatar estshy avatar imkikus avatar jeffluong avatar joonspoon avatar mhretab avatar rastopyr avatar robbiethewagner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ember-cli-image-cropper's Issues

Add dummy app

Dummy app should be created to show the addon's capability

Please provide a changelog

Hi, ๐Ÿ‘‹

It would be useful to get the list of changes and bugfixes between versions, with migrations notes or recommendations if any. For now we have to search in the code or the Git history for API changes, and it can take some time when you have a lot of dependencies to update.

Please publish a GitHub release for the last version v0.0.14 with some explanations like about what changed and the recommendations to migrate (i.e. #36), and/or provide a CHANGELOG.md file.

See for example https://keepachangelog.com/en/1.0.0/

Thank you. โค๏ธ

problem in using ember-cli-image-cropper

Hello,
I am having problem with using the ember-cli-image-cropper.
I made an ember application.
Made an component avatar-cropper.
then put the code from your io demo. the preview function is working fine, but i am unable to get the cropped avatar.
My avatar-cropper.hbs file looks like

<div class="container">

    <div class="cropper">

         <div class="cropper-container" style="width:400px;">

            <img width="400px" src="image.jpg" class="cropper-hidden">

        </div>

        <div class="preview">

            <div class="img-preview" style="width: 152px; height: 152px;">

                <img src="image.jpg" style="display: block; width: 337.778px; min-width: 0px !important; min-height: 0px !important; max-width: none !important; max-height: none !important; height: 190px; margin-left: 0px; margin-top: 0px; transform: none;">

            </div>

            Preview

        </div>

        <div class="cropped">

            <div class="cropped-avatar">

                <!---->

            </div>

            Cropped Avatar

        </div>

    </div>

    <button {{action "getCroppedAvatar"}}>Crop Avatar</button>

    </div>

{{yield}}

and my avatar-cropper.js file looks like

import Ember from 'ember';

export default Ember.Component.extend({

});

// app/components/avatar-cropper.js
import imageCropper from 'ember-cli-image-cropper/components/image-cropper';

export default imageCropper.extend({
//override default options of cropper
aspectRatio: 1,
minCropBoxWidth: 100,
minCropBoxHeight: 100,
cropperContainer: '.cropper-container > img',
previewClass: '.img-preview',
croppedAvatar: null,

actions:
{
    getCroppedAvatar: function() 
    {
        alert('hi');
        var container = this.$(this.get('cropperContainer'));
        var croppedImage = container.cropper('getCroppedCanvas');
        this.set('croppedAvatar', croppedImage);
        alert('bye');
    }
}
});

the function getCroppedAvatar is working as i get both alert messages, but i dont get the image at cropped area.

screenshot from 2016-06-11 11-59-05

please help me. I am stuck here for a week

problem in uploading different images for cropping

Hello again,
Hey the image cropping is working very well.
But i am having difficulty to upload different images to be cropped; ie. I need to upload an image from the local system and then crop it. the code I an using is as follows.

the hbs file

<div class="container"> 

    <div class="cropper">

        <div class="cropper-container" style="width:400px;">

            <img width="400px" id="img" src="image.jpg">

        </div>

        <div class="preview">

            <div class="img-preview" style="width: 152px; height: 152px;">

            </div>

            Preview

        </div>

        <div class="cropped">

            <div class="cropped-avatar">

                {{croppedAvatar}}

            </div>

            Cropped Avatar

        </div>

  </div>

    <button class="button" {{action "getCroppedAvatar"}}>

        Crop Avatar

    </button>

    <input type="file" id="inputFileToLoad">

    <button  id="button" {{action "loadImageFileAsURL"}}>

         Load Selected File

    </button>
</div>

{{yield}}

and the corresponding js file is

            // app/components/avatar-cropper.js 
            import imageCropper from 'ember-cli-image-cropper/components/image-cropper';

            export default imageCropper.extend({
                //override default options of cropper
                aspectRatio: 1,
                minCropBoxWidth: 100,
                minCropBoxHeight: 100,
                cropperContainer: '.cropper-container > img',
                previewClass: '.img-preview',
                croppedAvatar: null,
                actions:
                {

                    getCroppedAvatar: function() 
                    {
                        var container = this.$(this.get('cropperContainer'));
                        var croppedImage = container.cropper('getCroppedCanvas');
                        this.set('croppedAvatar', croppedImage);
                    },
                    loadImageFileAsURL: function()
                        {

                            var filesSelected = document.getElementById("inputFileToLoad").files;
                            if (filesSelected.length > 0)
                            {
                                var fileToLoad = filesSelected[0];
                                if (fileToLoad.type.match("image.*"))
                                {
                                      var fileReader = new FileReader();
                                    fileReader.onload = function(fileLoadedEvent) 
                                    {
                                        var imageLoaded = document.getElementById("img");
                                      imageLoaded.src = fileLoadedEvent.target.result;

                                    };
                                    fileReader.readAsDataURL(fileToLoad);
                                }

                            }
                        }
                }
            });

but the image is not changing. can you please help out with how to upload an image to a website from a client image and then crop it.

Switch from 0.0.13 to 0.0.14 was a breaking change

I just noticed that our image cropper stopped working after re-deploying the web-app...
the docs don't mention this breaking change, but I can see that the test in tests/dummy/app/components/avatar-cropper.js was updated.

Cannot use base64 encoded data URL as img:src "as is"

I found this library today and I got to find out that one cannot use a base64 encoded data URL as <img src={{image}}/> src attribute directly but one has to call this.$(this.get('cropperContainer')).cropper('replace', this.get('image')) from an observer or something the like to get things up and running...

Did I do something wrong or is this just missing in the documentation/readme?

Initializing cropper sets "cropper-container" element larger than image

When using this component, it sometimes sets the "cropper-container" div wider than the outer image container div. The result is the "left" style attribute of the "cropper-canvas" element is not "0px" but rather a positive value that pushes the image to the right.

I've added some screenshots showing the markup as well as the dom inspector so you can see the what I'm seeing.

before_cropper_init
after_cropper_init
after_cropper_init_left_off

ember-cli-image-cropper: 0.0.10
ember-cli: 2.6.3

I would love a little more explanation on using this component.

I'm just having a hard time understanding how to get this working.

The documentation is a little vague, do I need to call a component in the handlebars template some where, how does the component know what action to fire if I make a new action? How do I set the source of the cropper to the source of my image?

Fix version of HTMLBars

This extension throws out deprecation notes due to the fact that it uses old version of HTMLBars. Please update it to the newest version and make a new release tag and the issue we be solved.

DEPRECATION: Overriding init without calling this._super is deprecated. Please call this._super.init && this._super.init.apply(this, arguments); addon: ember-cli-htmlbars
at Function.Addon.lookup (/Users/estshy/enquicken/site/node_modules/ember-cli/lib/models/addon.js:896:27)

How to use?

How should look a template for your the component?

inconsistency between master branch and npm package

From my understanding the latest master should reflect what is published on npm. Now it is really confusing. I'm installing with ember install ember-cli-image-cropper which installs really outdated code with jQuery and in-compatible api.
E.g. https://ember-twiddle.com/ba1f81d311be62519a9dd74d73634f76?openFiles=twiddle.json%2Ctemplates.components.my-component.hbs
Took me a while to figure out what is going on.

I don't have a strong call to action, just warning to others, probably would face the same issue.

Remove cropper from being bower dependencies

Bower is basically an obsolete package manager as the JS world transitions to npm/yarn. Please consider removing cropper as a bower dependencies and grabbing it with npm instead.

Add test

assess if unit/integration tests are required

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.